Open bdarcus opened 1 year ago
Maybe could do something like this?
title: title
rendering: [emph]
alternate:
- type: [article, chapter]
match: any # default
rendering: [quote]
@denismaier - WDYT of this "selector" macro system that Hayagriva uses? It's effectively a custom selection and filtering language.
https://github.com/typst/hayagriva/blob/5f77bfb6dd3ada3db57d308d134908ee7245f77d/docs/selectors.md
One of their main developers mentioned wanting to use it with CSL 1.0, though I'm unclear how that would work.
But it could be interesting here?
EDIT: or maybe not. Really the main advantage it offers is extensible fields and types. And I don't think the style would be very portable when exploiting those.
I'm uneasy with translating the 1.0 approach directly, so hoping to find a better way.
There's also a question of whether we need to make an already complicated model more complicated functionally, or if we can instead simplify by putting more logic into the parameter options.
For an idea of what I mean by the latter, you could imagine something like this in a style:
I'm experimenting with this idea on:
https://github.com/bdarcus/csln/blob/main/processor/examples/chicago-ad-experiment.yaml
Another approach, more general but fairly clean, is just to add a
conditions
field to the template component models.... but that also has limitations; I think it might yield more verbose styles in some cases?
But "presets" could help with that, so in the end the styles are typically much simpler and shorter.
See also the "selector" language from Hayagriva.
https://github.com/typst/hayagriva/blob/main/docs/selectors.md
... and this is conceptually how BibLaTeX does it (https://github.com/bdarcus/csln/issues/106#issuecomment-1628576786):
Finally, see liquid:
https://shopify.github.io/liquid/tags/control-flow/