on master help sign in
Turn off TagSoup escaping
commitb5f864afc00d39f42ba8496a2f81ba5a0e3b2239 authorJasper Van der Jeugt <m@jaspervdj.be> dateThu 19 Jan 2012, 19:46 (15 years ago) parentdabaa45
2 files changed+12−11
src/Hakyll/Web/Urls.hs+11−10 src/Hakyll/Web/Urls/Relativize.hs+1−1
src/Hakyll/Web/Urls.hs+11−10
@@ -11,17 +11,18 @@ import Data.List (isPrefixOf)
1111import System.FilePath (splitPath, takeDirectory, joinPath)
1212import qualified Data.Set as S
1313
14−import Text.HTML.TagSoup (Tag (..), renderTags, parseTags)
14+import qualified Text.HTML.TagSoup as TS
1515
1616-- | Apply a function to each URL on a webpage
1717--
1818withUrls :: (String -> String) -> String -> String
19−withUrls f = renderTags . map tag . parseTags
19+withUrls f = TS.renderTagsOptions opts . map tag . TS.parseTags
2020 where
21− tag (TagOpen s a) = TagOpen s $ map attr a
22− tag x = x
23− attr (k, v) = (k, if k `S.member` refs then f v else v)
24− refs = S.fromList ["src", "href"]
21+ tag (TS.TagOpen s a) = TS.TagOpen s $ map attr a
22+ tag x = x
23+ attr (k, v) = (k, if k `S.member` refs then f v else v)
24+ refs = S.fromList ["src", "href"]
25+ opts = TS.renderOptions {TS.optEscape = id}
2526
2627-- | Convert a filepath to an URL starting from the site root
2728--
@@ -43,12 +44,12 @@ toSiteRoot :: String -> String
4344toSiteRoot = emptyException . joinPath . map parent
4445 . filter relevant . splitPath . takeDirectory
4546 where
46− parent = const ".."
47+ parent = const ".."
4748 emptyException [] = "."
4849 emptyException x = x
49− relevant "." = False
50− relevant "/" = False
51− relevant _ = True
50+ relevant "." = False
51+ relevant "/" = False
52+ relevant _ = True
5253
5354-- | Check if an URL links to an external HTTP(S) source
5455--
src/Hakyll/Web/Urls/Relativize.hs+1−1
@@ -34,7 +34,7 @@ import Hakyll.Web.Urls
3434relativizeUrlsCompiler :: Compiler (Page String) (Page String)
3535relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize
3636 where
37− relativize Nothing = id
37+ relativize Nothing = id
3838 relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)
3939
4040-- | Relativize URL's in HTML