Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,11 +109,13 @@ def check_for_fragment(url):
|
|
| 109 |
return '#:~:text=' in url
|
| 110 |
|
| 111 |
def parse_citation_text(citation_text):
|
| 112 |
-
# Match "Author (Year)"
|
| 113 |
-
match = re.match(r'(\
|
| 114 |
if match:
|
| 115 |
-
|
| 116 |
-
author =
|
|
|
|
|
|
|
| 117 |
return author, year
|
| 118 |
return None, None
|
| 119 |
|
|
@@ -173,7 +175,7 @@ def live_clock():
|
|
| 173 |
const date = `${parts[4].value}-${parts[2].value}-${parts[0].value}`;
|
| 174 |
const time = `${parts[6].value}:${parts[8].value}:${parts[10].value}`;
|
| 175 |
const datetimeElement = document.getElementById('live_datetime');
|
| 176 |
-
if datetimeElement) {
|
| 177 |
datetimeElement.innerText = `${date} ${time}`;
|
| 178 |
}
|
| 179 |
}
|
|
|
|
| 109 |
return '#:~:text=' in url
|
| 110 |
|
| 111 |
def parse_citation_text(citation_text):
|
| 112 |
+
# Match both "Author (Year)" and "(Author, Year)"
|
| 113 |
+
match = re.match(r'^(?:(\w[\w\s.,&et al]+)\s*\((\d{4})\)|\((\w[\w\s.,&et al]+),\s*(\d{4})\))$', citation_text.strip())
|
| 114 |
if match:
|
| 115 |
+
# If "Author (Year)" matches, take groups 1 and 2; if "(Author, Year)" matches, take groups 3 and 4
|
| 116 |
+
author = match.group(1) or match.group(3)
|
| 117 |
+
year = match.group(2) or match.group(4)
|
| 118 |
+
author = author.strip()
|
| 119 |
return author, year
|
| 120 |
return None, None
|
| 121 |
|
|
|
|
| 175 |
const date = `${parts[4].value}-${parts[2].value}-${parts[0].value}`;
|
| 176 |
const time = `${parts[6].value}:${parts[8].value}:${parts[10].value}`;
|
| 177 |
const datetimeElement = document.getElementById('live_datetime');
|
| 178 |
+
if (datetimeElement) {
|
| 179 |
datetimeElement.innerText = `${date} ${time}`;
|
| 180 |
}
|
| 181 |
}
|