~alcinnz/rhapsode

5c48d5e02f1dc047554fd8052643f13ea90cdd90 — Adrian Cochrane 4 years ago 3898dfa
Implement :target pseudoclass.

Defaults to <main> to further avoid excess clutter from pages.
1 files changed, 9 insertions(+), 1 deletions(-)

M src/Render.hs
M src/Render.hs => src/Render.hs +9 -1
@@ 112,6 112,14 @@ loadUserStyles styles = do
        CSS.parse style (Txt.pack source) `loadFiles` files
    loadFiles style [] = return style

targetSel "" = [CSSTok.Ident "main"]
targetSel ('#':id) = [CSSTok.Hash CSSTok.HUnrestricted $ Txt.pack id]
targetSel _ = []

rhapsodePseudoFilter url = CSSPseudo.addRewrite "link" "[src], [href]" $
    CSSPseudo.addRewrite' "target" (targetSel $ uriFragment url) $
    CSSPseudo.htmlPsuedoFilter Style.queryableStyleSheet

--------
---- Download assets
--------


@@ 137,7 145,7 @@ c_renderDoc c_session c_page rewriteURLs = do
    session <- deRefStablePtr c_session
    page <- deRefStablePtr c_page
    css' <- retreiveStyles session $ css page
    let pseudoFilter = CSSPseudo.htmlPsuedoFilter Style.queryableStyleSheet
    let pseudoFilter = rhapsodePseudoFilter $ url page
    qCSS <- if rewriteURLs then do
        assets <- downloadAssets session [
                "audio/vnd.wav"