-- | 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 'pageReadPandocBiblio'. This function also-- takes a parser state for completeness -- you can use-- 'defaultHakyllParserState' if you're unsure.--{-# LANGUAGE Arrows, DeriveDataTypeable, GeneralizedNewtypeDeriving #-}moduleHakyll.Web.Pandoc.Biblio(CSL,cslCompiler,Biblio(..),biblioCompiler,pageReadPandocBiblio)whereimportControl.Applicative((<$>))importControl.Arrow(arr,returnA)importData.Typeable(Typeable)importData.Binary(Binary(..))importText.Pandoc(Pandoc,ParserState(..))importText.Pandoc.Biblio(processBiblio)importqualifiedText.CSLasCSLimportHakyll.Core.CompilerimportHakyll.Core.IdentifierimportHakyll.Core.ResourceimportHakyll.Core.WritableimportHakyll.Web.PageimportHakyll.Web.PandocnewtypeCSL=CSLFilePathderiving(Binary,Show,Typeable,Writable)cslCompiler::CompilerResourceCSLcslCompiler=arr(CSL.unResource)newtypeBiblio=Biblio[CSL.Reference]deriving(Show,Typeable)instanceBinaryBibliowhere-- Ugly.get=Biblio.read<$>getput(Bibliors)=put$showrsinstanceWritableBibliowherewrite__=return()biblioCompiler::CompilerResourceBibliobiblioCompiler=unsafeCompiler$fmapBiblio.CSL.readBiblioFile.unResourcepageReadPandocBiblio::ParserState->IdentifierCSL->IdentifierBiblio->Compiler(PageString)(PagePandoc)pageReadPandocBibliostatecslrefs=procpage->doCSLcsl'<-require_csl-<()Bibliorefs'<-require_refs-<()-- We need to know the citation keys, add then *before* actually parsing the-- actual page. If we don't do this, pandoc won't even consider them-- citations!letcits=mapCSL.refIdrefs'state'=state{stateCitations=stateCitationsstate++cits}pandocPage<-pageReadPandocWithA-<(state',page)letpandoc=pageBodypandocPagepandoc'<-unsafeCompilerprocessBiblio'-<(csl',refs',pandoc)returnA-<pandocPage{pageBody=pandoc'}whereprocessBiblio'(c,r,p)=processBibliocNothingrp