Custom Citation Style - Spec
This is the specification of the feature at hand.
Problem
Currently, references are rendered at the note footer in APA format. For example,
- Dijkstra, E. W. (1959). A note on two problems in connexion with graphs. Numerische Mathematik. https://doi.org/10.1007/bf01386390
Although this might be OK for some users, every journal wants the references supplied in a specific format (longer/shorter, with/without titles, only first author / all authors, etc.). As a result, adding an option for specifying the citation style is immensely useful. The user should be able to somehow (addressed later in this post) select the style (APA, MLA, Nature, IEEE, etc.) in which the references are rendered, and the bibliography is automatically formatted based on the chosen citation style.
Solution
As in apps like Mendeley, the user selects a certain citation style from a large list, then all the references get automatically formatted according to the specified style. Under the hood, it utilizes the concept of Citation Style Language (CSL), which is an XML-based format to describe the formatting of citations, notes and bibliographies. CSL is the de facto standard for citation styling and it has a very detailed documentation. Every citation style has a CSL file which describes exactly how references written in this style should be formatted. For example, here is the CSL file of IEEE format, which is contained in a very large repository alongside other well-known citation styles.
Implementation
The implementation will consist of two major parts: selecting a Joplin-wide citation style and rendering the references using that style.
Selecting citation style
There are two approaches for enabling the user to select a citation style: either to choose from a large list of well-known styles or to specify a path of a .csl
file. I personally prefer the later method since it's more customizable and user-friendly, in addition to being easier to implement (by just registering a new field in the config screen). By default, there will be no path to a .csl
file. In that case, the default style that shall be used is APA.
Rendering the references in the specified style
For this feature to work, there should be a utility that does the following:
- Take two arguments:
.csl
file and a reference. - Parse the
.csl
file. - Generate an HTML markup representing the given reference in the specified format.
Such utility is already implemented and it's called a CSL Processor
. There are numerous implementations of CSL Processors in various programming languages and technologies. The one that's gonna be useful for this feature is Citeproc-js or its developer-friendly cousin simple-cite, which is just a simple wrapper around Citeproc. Although having a somewhat complex interface, I think Citeproc-js is more suitable as it has been live for about 12 years, and currently used by a lot of applications (like Zotero and Mendeley).
Suggestions
As usual, all suggestions and ideas are welcome
Am I missing something? Are there any ambiguous parts? How can this be improved?