on master help sign in
Merge pull request #464 from yogsototh/fix-feed-with-cdata
43e78fcJasper Van der Jeugt
src/Hakyll/Web/Feed.hs+7−1
@@ -27,6 +27,7 @@ module Hakyll.Web.Feed
27import Hakyll.Core.Compiler
27import Hakyll.Core.Compiler
28import Hakyll.Core.Compiler.Internal
28import Hakyll.Core.Compiler.Internal
29import Hakyll.Core.Item
29import Hakyll.Core.Item
30+import Hakyll.Core.Util.String (replaceAll)
30import Hakyll.Web.Template
31import Hakyll.Web.Template
31import Hakyll.Web.Template.Context
32import Hakyll.Web.Template.Context
32import Hakyll.Web.Template.List
33import Hakyll.Web.Template.List
@@ -64,9 +65,14 @@ renderFeed feedPath itemPath config itemContext items = do
64 feedTpl <- loadTemplate feedPath
65 feedTpl <- loadTemplate feedPath
65 itemTpl <- loadTemplate itemPath
66 itemTpl <- loadTemplate itemPath
66
67
68+ protectedItems <- mapM (applyFilter protectCDATA) items
67− body <- makeItem =<< applyTemplateList itemTpl itemContext' items
69+ body <- makeItem =<< applyTemplateList itemTpl itemContext' protectedItems
68 applyTemplate feedTpl feedContext body
70 applyTemplate feedTpl feedContext body
69 where
71 where
72+ applyFilter :: (Monad m,Functor f) => (String -> String) -> f String -> m (f String)
73+ applyFilter tr str = return $ fmap tr str
74+ protectCDATA :: String -> String
75+ protectCDATA = replaceAll "]]>" (const "]]&gt;")
70 -- Auxiliary: load a template from a datafile
76 -- Auxiliary: load a template from a datafile
71 loadTemplate path = do
77 loadTemplate path = do
72 file <- compilerUnsafeIO $ getDataFileName path
78 file <- compilerUnsafeIO $ getDataFileName path