diff options
author | Matthias C. M. Troffaes <matthias.troffaes@gmail.com> | 2015-01-09 15:07:20 +0000 |
---|---|---|
committer | Matthias C. M. Troffaes <matthias.troffaes@gmail.com> | 2015-01-09 15:07:20 +0000 |
commit | e7c077de2feb4be042301bab3d898894adcbb8ee (patch) | |
tree | 20d605669ca7dd3569d21bf086d3a16e4f624faf /src/Hakyll | |
parent | 23ab06de05a2da2b9c428d333d684690a580f3ba (diff) | |
download | hakyll-e7c077de2feb4be042301bab3d898894adcbb8ee.tar.gz |
add convenience function pandocBiblioCompiler
Diffstat (limited to 'src/Hakyll')
-rw-r--r-- | src/Hakyll/Web/Pandoc/Biblio.hs | 11 |
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) |