hakyll-4.16.6.0: A static website compiler library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hakyll.Web.Pandoc.Biblio

Description

Wraps pandocs bibiliography handling

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 readPandocBiblio. This function also takes the reader options for completeness -- you can use defaultHakyllReaderOptions if you're unsure. If you already read the source into a Pandoc type and need to add processing for the bibliography, you can use processPandocBiblio instead. pandocBiblioCompiler is a convenience wrapper which works like pandocCompiler, but also takes paths to compiled bibliography and csl files; pandocBibliosCompiler is similar but instead takes a glob pattern for bib files.

Synopsis

Documentation

newtype CSL Source #

Constructors

CSL 

Fields

Instances

Instances details
Show CSL Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Methods

showsPrec :: Int -> CSL -> ShowS #

show :: CSL -> String #

showList :: [CSL] -> ShowS #

Binary CSL Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Methods

put :: CSL -> Put #

get :: Get CSL #

putList :: [CSL] -> Put #

Writable CSL Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Methods

write :: FilePath -> Item CSL -> IO () Source #

newtype Biblio Source #

Constructors

Biblio 

Fields

Instances

Instances details
Show Biblio Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Binary Biblio Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Methods

put :: Biblio -> Put #

get :: Get Biblio #

putList :: [Biblio] -> Put #

Writable Biblio Source # 
Instance details

Defined in Hakyll.Web.Pandoc.Biblio

Methods

write :: FilePath -> Item Biblio -> IO () Source #

processPandocBiblio :: Item CSL -> Item Biblio -> Item Pandoc -> Compiler (Item Pandoc) Source #

Process a bibliography file with the given style.

This function supports pandoc's nocite functionality when there is a nocite metadata field present.

Example

Expand

In your main function, first compile the respective files:

main = hakyll $ do
  …
  match "style.csl" $ compile cslCompiler
  match "bib.bib"   $ compile biblioCompiler

Then, create a function like the following:

processBib :: Item Pandoc -> Compiler (Item Pandoc)
processBib pandoc = do
  csl <- load @CSL    "bib/style.csl"
  bib <- load @Biblio "bib/bibliography.bib"
  processPandocBiblio csl bib pandoc

Now, feed this function to your pandoc compiler:

myCompiler :: Compiler (Item String)
myCompiler = pandocItemCompilerWithTransformM myReader myWriter processBib

processPandocBiblios :: Item CSL -> [Item Biblio] -> Item Pandoc -> Compiler (Item Pandoc) Source #

Like processPandocBiblio, which see, but support multiple bibliography files.

pandocBiblioCompiler :: String -> String -> Compiler (Item String) Source #

Compiles a markdown file via Pandoc. Requires the .csl and .bib files to be known to the compiler via match statements.

pandocBibliosCompiler :: String -> String -> Compiler (Item String) Source #

Compiles a markdown file via Pandoc. Requires the .csl and .bib files to be known to the compiler via match statements.