summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-01-25 10:36:17 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-01-25 10:36:17 +0100
commit98d311ebc87d8818160bd9c115b8cac4b958c4e1 (patch)
tree49ca87696ffc16a89a03d7d9985cabcdc30d1758
parentd31e92c09dc824a9347ec935f1dbebfa1512226a (diff)
downloadhakyll-98d311ebc87d8818160bd9c115b8cac4b958c4e1.tar.gz
Fix TagSoup options and bump its dependency
-rw-r--r--hakyll.cabal2
-rw-r--r--src/Hakyll/Web/Pandoc/FileType.hs12
-rw-r--r--src/Hakyll/Web/Urls.hs3
-rw-r--r--tests/Hakyll/Web/Urls/Tests.hs6
4 files changed, 15 insertions, 8 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 45799fb..cc0e107 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -77,7 +77,7 @@ Library
process >= 1.0 && < 1.4,
regex-base >= 0.93 && < 1.0,
regex-pcre >= 0.93 && < 1.0,
- tagsoup >= 0.12 && < 0.13,
+ tagsoup >= 0.12.6 && < 0.13,
time >= 1.1 && < 1.3,
unix >= 2.4 && < 2.6
diff --git a/src/Hakyll/Web/Pandoc/FileType.hs b/src/Hakyll/Web/Pandoc/FileType.hs
index 670f1eb..a10de1c 100644
--- a/src/Hakyll/Web/Pandoc/FileType.hs
+++ b/src/Hakyll/Web/Pandoc/FileType.hs
@@ -16,14 +16,15 @@ import Hakyll.Core.Compiler
-- default
--
data FileType
- = Html
+ = Binary
+ | Css
+ | Html
| LaTeX
| LiterateHaskell FileType
| Markdown
- | Rst
+ | OrgMode
| PlainText
- | Css
- | Binary
+ | Rst
deriving (Eq, Ord, Show, Read)
-- | Get the file type for a certain file. The type is determined by extension.
@@ -31,6 +32,7 @@ data FileType
fileType :: FilePath -> FileType
fileType = fileType' . takeExtension
where
+ fileType' ".css" = Css
fileType' ".htm" = Html
fileType' ".html" = Html
fileType' ".lhs" = LiterateHaskell Markdown
@@ -41,12 +43,12 @@ fileType = fileType' . takeExtension
fileType' ".mdwn" = Markdown
fileType' ".mkd" = Markdown
fileType' ".mkdwn" = Markdown
+ fileType' ".org" = OrgMode
fileType' ".page" = Markdown
fileType' ".rst" = Rst
fileType' ".tex" = LaTeX
fileType' ".text" = PlainText
fileType' ".txt" = PlainText
- fileType' ".css" = Css
fileType' _ = Binary -- Treat unknown files as binary
-- | Get the file type for the current file
diff --git a/src/Hakyll/Web/Urls.hs b/src/Hakyll/Web/Urls.hs
index f41d323..7f33ab0 100644
--- a/src/Hakyll/Web/Urls.hs
+++ b/src/Hakyll/Web/Urls.hs
@@ -16,13 +16,12 @@ import qualified Text.HTML.TagSoup as TS
-- | Apply a function to each URL on a webpage
--
withUrls :: (String -> String) -> String -> String
-withUrls f = TS.renderTagsOptions opts . map tag . TS.parseTags
+withUrls f = TS.renderTags . map tag . TS.parseTags
where
tag (TS.TagOpen s a) = TS.TagOpen s $ map attr a
tag x = x
attr (k, v) = (k, if k `S.member` refs then f v else v)
refs = S.fromList ["src", "href"]
- opts = TS.renderOptions {TS.optEscape = id}
-- | Convert a filepath to an URL starting from the site root
--
diff --git a/tests/Hakyll/Web/Urls/Tests.hs b/tests/Hakyll/Web/Urls/Tests.hs
index db7a10b..d7bd3a6 100644
--- a/tests/Hakyll/Web/Urls/Tests.hs
+++ b/tests/Hakyll/Web/Urls/Tests.hs
@@ -17,6 +17,12 @@ tests = concat
withUrls (map toUpper) "<a href=\"foo\">bar</a>"
, "<img src=\"OH BAR\">" @=?
withUrls (map toUpper) "<img src=\"oh bar\">"
+
+ -- Test escaping
+ , "<script>\"sup\"</script>" @=?
+ withUrls id "<script>\"sup\"</script>"
+ , "<code>&lt;stdio&gt;</code>" @=?
+ withUrls id "<code>&lt;stdio&gt;</code>"
]
, fromAssertions "toUrl"
[ "/foo/bar.html" @=? toUrl "foo/bar.html"