bdarcus / csln

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

Implement full document processing #49

Open bdarcus opened 1 year ago

bdarcus commented 1 year ago

My first step on rendering was a basic bibliography.

Next step is adding citations, and full document processing.

To do that, need to resolve some questions in the context of real style examples.

Do we need the 1.0 notion of a style type?

If yes, the default should be in-text, since that's what I use :-)

And should it be a global option, or only on citation?

What about other defaults?

There's a wide range of them in the style model we could set. Which ones should we, and what should the values be?

Again, I'll likely privilege my own preferences, so long as it doesn't cause problems in other contexts.

Which document format to start with?

I'd like it to be djot, but that depends on progress there.

Otherwise, maybe pandoc?

denismaier commented 1 year ago

Do we need the 1.0 notion of a style type?

If yes, the default should be in-text, since that's what I use :-)

And should it be a global option, or only on citation?

I think it'd make sense to perhaps follow the biblatex approach. Define a couple of citation commands and make one the default (as in \autocite).

denismaier commented 1 year ago

Which document format to start with? I'd like it to be djot, but that depends on progress there. Otherwise, maybe pandoc?

Pandoc. Because IIUC djot itself will translate a djot document to the pandoc AST. Problem with this approach is that you'll be limited by pandoc's types for citations.

bdarcus commented 1 year ago

There's a rust djot parser.

bdarcus commented 1 year ago

I think it'd make sense to perhaps follow the biblatex approach. Define a couple of citation commands and make one the default (as in \autocite).

To come back to this ....

There's two things here:

  1. what a citation should look like in general (author-date, note, numeric)
  2. locally-modified citations

The question was about 1.

For 2, here's how I currently model this:

https://github.com/bdarcus/csln/blob/f0cff31da320b687801e558761546881fc8cea0a/citation/src/lib.rs#L20-L26

It's basically the auto-cite/CSL idea, but with two variants.

But authors, and their substitutions, are core to this model.

On 1, I'm leaning towards including it, mostly so I can use it to set reasonable defaults for each one.

For example, author-date styles need to be sorted and grouped by author, year. If I add this, I can set that as default for that type only, so style authors don't have to (in the revisions I just merged, they would have to).

pub enum Class {
    /// Author-date citation and bibliography.
    AuthorDate,
    /// Footnote or endnote citation and (optionally) bibliography.
    Note,
    /// Bibliography entries are numbered, and the number is used for the citation.
    Numeric,
    /// Citations are printed as if they were bibliography entries.
    Entry,
}

I've opened a draft branch to implement this.

EDIT: went in a somewhat different direction.

denismaier commented 1 year ago

One thing to think about: the current citation modes are a bit orthogonal. Author- year might happen in a note (actually quite common in certain disciplines, e.g. archeology). On the other hand, author title citations might appear in text (e.g. MLA). So, I think default position and rendering should be independent from each other

bdarcus commented 1 year ago

I'm contemplating a bit more what goes together, and what should remain separate, in #87.

I hadn't actually gotten to considering citation position yet, but does what you suggest mean something like this would be appropriate?

citationPosition: footnote
processing: author-date # in #87, processing would cover sorting, grouping and disambiguation

BTW, that processing field:

Internally, the config method attached to it converts the "preset" values into a "custom" definition.

denismaier commented 1 year ago

Yes, I think that would be more appropriate. Would perhaps be better to call it defaultCitationPosition, or perhaps something like something like defaultCitationTemplate.

bdarcus commented 1 year ago

Would perhaps be better to call it defaultCitationPosition, or perhaps something like something like defaultCitationTemplate.

You're thinking so a user could mix-and-match in a document?

If yes, I'd imagine the processing would get a fair bit more complicated? Or maybe not?

But certainly best to avoid unstated/acknowledged assumptions or restrictions.

Also, isn't template and position orthogonal?

denismaier commented 1 year ago

Well, I just thinking about this in terms of how biblatex does it: define a bunch of citation commands, and set one as the default.

options: 
  processing: author-date # this sets sorting and grouping for author-date
  defaultCitationTemplate: parens # but this may also be the a task for the calling program.
...
citation:
  templates:
    - plain
      - contributor: author
        form: short
    - parens
      - contributor: author
        form: short
    - narrative
      - contributor: author
        form: short
bdarcus commented 1 year ago

I see.

Right now, I just have two, very general, commands which have the same idea:

But they're more general than in the tex world; "integral" just means whether the author is the subject of the statement.

Doe [1] says ....
Doe (2019) says ....
etc
bdarcus commented 1 year ago

I'm toying now with extending some of the design tweaks, so one could do something like this:

title: ABC journal
processing: author-date # preset processing
dates: long # preset dates
contributors: long # preset contributors
titles: apa # preset titles
citation:
  template:
    - contributor: author