|
@ -39,14 +39,15 @@ def compile_authwords(authwords): |
|
|
def split_author_names(string): |
|
|
def split_author_names(string): |
|
|
r"""Split author between first and last name. |
|
|
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") |
|
|
>>> split_author_names("Edgar Allan Poe") |
|
|
('Poe', 'Edgar Allan') |
|
|
('Poe', 'Edgar Allan') |
|
|
>>> split_author_names("Edgar Allan \emph {Poe}") |
|
|
>>> split_author_names("Edgar Allan \emph {Poe}") |
|
|
('{Poe}', 'Edgar Allan \\emph') |
|
|
('{Poe}', 'Edgar Allan \\emph') |
|
|
>>> split_author_names(r"The Rolling\ Stones") |
|
|
>>> split_author_names(r"The Rolling\ Stones") |
|
|
('Stones', 'The Rolling\\') |
|
|
('Rolling~Stones', 'The') |
|
|
>>> split_author_names("The {Rolling Stones}") |
|
|
>>> split_author_names("The {Rolling Stones}") |
|
|
('Stones}', 'The {Rolling') |
|
|
('Stones}', 'The {Rolling') |
|
|
>>> split_author_names("The Rolling Stones") |
|
|
>>> split_author_names("The Rolling Stones") |
|
@ -54,7 +55,8 @@ def split_author_names(string): |
|
|
>>> split_author_names(" John Doe ") |
|
|
>>> split_author_names(" John Doe ") |
|
|
('Doe', 'John') |
|
|
('Doe', 'John') |
|
|
""" |
|
|
""" |
|
|
chunks = string.strip().split(" ") |
|
|
chunks = string.strip().replace("\\ ", "~") |
|
|
|
|
|
chunks = chunks.split(" ") |
|
|
return (chunks[-1].strip(), " ".join(chunks[:-1]).strip()) |
|
|
return (chunks[-1].strip(), " ".join(chunks[:-1]).strip()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|