Describe the bug
Trailing backslashes break the intended inverse relationship between
NameParts.merge_last_name_first and parse_single_name_into_parts.
Two related cases are involved:
- Parsing a name whose final token ends in a backslash appends that backslash
twice because the end-of-input branch does not stop further handling of the
same character.
merge_last_name_first escapes the final section even though no comma follows
it, changing a terminal backslash unnecessarily.
The existing inverse-property test skips strict and non-strict examples with
odd trailing backslashes, concealing the round-trip failure.
Reproducing
Version: current main (08e370a)
Code:
from bibtexparser.middlewares.names import NameParts
from bibtexparser.middlewares.names import parse_single_name_into_parts
parts = NameParts(
first=["Christina", "A.", "L.\\"],
von=[],
last=["Thiele"],
jr=[],
)
merged = parts.merge_last_name_first
assert parse_single_name_into_parts(merged) == parts
The assertion fails on current main.
Expected behavior
Last-name-first serialization and reparsing should preserve the NameParts
value in both strict and non-strict modes, including terminal backslashes. Only
sections followed by a comma need delimiter-protecting escaping.
Workaround
Avoid terminal backslashes in name parts or normalize affected names manually.
Remaining Questions (Optional)
Describe the bug
Trailing backslashes break the intended inverse relationship between
NameParts.merge_last_name_firstandparse_single_name_into_parts.Two related cases are involved:
twice because the end-of-input branch does not stop further handling of the
same character.
merge_last_name_firstescapes the final section even though no comma followsit, changing a terminal backslash unnecessarily.
The existing inverse-property test skips strict and non-strict examples with
odd trailing backslashes, concealing the round-trip failure.
Reproducing
Version: current
main(08e370a)Code:
The assertion fails on current
main.Expected behavior
Last-name-first serialization and reparsing should preserve the
NamePartsvalue in both strict and non-strict modes, including terminal backslashes. Only
sections followed by a comma need delimiter-protecting escaping.
Workaround
Avoid terminal backslashes in name parts or normalize affected names manually.
Remaining Questions (Optional)