From 45fd85ddb138015d7fd918891f96e4e3f57a693d Mon Sep 17 00:00:00 2001
From: SwoopDoable <swoop-doable.0v@icloud.com>
Date: Mon, 12 Aug 2024 17:16:47 +0200
Subject: [PATCH] Correct author identification in presence of orcid

---
 scipost_django/journals/models/publication.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scipost_django/journals/models/publication.py b/scipost_django/journals/models/publication.py
index c837b2c58..6ee178057 100644
--- a/scipost_django/journals/models/publication.py
+++ b/scipost_django/journals/models/publication.py
@@ -614,10 +614,14 @@ class Publication(models.Model):
         
         tex_contents = self.proofs_repository.fetch_publication_tex()
         author_field = re.findall("%%%%%%%%%% TODO: AUTHORS(.*?)%%%%%%%%%% END TODO: AUTHORS", tex_contents, re.DOTALL)[0]
-        author_texts = author_field.strip().split("\n")
+        author_texts = author_field.strip().replace("\,", "").split("\n")
 
+        # Remove any trailing or leading "and"s.
         if len(author_texts) > 1 and " and" in author_texts[-2]:
             author_texts[-2] = author_texts[-2].replace(" and", ",").replace("\nand ", "\n")
+        
+        # Remove \orcidlink{...} commands.
+        author_texts = [re.sub(r"\\orcidlink\{.*?\}", "", author_text) for author_text in author_texts]
 
         author_list = []; affiliation_list = []
         for author_text in author_texts:            
-- 
GitLab