From 8d22340e7a633bfc8e5dbfa80c97159c796035a6 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 25 Aug 2014 11:16:34 +0200 Subject: Don't have TagSoup decode any HTML entities --- src/Hakyll/Web/Html.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Hakyll/Web/Html.hs b/src/Hakyll/Web/Html.hs index a86ac1e..bed7755 100644 --- a/src/Hakyll/Web/Html.hs +++ b/src/Hakyll/Web/Html.hs @@ -36,7 +36,7 @@ import Network.URI (isUnreserved, escapeURIString) -------------------------------------------------------------------------------- -- | Map over all tags in the document withTags :: (TS.Tag String -> TS.Tag String) -> String -> String -withTags f = renderTags' . map f . TS.parseTags +withTags f = renderTags' . map f . parseTags' -------------------------------------------------------------------------------- @@ -90,6 +90,15 @@ renderTags' = TS.renderTagsOptions TS.RenderOptions ] +-------------------------------------------------------------------------------- +-- | Customized TagSoup parser: do not decode any entities. +parseTags' :: String -> [TS.Tag String] +parseTags' = TS.parseTagsOptions (TS.parseOptions :: TS.ParseOptions String) + { TS.optEntityData = \(str, b) -> [TS.TagText $ "&" ++ str ++ [';' | b]] + , TS.optEntityAttrib = \(str, b) -> ("&" ++ str ++ [';' | b], []) + } + + -------------------------------------------------------------------------------- -- | Convert a filepath to an URL starting from the site root -- -- cgit v1.2.3