Skip to content

Commit

Permalink
🐛 fix split_multiple_persons_names with single-char middlenames (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Mar 19, 2024
1 parent 09f8bc1 commit cf0079d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bibtexparser/middlewares/names.py
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
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

0 comments on commit cf0079d

Please sign in to comment.