Skip to content

fix: format BibTeX names with Jr parts and braced "and" - #2157

Open
jayhemnani9910 wants to merge 1 commit into
HKUDS:devfrom
jayhemnani9910:bibtex-author-names
Open

jayhemnani9910 wants to merge 1 commit into
HKUDS:devfrom
jayhemnani9910:bibtex-author-names

Conversation

@jayhemnani9910

Copy link
Copy Markdown

Description

_format_authors removes braces first and then splits on " and " and the first comma. In BibTeX, braces protect a name, and a name can have three parts (Last, Jr, First). So:

author = {King, Jr., Martin Luther and {Food and Agriculture Organization}}

Before: **Authors:** Jr., Martin Luther King, Food, Agriculture Organization
After: **Authors:** Martin Luther King Jr., Food and Agriculture Organization

Field values now keep their braces when read; names and name parts are split only outside braces, and the braces are removed when a value is displayed. Corporate authors in double braces are what Zotero writes for institutions, so names like this come up in exported libraries.

A regression test is added to tests/utils/test_bibtex_converter.py; it fails on dev and passes with this change.

Related Issues

  • None

Module(s) Affected

  • utils
  • tests

Checklist

  • This PR targets dev (not main — see the base-branch selector above).
  • I have read and followed the contribution guidelines.
  • My code follows the project's coding standards.
  • I have run pre-commit run --all-files and fixed any issues. (Ran ruff check and ruff format --check on the changed files, and pytest tests/utils: 143 passed.)

Authors were split on every " and " after braces were removed, so a
braced corporate name such as {Food and Agriculture Organization} became
two people, and "King, Jr., Martin Luther" came out as "Jr., Martin Luther
King". Split names and name parts only outside braces, and order the
three-part "Last, Jr, First" form as "First Last Jr".

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant