Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io
Other
305 stars 85 forks source link

How do modular styles work? #144

Open denismaier opened 4 years ago

denismaier commented 4 years ago

I've just tried to read about how modular legal styles work. I think I remember there was a blog entry somewhere, but I could not find the relevant information anymore.

dchawisher commented 2 years ago

I recently struggled to figure out the same thing. This blog post has a helpful explanation. In practical terms, I think it works like this:

  1. The parent style (jm-indigobook or whatever) has a cs:citation element, which actually renders the citation. It does this by calling one or more cs:macro elements.
  2. The parent style also has a cs:locale > style-options element with a jurisdiction-preference attribute. That attribute defines a 'flavor' of jurisdiction modules that the parent style will use.
  3. Finally, the parent style has a number of cs:macro elements that are meant to be supplied by the style modules. In the parent style, those macros are empty (or maybe they render an error message, e.g. 'install Juris-M').
  4. Style modules contain a number of cs:macro elements named identically to the ones in the parent style. In the modules, those elements have the content you want to appear in your citation.
  5. When citing a record that has a jurisdiction variable, if there is a corresponding style module of the appropriate 'flavor,' that module is loaded, meaning that macros defined in the module overwrite the corresponding modules in the parent style.
  6. The parent style then renders the citation. So the parent style is responsible for, e.g., saying 'we're citing a court case, so it goes <title>, <citation body>, <locator> (<court> <year>), and the style module is responsible for saying 'in Wyoming, <citation body> looks like this ... '