how to use pandoc citations? (@bibitem)

190 views
Skip to first unread message

Christian Höner zu Siederdissen

unread,
May 28, 2011, 9:34:09 PM5/28/11
to hakyll
Hi,

I am considering hakyll for my website. One requirement would be easy
handling of bibtex items. Pandoc supports this using @bibitem and --
bibliography. Internally, as far as I can tell, processBiblio is used
to replace @bibitem with the corresponding key.

How easy would it be to have pandoc bibliography handling used in
hakyll? Or can one just use 'processBiblio'? It ends up in the IO
monad.

Gruss,
Christian

Jasper Van der Jeugt

unread,
May 29, 2011, 3:00:42 AM5/29/11
to hak...@googlegroups.com
Hello,

It is certainly possible but it is not very pretty. The following will
do as a page transformer:

biblio :: Compiler (Page Pandoc) (Page Pandoc)
biblio = unsafeCompiler $ \(Page md b) -> do
refs <- readBiblioFile "foo.bibtex"
Page md <$> processBiblio "foo.xml" refs b

A problem will be that you'll have to rebuild your site whenever you
change the foo.bibtex/foo.xml files. The latter I can't do anything
about, due to the API pandoc exposes. The former could be fixed but
this would require writing your own Binary and Writable instances for
[Reference], so it's possible, possibly outside the scope of this
mail.

The resulting biblio compiler is something you can easily hook up in
your Compiler pipeline, something I explained here [1]. You'll want to
replace the pageRenderPandoc function with something built from biblio
and the combinators in Hakyll.Web.Pandoc [2].

[1]: https://groups.google.com/d/topic/hakyll/UyLmJClgWgE/discussion
[2]: http://jaspervdj.be/hakyll/reference/Hakyll-Web-Pandoc.html

Hope this helps,
Cheers,
Jasper

Christian Höner zu Siederdissen

unread,
May 29, 2011, 6:18:57 AM5/29/11
to hakyll
Hi,

depends on your definition of pretty, I guess. It works quite well!
I'll test eveything out now. I'd suggest adding 'unsafeCompiler' to a
tutorial. I missed it when browsing through haddock and the source and
it is a very useful function.

Many thanks!
Christian
Reply all
Reply to author
Forward
0 new messages