Skip to content

Commit cf0079d

Browse files
authored
🐛 fix split_multiple_persons_names with single-char middlenames (#476)
1 parent 09f8bc1 commit cf0079d

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

bibtexparser/middlewares/names.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ def split_multiple_persons_names(names):
600600
step = FIND_A
601601
possible_end = pos - 1
602602

603-
# Looking for the letter a. NB., we can have multiple whitespace
604-
# characters so we need to handle that here.
603+
# Looking for the letter "a".
604+
# NB, we can have multiple whitespace characters so we need to handle that here.
605605
elif step == FIND_A:
606606
if char in ("a", "A"):
607607
step = FIND_N
@@ -612,13 +612,19 @@ def split_multiple_persons_names(names):
612612
elif step == FIND_N:
613613
if char in ("n", "N"):
614614
step = FIND_D
615+
elif char in whitespace:
616+
step = FIND_A
617+
possible_end = pos - 1
615618
else:
616619
step = START_WHITESPACE
617620

618621
# Looking for the letter d.
619622
elif step == FIND_D:
620623
if char in ("d", "D"):
621624
step = END_WHITESPACE
625+
elif char in whitespace:
626+
step = FIND_A
627+
possible_end = pos - 1
622628
else:
623629
step = START_WHITESPACE
624630

tests/middleware_tests/test_names.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
("Harry Fellowes~and D. Drumpf", ["Harry Fellowes~and D. Drumpf"]),
7676
("Harry Fellowes~and~D. Drumpf", ["Harry Fellowes~and~D. Drumpf"]),
7777
("Harry Fellowes and~D. Drumpf", ["Harry Fellowes and~D. Drumpf"]),
78+
("Doe, John A and Doe, Jane", ["Doe, John A", "Doe, Jane"]),
79+
("Doe, John AN and Doe, Jane", ["Doe, John AN", "Doe, Jane"]),
7880
(" ", []),
7981
("\t\n \t", []),
8082
("~", ["~"]),

0 commit comments

Comments
 (0)