diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2016-10-17 09:46:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-17 09:46:23 +0200 |
commit | 43e78fcdc755adcac61b3d2f1645037d3eff8fbb (patch) | |
tree | d8e04a39312eef0184096898b8d5f84039287708 /src | |
parent | 9d4640b76431be46847f28ea6d167bce83500e03 (diff) | |
parent | 43d2736a2b1dd7345bcb6d9016c04e471c002ffd (diff) | |
download | hakyll-43e78fcdc755adcac61b3d2f1645037d3eff8fbb.tar.gz |
Merge pull request #464 from yogsototh/fix-feed-with-cdata
Fix feed generator when item contains CDATA
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Web/Feed.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Feed.hs b/src/Hakyll/Web/Feed.hs index f40fa8a..6c6fa76 100644 --- a/src/Hakyll/Web/Feed.hs +++ b/src/Hakyll/Web/Feed.hs @@ -27,6 +27,7 @@ module Hakyll.Web.Feed import Hakyll.Core.Compiler import Hakyll.Core.Compiler.Internal import Hakyll.Core.Item +import Hakyll.Core.Util.String (replaceAll) import Hakyll.Web.Template import Hakyll.Web.Template.Context import Hakyll.Web.Template.List @@ -64,9 +65,14 @@ renderFeed feedPath itemPath config itemContext items = do feedTpl <- loadTemplate feedPath itemTpl <- loadTemplate itemPath - body <- makeItem =<< applyTemplateList itemTpl itemContext' items + protectedItems <- mapM (applyFilter protectCDATA) items + body <- makeItem =<< applyTemplateList itemTpl itemContext' protectedItems applyTemplate feedTpl feedContext body where + applyFilter :: (Monad m,Functor f) => (String -> String) -> f String -> m (f String) + applyFilter tr str = return $ fmap tr str + protectCDATA :: String -> String + protectCDATA = replaceAll "]]>" (const "]]>") -- Auxiliary: load a template from a datafile loadTemplate path = do file <- compilerUnsafeIO $ getDataFileName path |