I’ve only thought about this just now, so may be missing important details (like substitution and formatting), but …
What about ditching XML entirely, in favor of one of the new cross-language template languages?
Here’s liquid:
Hello {{ 'tobi' | upcase }}
Hello tobi has {{ 'tobi' | size }} letters!
Hello {{ '*tobi*' | textilize | upcase }}
Hello {{ 'now' | date: "%Y %h" }}
So the |
pipes the variable through one or more transformation functions, which can include arguments.
For CSL, the obvious filters, or filter groups:
- Names
- Dates
- Titles
Could have a default filter for each group, and then variants that encapsulate arguments (the logic in existing style macros) for ease of authoring.
A simple hypothetical style fragment:
{{ author.names | shorten-names-apa }} ({{ issued | date-year | date-suffix }}). {{ title }}.
And then combine the template strings in a larger YAML file?
citation:
mode: intext
et-al-min: 4
et-al-use-first: 1
disambiguate-add-year-suffix: true
disambiguate-add-names: true
disambiguate-add-givenname: true
givenname-disambiguation-rule: primary-name
collapse: year
after-collapse-delimiter: "; "
template: ({{ author.name }}, {{ date | fmt-year }})
EDIT: it occurred to me that the more complex logic in CSL now is actually described in the simple attributes. So in the above, the template can actually be pretty simple. I don’t know how substitution would work elegantly however ATM.
Any future development work would come down to describing the filters, much like we do now for rendering elements, and adding input/output examples to the test suite.
And in refactoring, can consider things like multilingual from the beginning.
Finally, this would be:
- easier for users to edit
- maybe possible to convert to from existing styles.
This assumes most of the logic can be contained in the filters, so the actual templates are pretty simple. Am not sure about that.
Am I crazy, or might this be a way to address all of the above issues?
If you think about it, all the collective knowledge of citation formatting is embedded in that style repo; maybe we can use that to facilitate a more radical break (and also do other cool things)?
Or maybe the basic idea of chained filter transformation could be implemented in the XML syntax; not sure. As I said, this is just a very tentative idea.