summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2015-06-23 11:06:08 +0200
committerJasper Van der Jeugt <jaspervdj@gmail.com>2015-06-23 11:06:08 +0200
commita43b4ee90fe581b2aedcff5e03b4e9689b6497ce (patch)
tree55278f1b9da310a853008882d70a36e2145a9d92 /src
parentd28fea840b241611970b0f26f510ed4af53c6a8b (diff)
parentbe151b94a4d6989632993f658bbfec67e59ddb78 (diff)
downloadhakyll-a43b4ee90fe581b2aedcff5e03b4e9689b6497ce.tar.gz
Merge pull request #327 from mcmtroffaes/patch-1
Add convenience function pandocBiblioCompiler.
Diffstat (limited to 'src')
-rw-r--r--src/Hakyll/Web/Pandoc/Biblio.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs
index a4df630..53e3419 100644
--- a/src/Hakyll/Web/Pandoc/Biblio.hs
+++ b/src/Hakyll/Web/Pandoc/Biblio.hs
@@ -4,9 +4,11 @@
-- In order to add a bibliography, you will need a bibliography file (e.g.
-- @.bib@) and a CSL file (@.csl@). Both need to be compiled with their
-- respective compilers ('biblioCompiler' and 'cslCompiler'). Then, you can
--- refer to these files when you use 'pageReadPandocBiblio'. This function also
+-- refer to these files when you use 'readPandocBiblio'. 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 #-}
@@ -16,13 +18,15 @@ module Hakyll.Web.Pandoc.Biblio
, Biblio (..)
, biblioCompiler
, readPandocBiblio
+ , pandocBiblioCompiler
) where
--------------------------------------------------------------------------------
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 +109,10 @@ 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)