@@ -4,9 +4,11 @@
4-- In order to add a bibliography, you will need a bibliography file (e.g.
4-- In order to add a bibliography, you will need a bibliography file (e.g.
5-- @.bib@) and a CSL file (@.csl@). Both need to be compiled with their
5-- @.bib@) and a CSL file (@.csl@). Both need to be compiled with their
6-- respective compilers ('biblioCompiler' and 'cslCompiler'). Then, you can
6-- 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
8-- takes the reader options for completeness -- you can use
8-- takes the reader options for completeness -- you can use
9-- 'defaultHakyllReaderOptions' if you're unsure.
9-- '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.
10{-# LANGUAGE Arrows #-}
12{-# LANGUAGE Arrows #-}
11{-# LANGUAGE DeriveDataTypeable #-}
13{-# LANGUAGE DeriveDataTypeable #-}
12{-# LANGUAGE GeneralizedNewtypeDeriving #-}
14{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -16,13 +18,15 @@ module Hakyll.Web.Pandoc.Biblio
16 , Biblio (..)
18 , Biblio (..)
17 , biblioCompiler
19 , biblioCompiler
18 , readPandocBiblio
20 , readPandocBiblio
21+ , pandocBiblioCompiler
22--------------------------------------------------------------------------------
25--------------------------------------------------------------------------------
23import Control.Applicative ((<$>))
26import Control.Applicative ((<$>))
24−import Control.Monad (replicateM)
27+import Control.Monad (replicateM, liftM)
25import Data.Binary (Binary (..))
28import Data.Binary (Binary (..))
29+import Data.Default (def)
26import Data.Typeable (Typeable)
30import Data.Typeable (Typeable)
27import qualified Text.CSL as CSL
31import qualified Text.CSL as CSL
28import Text.CSL.Pandoc (processCites)
32import Text.CSL.Pandoc (processCites)
@@ -105,3 +109,10 @@ readPandocBiblio ropt csl biblio item = do
106 return $ fmap (const pandoc') item
110 return $ fmap (const pandoc') item
112+--------------------------------------------------------------------------------
113+pandocBiblioCompiler :: String -> String -> Compiler (Item String)
114+pandocBiblioCompiler cslFileName bibFileName = do
115+ csl <- load $ fromFilePath cslFileName
116+ bib <- load $ fromFilePath bibFileName
118+ (getResourceBody >>= readPandocBiblio def csl bib)