on master help sign in
Fix TagSoup options and bump its dependency
98d311eJasper Van der Jeugt
hakyll.cabal+1−1
@@ -77,7 +77,7 @@ Library
77 process >= 1.0 && < 1.4,
77 process >= 1.0 && < 1.4,
78 regex-base >= 0.93 && < 1.0,
78 regex-base >= 0.93 && < 1.0,
79 regex-pcre >= 0.93 && < 1.0,
79 regex-pcre >= 0.93 && < 1.0,
80− tagsoup >= 0.12 && < 0.13,
80+ tagsoup >= 0.12.6 && < 0.13,
81 time >= 1.1 && < 1.3,
81 time >= 1.1 && < 1.3,
82 unix >= 2.4 && < 2.6
82 unix >= 2.4 && < 2.6
83
83
src/Hakyll/Web/Pandoc/FileType.hs+7−5
@@ -16,14 +16,15 @@ import Hakyll.Core.Compiler
16-- default
16-- default
17--
17--
18data FileType
18data FileType
19+ = Binary
20+ | Css
19− = Html
21+ | Html
20 | LaTeX
22 | LaTeX
21 | LiterateHaskell FileType
23 | LiterateHaskell FileType
22 | Markdown
24 | Markdown
23− | Rst
25+ | OrgMode
24 | PlainText
26 | PlainText
25− | Css
27+ | Rst
26− | Binary
27 deriving (Eq, Ord, Show, Read)
28 deriving (Eq, Ord, Show, Read)
28
29
29-- | Get the file type for a certain file. The type is determined by extension.
30-- | Get the file type for a certain file. The type is determined by extension.
@@ -31,6 +32,7 @@ data FileType
31fileType :: FilePath -> FileType
32fileType :: FilePath -> FileType
32fileType = fileType' . takeExtension
33fileType = fileType' . takeExtension
33 where
34 where
35+ fileType' ".css" = Css
34 fileType' ".htm" = Html
36 fileType' ".htm" = Html
35 fileType' ".html" = Html
37 fileType' ".html" = Html
36 fileType' ".lhs" = LiterateHaskell Markdown
38 fileType' ".lhs" = LiterateHaskell Markdown
@@ -41,12 +43,12 @@ fileType = fileType' . takeExtension
41 fileType' ".mdwn" = Markdown
43 fileType' ".mdwn" = Markdown
42 fileType' ".mkd" = Markdown
44 fileType' ".mkd" = Markdown
43 fileType' ".mkdwn" = Markdown
45 fileType' ".mkdwn" = Markdown
46+ fileType' ".org" = OrgMode
44 fileType' ".page" = Markdown
47 fileType' ".page" = Markdown
45 fileType' ".rst" = Rst
48 fileType' ".rst" = Rst
46 fileType' ".tex" = LaTeX
49 fileType' ".tex" = LaTeX
47 fileType' ".text" = PlainText
50 fileType' ".text" = PlainText
48 fileType' ".txt" = PlainText
51 fileType' ".txt" = PlainText
49− fileType' ".css" = Css
50 fileType' _ = Binary -- Treat unknown files as binary
52 fileType' _ = Binary -- Treat unknown files as binary
51
53
52-- | Get the file type for the current file
54-- | Get the file type for the current file
src/Hakyll/Web/Urls.hs+1−2
@@ -16,13 +16,12 @@ import qualified Text.HTML.TagSoup as TS
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 = TS.renderTagsOptions opts . map tag . TS.parseTags
19+withUrls f = TS.renderTags . map tag . TS.parseTags
20 where
20 where
21 tag (TS.TagOpen s a) = TS.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}
26
25
27-- | Convert a filepath to an URL starting from the site root
26-- | Convert a filepath to an URL starting from the site root
28--
27--
tests/Hakyll/Web/Urls/Tests.hs+6
@@ -17,6 +17,12 @@ tests = concat
17 withUrls (map toUpper) "<a href=\"foo\">bar</a>"
17 withUrls (map toUpper) "<a href=\"foo\">bar</a>"
18 , "<img src=\"OH BAR\">" @=?
18 , "<img src=\"OH BAR\">" @=?
19 withUrls (map toUpper) "<img src=\"oh bar\">"
19 withUrls (map toUpper) "<img src=\"oh bar\">"
20+
21+ -- Test escaping
22+ , "<script>\"sup\"</script>" @=?
23+ withUrls id "<script>\"sup\"</script>"
24+ , "<code>&lt;stdio&gt;</code>" @=?
25+ withUrls id "<code>&lt;stdio&gt;</code>"
20 ]
26 ]
21 , fromAssertions "toUrl"
27 , fromAssertions "toUrl"
22 [ "/foo/bar.html" @=? toUrl "foo/bar.html"
28 [ "/foo/bar.html" @=? toUrl "foo/bar.html"