summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2016-10-17 09:46:23 +0200
committerGitHub <noreply@github.com>2016-10-17 09:46:23 +0200
commit43e78fcdc755adcac61b3d2f1645037d3eff8fbb (patch)
treed8e04a39312eef0184096898b8d5f84039287708 /src
parent9d4640b76431be46847f28ea6d167bce83500e03 (diff)
parent43d2736a2b1dd7345bcb6d9016c04e471c002ffd (diff)
downloadhakyll-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.hs8
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 "]]&gt;")
-- Auxiliary: load a template from a datafile
loadTemplate path = do
file <- compilerUnsafeIO $ getDataFileName path