shyamd/mkdocs-bibtex

Citation style with CSL

Closed this issue · 6 comments

Great plugin here!

Is it possible to change the citation style, for example, by specifying the CSL style file in the .yml? Would be a good feature to have!

Thank you!
Jobin

Hi Jobindj,

This uses pybtex to all the bibtex heavy lifting. Unfortunately, that doesn't support using CSL style files to control the output. You're welcome to submit a patch that enables this directly to pybtex or to this repo.

Thank you, @shyamd

@jobindj : I am also looking for ways to use CSL styles for citations. I found a workaround: it is possible to use pandoc to add citations, before running mkdocs.

Suppose you have a file with citations ([@AuthorYear] elements) in file docs/publications-EDITME.md, and bibliography in refs.bib. The following command will create a new file docs/publications.md with fully-formatted citations according to CSL file:

pandoc docs/publications-EDITME.md --bibliography refs.bib -o docs/publications.md -t markdown-citations --csl csl/chicago-syllabus.csl

More background on StackOverflow here, here, and here.

I also found that citeproc-py can handle both CSL and Bibtex bibliographies, I'll see if I can make it to work instead of pybitex.

Actually, I realized that it is possible to call pandoc from inside mkdocs-bibtex plugin, instead of running it separately from the command line. Pandoc might be better option than citeproc-py: citeproc-py appears to be not very robust to "slightly-broken" CSL files, while pandoc handles those CSL files without problem.

There are Python wrappers for pandoc: pypandoc and pyandoc. Both wrappers require pandoc and pandoc-citeproc to be installed on the system - an extra dependency. Citeproc-py, on the other hand, is pure Python.

Thanks for sharing, @alexvoronov! I will give this a try 👍

I'm more than happy to accept a PR to switch to pypandoc. pyandoc looks like it might not be maintained anymore