summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-10-04 17:14:20 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-10-04 17:14:20 +0200
commit111828d282ea2a0a7d4a161960c4bc576bc89984 (patch)
tree21f89c24ce1f01814ed6a6df0daf8f4e0e6158e8
parent371bc0347b21ff6693f9badeae4962433d42cc55 (diff)
downloadhakyll-111828d282ea2a0a7d4a161960c4bc576bc89984.tar.gz
Provide simple `renderActionWith` function
-rw-r--r--src/Text/Hakyll/Pandoc.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Text/Hakyll/Pandoc.hs b/src/Text/Hakyll/Pandoc.hs
index f3626d9..dcd7392 100644
--- a/src/Text/Hakyll/Pandoc.hs
+++ b/src/Text/Hakyll/Pandoc.hs
@@ -2,11 +2,12 @@
--
module Text.Hakyll.Pandoc
( renderAction
+ , renderActionWith
) where
import Data.Maybe (fromMaybe)
import qualified Data.Map as M
-import Control.Arrow (second)
+import Control.Arrow (second, (>>>), arr)
import Text.Pandoc
@@ -42,11 +43,16 @@ getRenderFunction fileType = do
--
renderAction :: HakyllAction [PageSection] Context
renderAction = createHakyllAction $ \sections -> do
- let triples = map unPageSection sections
- path = fromMaybe "unknown" $ lookup "path"
+ let path = fromMaybe "unknown" $ lookup "path"
$ map (\(x, y, _) -> (x, y))
- $ triples
+ $ map unPageSection sections
render' <- getRenderFunction $ getFileType path
- let pairs = map (\(k, v, r) -> second (if r then render' else id) (k, v))
- triples
- return $ Context $ M.fromList pairs
+ runHakyllAction $ arr (const sections) >>> renderActionWith render'
+
+-- | An action to render pages, offering just a little more flexibility
+--
+renderActionWith :: (String -> String) -> HakyllAction [PageSection] Context
+renderActionWith render' = createHakyllAction $ \sections -> return $
+ Context $ M.fromList $ map (renderTriple . unPageSection) sections
+ where
+ renderTriple (k, v, r) = second (if r then render' else id) (k, v)