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

🐛 fix split_multiple_persons_names with single-char middlenames #476

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions bibtexparser/middlewares/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ def split_multiple_persons_names(names):
step = FIND_A
possible_end = pos - 1

# Looking for the letter a. NB., we can have multiple whitespace
# characters so we need to handle that here.
# Looking for the letter "a".
# NB, we can have multiple whitespace characters so we need to handle that here.
elif step == FIND_A:
if char in ("a", "A"):
step = FIND_N
Expand All @@ -612,13 +612,19 @@ def split_multiple_persons_names(names):
elif step == FIND_N:
if char in ("n", "N"):
step = FIND_D
elif char in whitespace:
step = FIND_A
possible_end = pos - 1
else:
step = START_WHITESPACE

# Looking for the letter d.
elif step == FIND_D:
if char in ("d", "D"):
step = END_WHITESPACE
elif char in whitespace:
step = FIND_A
possible_end = pos - 1
else:
step = START_WHITESPACE

Expand Down
2 changes: 2 additions & 0 deletions tests/middleware_tests/test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
("Harry Fellowes~and D. Drumpf", ["Harry Fellowes~and D. Drumpf"]),
("Harry Fellowes~and~D. Drumpf", ["Harry Fellowes~and~D. Drumpf"]),
("Harry Fellowes and~D. Drumpf", ["Harry Fellowes and~D. Drumpf"]),
("Doe, John A and Doe, Jane", ["Doe, John A", "Doe, Jane"]),
("Doe, John AN and Doe, Jane", ["Doe, John AN", "Doe, Jane"]),
(" ", []),
("\t\n \t", []),
("~", ["~"]),
Expand Down
Loading