From afbc3c0556a0b1d45834091a6c9a3ddfc3ebe4f8 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Sat, 13 Jul 2019 16:55:46 +1200 Subject: [PATCH] Fix for parsing HTTP responses, test for speech media. --- src/Main.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index 924cc2d..ed0d9b8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -42,14 +42,19 @@ externalStyles html manager base = go $ linkedStyles html linkedStyles (XML.Element "link" attrs _) | Just link <- "href" `M.lookup` attrs, Just "stylesheet" <- "rel" `M.lookup` attrs, + testMedia attrs, Just uri <- parseURIReference $ unpack link = [uri] linkedStyles (XML.Element _ _ children) = concat [linkedStyles el | XML.NodeElement el <- children] -internalStyles (XML.Element "style" _ children) = [strContent children] +internalStyles (XML.Element "style" attrs children) + | testMedia attrs = [strContent children] internalStyles (XML.Element _ _ children) = concat [internalStyles el | XML.NodeElement el <- children] +testMedia attrs = media == Nothing || media == Just "speech" + where media = "media" `M.lookup` attrs + strContent (XML.NodeContent text : rest) = unpack text ++ strContent rest -- We do want to read in comments for CSS, just not for display. -- 2.30.2