summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Pandoc/Biblio.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs
index c8f075d..bcc5d5d 100644
--- a/src/Hakyll/Web/Pandoc/Biblio.hs
+++ b/src/Hakyll/Web/Pandoc/Biblio.hs
@@ -7,6 +7,8 @@
-- refer to these files when you use 'pageReadPandocBiblio'. This function also
-- takes the reader options for completeness -- you can use
-- 'defaultHakyllReaderOptions' if you're unsure.
+-- 'pandocBiblioCompiler' is a convenience wrapper which works like 'pandocCompiler',
+-- but also takes paths to compiled bibliography and csl files.
{-# LANGUAGE Arrows #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -21,8 +23,9 @@ module Hakyll.Web.Pandoc.Biblio
--------------------------------------------------------------------------------
import Control.Applicative ((<$>))
-import Control.Monad (replicateM)
+import Control.Monad (replicateM, liftM)
import Data.Binary (Binary (..))
+import Data.Default (def)
import Data.Typeable (Typeable)
import qualified Text.CSL as CSL
import Text.CSL.Pandoc (processCites)
@@ -105,3 +108,9 @@ readPandocBiblio ropt csl biblio item = do
return $ fmap (const pandoc') item
+pandocBiblioCompiler :: String -> String -> Compiler (Item String)
+pandocBiblioCompiler cslFileName bibFileName = do
+ csl <- load $ fromFilePath cslFileName
+ bib <- load $ fromFilePath bibFileName
+ liftM writePandoc
+ (getResourceBody >>= readPandocBiblio def csl bib)