on master help sign in
Fix TagSoup options and bump its dependency
commit98d311ebc87d8818160bd9c115b8cac4b958c4e1 authorJasper Van der Jeugt <m@jaspervdj.be> dateWed 25 Jan 2012, 10:36 (15 years ago) parentd31e92c
4 files changed+15−8
hakyll.cabal+1−1 src/Hakyll/Web/Pandoc/FileType.hs+7−5 src/Hakyll/Web/Urls.hs+1−2 tests/Hakyll/Web/Urls/Tests.hs+6
hakyll.cabal+1−1
@@ -77,7 +77,7 @@ Library
7777 process >= 1.0 && < 1.4,
7878 regex-base >= 0.93 && < 1.0,
7979 regex-pcre >= 0.93 && < 1.0,
80− tagsoup >= 0.12 && < 0.13,
80+ tagsoup >= 0.12.6 && < 0.13,
8181 time >= 1.1 && < 1.3,
8282 unix >= 2.4 && < 2.6
8383
src/Hakyll/Web/Pandoc/FileType.hs+7−5
@@ -16,14 +16,15 @@ import Hakyll.Core.Compiler
1616-- default
1717--
1818data FileType
19− = Html
19+ = Binary
20+ | Css
21+ | Html
2022 | LaTeX
2123 | LiterateHaskell FileType
2224 | Markdown
23− | Rst
25+ | OrgMode
2426 | PlainText
25− | Css
26− | Binary
27+ | Rst
2728 deriving (Eq, Ord, Show, Read)
2829
2930-- | Get the file type for a certain file. The type is determined by extension.
@@ -31,6 +32,7 @@ data FileType
3132fileType :: FilePath -> FileType
3233fileType = fileType' . takeExtension
3334 where
35+ fileType' ".css" = Css
3436 fileType' ".htm" = Html
3537 fileType' ".html" = Html
3638 fileType' ".lhs" = LiterateHaskell Markdown
@@ -41,12 +43,12 @@ fileType = fileType' . takeExtension
4143 fileType' ".mdwn" = Markdown
4244 fileType' ".mkd" = Markdown
4345 fileType' ".mkdwn" = Markdown
46+ fileType' ".org" = OrgMode
4447 fileType' ".page" = Markdown
4548 fileType' ".rst" = Rst
4649 fileType' ".tex" = LaTeX
4750 fileType' ".text" = PlainText
4851 fileType' ".txt" = PlainText
49− fileType' ".css" = Css
5052 fileType' _ = Binary -- Treat unknown files as binary
5153
5254-- | 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
1616-- | Apply a function to each URL on a webpage
1717--
1818withUrls :: (String -> String) -> String -> String
19−withUrls f = TS.renderTagsOptions opts . map tag . TS.parseTags
19+withUrls f = TS.renderTags . map tag . TS.parseTags
2020 where
2121 tag (TS.TagOpen s a) = TS.TagOpen s $ map attr a
2222 tag x = x
2323 attr (k, v) = (k, if k `S.member` refs then f v else v)
2424 refs = S.fromList ["src", "href"]
25− opts = TS.renderOptions {TS.optEscape = id}
2625
2726-- | Convert a filepath to an URL starting from the site root
2827--
tests/Hakyll/Web/Urls/Tests.hs+6
@@ -17,6 +17,12 @@ tests = concat
1717 withUrls (map toUpper) "<a href=\"foo\">bar</a>"
1818 , "<img src=\"OH BAR\">" @=?
1919 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>"
2026 ]
2127 , fromAssertions "toUrl"
2228 [ "/foo/bar.html" @=? toUrl "foo/bar.html"