bdarcus / csln

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

refactor: add csln-types crate #57

Closed bdarcus closed 1 year ago

bdarcus commented 1 year ago

An experiment ATM, that I'm merging for now. But it's not hooked up, and it needs work.

Adapt a few ideas, and some code, from Hayagriva, and separate out basic data types and formatting code from bibliography and processor.

I think ideally I want all the basic formatting of these datatypes to be here too, so the models become clean, and also easier to contribute to for non-programmers or rust devs, and it's all more modular.

For titles, adapted this from the ts model, which in turn is adapted from the CSL 1.1 branch xml schema.

export interface TitleStructured {
  full?: TitleString;
  main: TitleString;
  sub: TitleString[];
}

Still unsure on traits vs straight functions, etc. Masto response back-and-forth is very useful.

https://fosstodon.org/@digikata/110515566415939721

Here's one of the suggested examples to examine:

https://github.com/obsidiandynamics/stanza/blob/master/src/renderer.rs

And the markdown renderer:

https://github.com/obsidiandynamics/stanza/blob/master/src/renderer/markdown.rs

https://docs.rs/tabled/latest/tabled/

May want to consider this on sorting:

https://stackoverflow.com/questions/60916194/how-to-sort-a-vector-in-descending-order-in-rust/60916195#60916195