Update:
I merged sorting and grouping logic this weekend, and I’ve integrated it into a processing AST.
The Internal model and AST
The grouping logic is added to the procHints
property on an intermediate ProcReference
class, which includes formatting methods. That property I currently only use for disambiguation …
ProcReference {
data: {
type: "book",
title: "The Title",
author: [ { name: "Doe, Jane" } ],
issued: "2023",
citekey: "doe2"
},
procHints: { groupIndex: 2, groupKey: "Doe, Jane:2023", groupLength: 2 }
}
… and then incorporate in the rendering AST, which is just the input templates with added procValue
property:
[
[ { contributors: "author", procValue: "Doe, Jane" } ],
{
date: "issued",
format: "year",
wrap: "parentheses",
procValue: "2023b"
},
[ { title: "title", procValue: "The Title" } ],
undefined,
undefined
]
FWIW, this processing model is conceptually similar to the design I used for the very first CSL implementation, in XSLT 1.0, but of course using native and close-to-native data structures (as in, input format very closely maps to and from internal data structures).
Code generation example
A little demo repo to demonstrate the code generation:
If you run the generate.sh
script, it will create the rust module files, and build that with the tiny main.rs
source file, which demonstrates the generated code correctly deserializes and serializes the Style
model, in this case translated to a Rust struct.
❯ time target/debug/csln-rs style.csl.yaml bibliography.yaml
The name of the style is: "APA"
The number of entries in the bibliography is: 5
________________________________________________________
Executed in 2.74 millis fish external
usr time 1.16 millis 406.00 micros 0.75 millis
sys time 1.62 millis 115.00 micros 1.51 millis
The Plan, milestones
Here’s how I imagine the milestones to build this out to a formal release. I’m already ahead of schedule on my own, so I’m optimistic about accomplishing the plan with help.
Aside: I’ve partly set the milestones up because there’s a possibility some comp sci students may work on pieces of this later this year and next.