Skip to content

✨ Support biber-style %-comments within entries - #633

Open
MiWeiss wants to merge 1 commit into
mainfrom
feat/372-biber-comments
Open

MiWeiss wants to merge 1 commit into
mainfrom
feat/372-biber-comments

Conversation

@MiWeiss

@MiWeiss MiWeiss commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Biber allows %-comments inside entries. We turned them into bogus keys or failed the entry:

parse_string("@article{k,\n  %note\n  author = {A},\n}")             # field key '%note\n  author'
parse_string("@article{k,\n  % note, see {x}\n  author = {A},\n}")   # ParsingFailedBlock

Fix: where a field key is expected, % to end of line is a comment. BibTeX forbids % in field keys, so no valid BibTeX changes meaning. Comments are kept in Field.comments (before a field) and Entry.trailing_comments (after the last field), both tuples, and written back. % in values and entry keys stays literal.

Notes:

  • year = 2020 % x without a comma before %: the comment stays part of the value (documented).
  • A comment line containing the closing brace comments it out too, as in biber.

Perf (cryptobib, 41 MB): parse +2.3%, write ±0. Output identical to main on cryptobib and the ACL anthology.

Tests: 2834 passed, 12 skipped. Pre-commit clean.

Closes #372

Where a field key is expected, `%` up to the end of the line is now parsed
as a comment (as in biber; BibTeX does not allow `%` in field keys).
Previously, such lines became bogus field keys, were merged into the next
field's key, or made the entry fail to parse.

Comments are kept: `Field.comments` holds those before a field,
`Entry.trailing_comments` those after the last field, and the writer
writes them back. Within values and entry keys, `%` stays literal.

Closes #372
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.

Support biber comments

1 participant