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 From 2663c24807f838b59475e656feec7f35c85206cb Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 9 Jan 2015 15:25:12 +0000 Subject: add missing export --- src/Hakyll/Web/Pandoc/Biblio.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Hakyll/Web/Pandoc') diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs index bcc5d5d..51c7ede 100644 --- a/src/Hakyll/Web/Pandoc/Biblio.hs +++ b/src/Hakyll/Web/Pandoc/Biblio.hs @@ -18,6 +18,7 @@ module Hakyll.Web.Pandoc.Biblio , Biblio (..) , biblioCompiler , readPandocBiblio + , pandocBiblioCompiler ) where -- cgit v1.2.3 From 285b3c4af03d50564078661ab66848c71e78ed1b Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 9 Jan 2015 15:29:01 +0000 Subject: add horizontal rule before function --- src/Hakyll/Web/Pandoc/Biblio.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Hakyll/Web/Pandoc') diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs index 51c7ede..acb21d3 100644 --- a/src/Hakyll/Web/Pandoc/Biblio.hs +++ b/src/Hakyll/Web/Pandoc/Biblio.hs @@ -109,6 +109,7 @@ 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 -- cgit v1.2.3 From be151b94a4d6989632993f658bbfec67e59ddb78 Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 9 Jan 2015 15:29:20 +0000 Subject: fix typo --- src/Hakyll/Web/Pandoc/Biblio.hs | 2 +- 1 file changed, 1 insertion(+), 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 acb21d3..c85512f 100644 --- a/src/Hakyll/Web/Pandoc/Biblio.hs +++ b/src/Hakyll/Web/Pandoc/Biblio.hs @@ -4,7 +4,7 @@ -- 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', -- cgit v1.2.3