Skip to content

Commit a8527ff

Browse files
authored
✨ allow customization to handle capital AND in author list (#9)
* Change as proposed by #282 * Unit tests
1 parent f84e318 commit a8527ff

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

bibtexparser/customization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ def author(record):
345345
"""
346346
if "author" in record:
347347
if record["author"]:
348-
record["author"] = getnames([i.strip() for i in record["author"].replace('\n', ' ').split(" and ")])
348+
record["author"] = getnames([i.strip() for i in re.split(r"\ and\ ", record["author"].replace('\n', ' '),
349+
flags=re.IGNORECASE)])
349350
else:
350351
del record["author"]
351352
return record
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@BOOK{Bird1987,
2+
title = {Dynamics of Polymeric Liquid},
3+
publisher = {Wiley Edition},
4+
year = {1987},
5+
author = {Bird, R.B. and Armstrong, R.C. AND Hassager, O.},
6+
volume = {1},
7+
edition = {2},
8+
}

bibtexparser/tests/test_bparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def test_book(self):
398398
self.assertEqual(res, expected)
399399

400400
def test_book_cust_unicode(self):
401-
with open('bibtexparser/tests/data/book.bib', 'r') as bibfile:
401+
with open('bibtexparser/tests/data/book_capital_AND.bib', 'r') as bibfile:
402402
bib = BibTexParser(bibfile.read(), customization=customizations_unicode)
403403
res = bib.get_entry_list()
404404
expected = [{'ENTRYTYPE': 'book',

0 commit comments

Comments
 (0)