bdarcus / csln

Reimagining CSL
Mozilla Public License 2.0
13 stars 0 forks source link

Convert existing macros and styles #45

Open bdarcus opened 1 year ago

bdarcus commented 1 year ago

A very high-priority, must-have, feature. And the quality has to be very good.

I doubt I have the time or skill to do it myself, however. So a PR would be welcome.

Details

I'm unsure exactly where and how to integrate this.

For style parsing, see citationberg from the typst folks. They've scaled it back to just be a CSL 1.0 parser, so can use here (see Style::from_xml).

use citationberg::Style;
use std::fs;
let style =
    citationberg::Style::from_xml(
      &fs::read_to_string("tests/independent/ieee.csl").unwrap()
    ).unwrap();

if let Style::Independent(independent) = style {
    assert_eq!(independent.info.title.value, "IEEE");
    // Get started processing your style!
} else {
    panic!("IEEE is an independent style");
}

The tricky part is then converting that internal model to this.

My first thought was this will be difficult, because of the significant differences.

OTOH, since I've simplified the template part on this end and constrained the options for things like sorting and substitution, it may not be too hard; possibly even easy?

I think the difficult part is likely to be the conditional.

It may make sense to look to simplify that too alongside this; to provide shortcuts, in effect, for common patterns (see note below on bdarcus/csln#29).

Another option

While we're at it, if it could work reliably, this more forward-looking idea might kill two birds with one stone:

This second task is high complexity, very high reward, and would depend on bdarcus/csln#29.

See also project..