From ea0c9774539b27956ddb0351a420acc61e6b21ba Mon Sep 17 00:00:00 2001 From: Tom de Geus Date: Thu, 14 Mar 2024 09:43:52 +0100 Subject: [PATCH] bugfix `split_multiple_persons_names` --- bibtexparser/middlewares/names.py | 10 ++++++++-- tests/middleware_tests/test_names.py | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bibtexparser/middlewares/names.py b/bibtexparser/middlewares/names.py index d067222..415beea 100644 --- a/bibtexparser/middlewares/names.py +++ b/bibtexparser/middlewares/names.py @@ -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 @@ -612,6 +612,9 @@ 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 @@ -619,6 +622,9 @@ def split_multiple_persons_names(names): 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 diff --git a/tests/middleware_tests/test_names.py b/tests/middleware_tests/test_names.py index 5da4d81..fc99d50 100644 --- a/tests/middleware_tests/test_names.py +++ b/tests/middleware_tests/test_names.py @@ -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", []), ("~", ["~"]),