on master help sign in
Turn off TagSoup escaping
b5f864aJasper Van der Jeugt
src/Hakyll/Web/Urls.hs+11−10
@@ -11,17 +11,18 @@ import Data.List (isPrefixOf)
11import System.FilePath (splitPath, takeDirectory, joinPath)
11import System.FilePath (splitPath, takeDirectory, joinPath)
12import qualified Data.Set as S
12import qualified Data.Set as S
13
13
14−import Text.HTML.TagSoup (Tag (..), renderTags, parseTags)
14+import qualified Text.HTML.TagSoup as TS
15
15
16-- | Apply a function to each URL on a webpage
16-- | Apply a function to each URL on a webpage
17--
17--
18withUrls :: (String -> String) -> String -> String
18withUrls :: (String -> String) -> String -> String
19−withUrls f = renderTags . map tag . parseTags
19+withUrls f = TS.renderTagsOptions opts . map tag . TS.parseTags
20 where
20 where
21− tag (TagOpen s a) = TagOpen s $ map attr a
21+ tag (TS.TagOpen s a) = TS.TagOpen s $ map attr a
22− tag x = x
22+ tag x = x
23− attr (k, v) = (k, if k `S.member` refs then f v else v)
23+ attr (k, v) = (k, if k `S.member` refs then f v else v)
24− refs = S.fromList ["src", "href"]
24+ refs = S.fromList ["src", "href"]
25+ opts = TS.renderOptions {TS.optEscape = id}
25
26
26-- | Convert a filepath to an URL starting from the site root
27-- | Convert a filepath to an URL starting from the site root
27--
28--
@@ -43,12 +44,12 @@ toSiteRoot :: String -> String
43toSiteRoot = emptyException . joinPath . map parent
44toSiteRoot = emptyException . joinPath . map parent
44 . filter relevant . splitPath . takeDirectory
45 . filter relevant . splitPath . takeDirectory
45 where
46 where
46− parent = const ".."
47+ parent = const ".."
47 emptyException [] = "."
48 emptyException [] = "."
48 emptyException x = x
49 emptyException x = x
49− relevant "." = False
50+ relevant "." = False
50− relevant "/" = False
51+ relevant "/" = False
51− relevant _ = True
52+ relevant _ = True
52
53
53-- | Check if an URL links to an external HTTP(S) source
54-- | Check if an URL links to an external HTTP(S) source
54--
55--
src/Hakyll/Web/Urls/Relativize.hs+1−1
@@ -34,7 +34,7 @@ import Hakyll.Web.Urls
34relativizeUrlsCompiler :: Compiler (Page String) (Page String)
34relativizeUrlsCompiler :: Compiler (Page String) (Page String)
35relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize
35relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize
36 where
36 where
37− relativize Nothing = id
37+ relativize Nothing = id
38 relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)
38 relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)
39
39
40-- | Relativize URL's in HTML
40-- | Relativize URL's in HTML