zotero / citeproc-rs

CSL processor in Rust.
https://cormacrelf.github.io/citeproc-wasm-demo/
Other
73 stars 11 forks source link

Bring the CSL test suite to 100% #82

Closed cormacrelf closed 3 years ago

cormacrelf commented 3 years ago

There are some caveats, but citeproc-rs now passes the CSL test suite.

The caveats are:

  1. This is my fork of the test suite, so it had a few edits made mostly early on making it less prone to failure on a young CSL implementation. E.g. cleaning up JSON, removing variables that don't exist, etc. It also lacks recent changes in the official CSL test repo, but last I checked some of those changes are the same ones I made.
  2. There are 24 test ignored completely, mostly because they rely on citeproc-js-only APIs or test modes. The ignored tests are listed in crates/citeproc/tests/data/ignore.txt, with justifications for each, but these are all absolutely open to question.
  3. Similarly, 15 tests are "snapshotted", meaning citeproc-rs produces different output that is still considered acceptable. Again, the list is in crates/citeproc/tests/data/snapshot.txt with justifications, and again all are open to question. Probably the most iffy ones are position_IbidInText.txt and locator_TrickyEntryForPlurals.txt, but at least neither of them is actually documented in the specification, so there's that at least.

There are also 23 additional tests in crates/citeproc/tests/data/humans/. This one's not really a caveat, but they're all candidates for test suite inclusion, and if you're reading this then chances are that's interesting to you.

A couple of inextricable Rust API changes landed along the way, ie Processor::new(InitOptions { style, ..Default::default() }), but the wasm API is severable, untouched and for a separate PR.

Edit: oh, and another inextricable change, the parsing a style's metadata only. There's a new csl::StyleMeta with a parse method. You can use this to figure out whether a style is dependent, and what its e.g. default-locale is, to apply to the parent style as an override. Or just to get some info from the style, without erroring out if there are parse errors outside the <info> block. (At least I should add a test for that last use case.)