~alcinnz/rhapsode

36872a78ccd8fb2d5646a475e5da8e9a84f2b3c8 — Adrian Cochrane 5 years ago ec79689
Correctly match tagnames (syntax error).

How did this regress?
1 files changed, 2 insertions(+), 4 deletions(-)

M src/Main.hs
M src/Main.hs => src/Main.hs +2 -4
@@ 27,10 27,8 @@ main = do
    -- TODO support more URI schemes, and do nonblocking networking. This could be it's own module.
    request <- HTTP.parseRequest url
    manager <- HTTP.newManager TLS.tlsManagerSettings
    putStrLn "Loading page..."
    response <- HTTP.httpLbs request manager
    let html = XML.documentRoot $ HTML.parseLBS $ HTTP.responseBody response
    putStrLn "Loaded page!"
    style <- retreiveStyles html manager request
    C8.putStrLn $ renderElLBS $ stylizeEl style html



@@ 62,7 60,7 @@ externalStyles html manager base = go $ linkedStyles html
            return (Txt.pack (C8.unpack $ HTTP.responseBody response) : rest)
        go [] = return []

linkedStyles (XML.Element "link" attrs _)
linkedStyles (XML.Element (XML.Name "link" _ _) attrs _)
    | Just link <- "href" `M.lookup` attrs,
        Just "stylesheet" <- "rel" `M.lookup` attrs,
        testMedia attrs,


@@ 70,7 68,7 @@ linkedStyles (XML.Element "link" attrs _)
linkedStyles (XML.Element _ _ children) =
    concat [linkedStyles el | XML.NodeElement el <- children]

internalStyles (XML.Element "style" attrs children)
internalStyles (XML.Element (XML.Name "style" _ _) attrs children)
    | testMedia attrs = [strContent children]
internalStyles (XML.Element _ _ children) =
    concat [internalStyles el | XML.NodeElement el <- children]