on master help sign in
Don't have TagSoup decode any HTML entities
commit8d22340e7a633bfc8e5dbfa80c97159c796035a6 authorJasper Van der Jeugt <m@jaspervdj.be> dateMon 25 Aug 2014, 11:16 (12 years ago) parentb4f264d
1 file changed+10−1
src/Hakyll/Web/Html.hs+10−1
src/Hakyll/Web/Html.hs+10−1
@@ -36,7 +36,7 @@ import Network.URI (isUnreserved, escapeURIString)
3636--------------------------------------------------------------------------------
3737-- | Map over all tags in the document
3838withTags :: (TS.Tag String -> TS.Tag String) -> String -> String
39−withTags f = renderTags' . map f . TS.parseTags
39+withTags f = renderTags' . map f . parseTags'
4040
4141
4242--------------------------------------------------------------------------------
@@ -90,6 +90,15 @@ renderTags' = TS.renderTagsOptions TS.RenderOptions
9090 ]
9191
9292
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+
93102--------------------------------------------------------------------------------
94103-- | Convert a filepath to an URL starting from the site root
95104--