Skip to content

fix(bib): handle @comment@entry-type per BibTeX spec#15

Open
wali-reheman wants to merge 1 commit into
aclements:masterfrom
wali-reheman:fix/comment-delimiter
Open

fix(bib): handle @comment@entry-type per BibTeX spec#15
wali-reheman wants to merge 1 commit into
aclements:masterfrom
wali-reheman:fix/comment-delimiter

Conversation

@wali-reheman
Copy link
Copy Markdown

@wali-reheman wali-reheman commented May 6, 2026

Summary

Per the BibTeX specification, @comment must be followed by a delimiter (whitespace, {, or ,) to be recognized as a comment command. Otherwise, the text after @ is treated as an entry type.

For example, @comment@book{key, title = {T}} is parsed as entry type book (key=key), not as a comment. This matches BibTeX behaviour where @comment@book is treated as an entry of type book.

The parser previously consumed @comment@book as a single identifier token (because ID_RE includes @) and treated it as entry type comment@book, which is incorrect.

Fix

In _scan_command_or_entry, after scanning the identifier token, check if it starts with comment@. If so, this is the @comment@... pattern — rewind to the second @ and reparse as a fresh entry. A __in_comment_rewind flag prevents the @string macro command from being treated as a regular entry during the rewind.

Test cases added

  • @comment@book{test, title = {Test}} → entry type book
  • @comment@string{foo, title = {Bar}} → entry type string
  • @comment {text} followed by @misc{x, title = {X}} → entry x (comment ignored)
  • Normal @string{foo = {Bar}} still works as a macro command

References

Per the BibTeX specification, @comment must be followed by a delimiter
(whitespace, {, or ,) to be recognized as a comment command.
Otherwise, the text after @ is treated as an entry type.

For example, '@comment@book{key, title = {T}}' is parsed as entry type
'book' (key='key'), not as a comment. This matches BibTeX behaviour
where '@comment@book' is treated as an entry of type 'book'.

The parser previously consumed '@comment@book' as a single identifier
token and treated it as entry type 'comment@book', which is incorrect.

Fixes aclements#13.
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.

@comment should be followed with delimiter

1 participant