@@ -4,9 +4,11 @@
44-- In order to add a bibliography, you will need a bibliography file (e.g.
55-- @.bib@) and a CSL file (@.csl@). Both need to be compiled with their
66-- respective compilers ('biblioCompiler' and 'cslCompiler'). Then, you can
7−-- refer to these files when you use 'pageReadPandocBiblio'. This function also
7+-- refer to these files when you use 'readPandocBiblio'. This function also
88-- takes the reader options for completeness -- you can use
99-- 'defaultHakyllReaderOptions' if you're unsure.
10+-- 'pandocBiblioCompiler' is a convenience wrapper which works like 'pandocCompiler',
11+-- but also takes paths to compiled bibliography and csl files.
1012{-# LANGUAGE Arrows #-}
1113{-# LANGUAGE DeriveDataTypeable #-}
1214{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -16,13 +18,15 @@ module Hakyll.Web.Pandoc.Biblio
1618 , Biblio (..)
1719 , biblioCompiler
1820 , readPandocBiblio
21+ , pandocBiblioCompiler
1922 ) where
2023
2124
2225--------------------------------------------------------------------------------
2326import Control.Applicative ((<$>))
24−import Control.Monad (replicateM)
27+import Control.Monad (replicateM, liftM)
2528import Data.Binary (Binary (..))
29+import Data.Default (def)
2630import Data.Typeable (Typeable)
2731import qualified Text.CSL as CSL
2832import Text.CSL.Pandoc (processCites)
@@ -105,3 +109,10 @@ readPandocBiblio ropt csl biblio item = do
105109
106110 return $ fmap (const pandoc') item
107111
112+--------------------------------------------------------------------------------
113+pandocBiblioCompiler :: String -> String -> Compiler (Item String)
114+pandocBiblioCompiler cslFileName bibFileName = do
115+ csl <- load $ fromFilePath cslFileName
116+ bib <- load $ fromFilePath bibFileName
117+ liftM writePandoc
118+ (getResourceBody >>= readPandocBiblio def csl bib)