From 43d2736a2b1dd7345bcb6d9016c04e471c002ffd Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Thu, 18 Aug 2016 01:22:50 +0200 Subject: Fix feed generator when item contains CDATA --- src/Hakyll/Web/Feed.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3