on master help sign in
Don't have TagSoup decode any HTML entities
8d22340Jasper Van der Jeugt
src/Hakyll/Web/Html.hs+10−1
@@ -36,7 +36,7 @@ import Network.URI (isUnreserved, escapeURIString)
36--------------------------------------------------------------------------------
36--------------------------------------------------------------------------------
37-- | Map over all tags in the document
37-- | Map over all tags in the document
38withTags :: (TS.Tag String -> TS.Tag String) -> String -> String
38withTags :: (TS.Tag String -> TS.Tag String) -> String -> String
39−withTags f = renderTags' . map f . TS.parseTags
39+withTags f = renderTags' . map f . parseTags'
40
40
41
41
42--------------------------------------------------------------------------------
42--------------------------------------------------------------------------------
@@ -90,6 +90,15 @@ renderTags' = TS.renderTagsOptions TS.RenderOptions
90 ]
90 ]
91
91
92
92
93+--------------------------------------------------------------------------------
94+-- | Customized TagSoup parser: do not decode any entities.
95+parseTags' :: String -> [TS.Tag String]
96+parseTags' = TS.parseTagsOptions (TS.parseOptions :: TS.ParseOptions String)
97+ { TS.optEntityData = \(str, b) -> [TS.TagText $ "&" ++ str ++ [';' | b]]
98+ , TS.optEntityAttrib = \(str, b) -> ("&" ++ str ++ [';' | b], [])
99+ }
100+
101+
93--------------------------------------------------------------------------------
102--------------------------------------------------------------------------------
94-- | Convert a filepath to an URL starting from the site root
103-- | Convert a filepath to an URL starting from the site root
95--
104--