diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2012-06-10 06:58:06 -0700 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2012-06-10 06:58:06 -0700 |
commit | 77ebb46ebae337cae0d7c14399dbfcd8139c72b0 (patch) | |
tree | c74bd8effc29ed36ae3febfde956af537275c014 /src/Hakyll | |
parent | 2df6ca0d6f6220e4a24746526e6918572b6399f0 (diff) | |
parent | f96174bfcc527b7959488cd1a70527ced3884f99 (diff) | |
download | hakyll-77ebb46ebae337cae0d7c14399dbfcd8139c72b0.tar.gz |
Merge pull request #69 from favonia/master
Do not escape contents within 'style' tags.
Diffstat (limited to 'src/Hakyll')
-rw-r--r-- | src/Hakyll/Web/Urls.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Urls.hs b/src/Hakyll/Web/Urls.hs index 7f33ab0..cfa9b42 100644 --- a/src/Hakyll/Web/Urls.hs +++ b/src/Hakyll/Web/Urls.hs @@ -8,6 +8,7 @@ module Hakyll.Web.Urls ) where import Data.List (isPrefixOf) +import Data.Char (toLower) import System.FilePath (splitPath, takeDirectory, joinPath) import qualified Data.Set as S @@ -16,13 +17,20 @@ import qualified Text.HTML.TagSoup as TS -- | Apply a function to each URL on a webpage -- withUrls :: (String -> String) -> String -> String -withUrls f = TS.renderTags . map tag . TS.parseTags +withUrls f = 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"] +-- | Customized TagSoup renderer. +-- (The default TagSoup renderer escape CSS within style tags.) +renderTags' :: [TS.Tag String] -> String +renderTags' = TS.renderTagsOptions TS.renderOptions + { TS.optRawTag = (`elem` ["script", "style"]) . map toLower + } + -- | Convert a filepath to an URL starting from the site root -- -- Example: |