diff --git a/patacrep/authors.py b/patacrep/authors.py index 83a072e3..6ea3098b 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -39,14 +39,15 @@ def compile_authwords(authwords): def split_author_names(string): r"""Split author between first and last name. - The last space separates first and last name. LaTeX commands are ignored. + The last space separates first and last name. + LaTeX commands are ignored, escaped spaces are converted to ~. >>> split_author_names("Edgar Allan Poe") ('Poe', 'Edgar Allan') >>> split_author_names("Edgar Allan \emph {Poe}") ('{Poe}', 'Edgar Allan \\emph') >>> split_author_names(r"The Rolling\ Stones") - ('Stones', 'The Rolling\\') + ('Rolling~Stones', 'The') >>> split_author_names("The {Rolling Stones}") ('Stones}', 'The {Rolling') >>> split_author_names("The Rolling Stones") @@ -54,7 +55,8 @@ def split_author_names(string): >>> split_author_names(" John Doe ") ('Doe', 'John') """ - chunks = string.strip().split(" ") + chunks = string.strip().replace("\\ ", "~") + chunks = chunks.split(" ") return (chunks[-1].strip(), " ".join(chunks[:-1]).strip()) diff --git a/test/test_authors.py b/test/test_authors.py index f9dfc053..b93ffa31 100644 --- a/test/test_authors.py +++ b/test/test_authors.py @@ -17,7 +17,7 @@ SPLIT_AUTHORS_DATA = [ ("The mamas and the papas", ("mamas and the papas", "The")), # Unbreakable spaces (r"\LaTeX command", ("command", r"\LaTeX")), # LaTeX commands are ignored (r"\emph{Some braces}", ("braces}", r"\emph{Some")), # LaTeX commands are ignored - (r"The Rolling\ Stones", ("Stones", 'The Rolling\\')), # LaTeX commands are ignored + (r"The Rolling\ Stones", ("Rolling~Stones", 'The')), # LaTeX commands are ignored ] PROCESS_AUTHORS_DATA = [