Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crossref inheritance and overloading #51

Open
wrenger opened this issue Mar 5, 2024 · 0 comments
Open

Crossref inheritance and overloading #51

wrenger opened this issue Mar 5, 2024 · 0 comments

Comments

@wrenger
Copy link
Sponsor

wrenger commented Mar 5, 2024

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.

@wrenger wrenger changed the title Crossref inheritance order Crossref inheritance and overloading Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant