typst / biblatex

A Rust crate for parsing and writing BibTeX and BibLaTeX files.
Apache License 2.0
129 stars 17 forks source link

Crossref inheritance and overloading #51

Open wrenger opened 7 months ago

wrenger commented 7 months ago

Hi, I'm a bit confused about the inheritance order of crossref. If both entries contain the same field with different values (like year), which one should be used?

Here is an example:

let bib = r#"
    @inproceedings{foo,
        author = {Max Müller},
        title = {Lorem Ipsum et Dolor},
        month = sep,
        year = 2005,
        crossref = {ref},
    }
    @proceedings{ref,
        month = jan,
        year = 2001,
        title = {Book Title},
        category = {baz},
    }
"#;
let parsed = Bibliography::parse(bib).unwrap();
println!("{parsed:#?}");

In this example, I would expect that the year from the referrer foo overwrites the year from the referee ref.

However, this is not the case:

Bibliography {
    entries: [
        Entry {
            key: "foo",
            entry_type: InProceedings,
            fields: {
                "author": [
                    Normal(
                        "Max Müller",
                    ) <43..54>,
                ],
                "booktitle": [
                    Normal(
                        "Book Title",
                    ) <252..262>,
                ],
                "crossref": [
                    Normal(
                        "ref",
                    ) <159..162>,
                ],
                "date": [
                    Normal(
                        "2001-01",
                    ) <18446744073709551615..18446744073709551615>,
                ],
                "title": [
                    Normal(
                        "Lorem Ipsum et Dolor",
                    ) <74..94>,
                ],
            },
        },
        Entry {
            key: "ref",
            entry_type: Proceedings,
            fields: {
                "category": [
                    Normal(
                        "baz",
                    ) <285..288>,
                ],
                "month": [
                    Normal(
                        "January",
                    ) <209..212>,
                ],
                "title": [
                    Normal(
                        "Book Title",
                    ) <252..262>,
                ],
                "year": [
                    Normal(
                        "2001",
                    ) <229..233>,
                ],
            },
        },
    ],
    keys: {
        "foo": 0,
        "ref": 1,
    },
}

PS: Also, the category is not inherited.

PS2: PS: Thank you for this crate. This is a good replacement for the very slow bibtexparser python package.