From e7c077de2feb4be042301bab3d898894adcbb8ee Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 9 Jan 2015 15:07:20 +0000 Subject: add convenience function pandocBiblioCompiler --- src/Hakyll/Web/Pandoc/Biblio.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/Hakyll/Web/Pandoc') 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) -- cgit v1.2.3