From 12fc781ec61a9cecf0000fe4a32965e8ce525b82 Mon Sep 17 00:00:00 2001 From: Adrian Cochrane Date: Thu, 7 Jan 2021 19:59:19 +1300 Subject: [PATCH] Better label rel=stylesheet --- src/Links.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Links.hs b/src/Links.hs index 89e6288..7914c51 100644 --- a/src/Links.hs +++ b/src/Links.hs @@ -60,9 +60,15 @@ extractEl _ (Element "{https://specifications.freedesktop.org/metainfo/1.0}url" | Just label <- "{https://specifications.freedesktop.org/metainfo/1.0}type" `M.lookup` attrs, Just url <- parseAbsoluteURI $ unpack $ nodesText childs "" = [Link label "" url] extractEl _ el@(Element _ attrs []) - | Just "alternae" <- "rel" `M.lookup` attrs', Just typ <- "type" `M.lookup` attrs', + | Just "alternate" <- "rel" `M.lookup` attrs', Just typ <- "type" `M.lookup` attrs', Just val <- "href" `M.lookup` attrs', Just uri <- parseURIReference $ unpack val = - let Application name _ title _ = mimeInfoCached $ unpack typ + let Application name _ title _ = mimeInfo $ unpack typ + in [Link (pack name) (pack title) uri] + where attrs' = M.mapKeys nameLocalName attrs +extractEl _ el@(Element (Name "link" _ _) attrs []) + | Just "stylesheet" <- "rel" `M.lookup` attrs', Nothing <- "title" `M.lookup` attrs', + Just val <- "href" `M.lookup` attrs', Just uri <- parseURIReference $ unpack val = + let Application name _ title _ = mimeInfo "text/css" in [Link (pack name) (pack title) uri] where attrs' = M.mapKeys nameLocalName attrs extractEl path el@(Element _ _ children) = -- 2.30.2