On Mon, 5 Oct 2020, Hans Hagen wrote:
John MacFarlane, the developper of Pandoc, has released a new Citeproc that generates citations and bibliographies using CSL style files (CSL= citation style language). While it is written in Haskell and while it's primarily intended for use with Pandoc, it can also be used in other contexts. Provided with a JSON encoded list of references via stdin, it can produce formatted output.
The man page of the new citeproc executable, for those who are interested:
https://github.com/jgm/citeproc/blob/master/man/citeproc.1.md
I know that ConTeXt has its own infrastructure to format bibliographies and citations, but, given the enormous amount of available styles in CSL, I nevertheless think that this could be a worthwile addition. What would be necessary to make such a toll usable with ConTeXt? How complicated would that be?
In principle, this should be trivial. Define a new command, say \citeproc[ref], which saves the values of `ref` to a lua table, and at the end of the run, write that lua table to an aux .json file, call citeproc and store output to a new file, and on the second run read from that file. This is essentially how the old bibtex used to work.
Note that this scheme has a few drawbacks: First, it needs to call an external executable, which can be slower than directly reading the bib file via lua. Second, it creates a bunch of extra auxiliary files, which is always annoying. But I do agree that it will provide us with the ability to use the large number CSL styles.
Of course, a better option will be write a CSL processor in Lua, but that is a lot of tedious (but relatively simple) task. I wonder if there is already a CSL processor written in Lua.
On 10/5/2020 2:47 AM, Aditya Mahajan wrote: the bib module can read lua files (or whatever)
i have no clue what csl is but I assume it's just some key / value thing as the bib module itself should to the logic
It is similar to a bst file and specifies how the bibliography should be formatted. The specification is written as an XML file, for example, this is the specification for APA style: https://www.zotero.org/styles/apa-5th-edition The detailed schema is here: https://github.com/citation-style-language/schema/tree/v1.0.1 There are a large number of such specifications available. For example: https://www.zotero.org/styles So, the user can easily search for a style that matches his/her needs and simply use it. The task of finding a reference from a reference database is left to a CSL processor and there a few of them available: https://citationstyles.org/developers/ In principle, it should be relatively straight forward (but tedious) to write a processor in Lua. But I am not volunteering for that :-) Aditya