Skip to content

Commit

Permalink
coherent author formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbzm committed Oct 2, 2024
1 parent a0e3408 commit 5d1b140
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions data_extraction/build_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,22 @@ def load_methods_summaries(ranks, groupcolors):
width, height = img.size

author = authors[file.split(".")[0]]
#replace all but the last " and " with ", "

parts = author.split(' and ')
if not "," in author:
parts = author.split(' and ')
# Join all parts except the last one with ", " and then add the last part prefixed with " and "
author = ', '.join(parts[:-1]) + ' and ' + parts[-1]
formatted_authors = parts
else:
formatted_authors = []
for part in parts:
# Split by comma and reverse the order
last, first = [p.strip() for p in part.split(',', 1)]
formatted_authors.append(f"{first} {last}")

if len(formatted_authors) > 2:
author = ', '.join(formatted_authors[:-1]) + ' and ' + formatted_authors[-1]
else:
author = ' and '.join(formatted_authors)


summaries.append({
'name': file.split('.')[0],
Expand Down

0 comments on commit 5d1b140

Please sign in to comment.