summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYann Esposito (Yogsototh) <yann.esposito@gmail.com>2016-08-18 01:22:50 +0200
committerYann Esposito (Yogsototh) <yann.esposito@gmail.com>2016-08-18 01:22:50 +0200
commit43d2736a2b1dd7345bcb6d9016c04e471c002ffd (patch)
tree0f33e735685e55a375aba39fd6976441497b0c53 /src
parent2ef6d118df38ec1776056cc2506127401d9e5385 (diff)
downloadhakyll-43d2736a2b1dd7345bcb6d9016c04e471c002ffd.tar.gz
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