Skip to content

Commit 061ef0e

Browse files
authored
feat: add support for arXiv entries and non-PDF URLs (#97)
1 parent 56757a6 commit 061ef0e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

academic/import_bibtex.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,24 @@ def parse_bibtex_entry(
142142
if "keywords" in entry:
143143
page.fm["tags"] = clean_bibtex_tags(entry["keywords"], normalize)
144144

145-
if "url" in entry:
146-
page.fm["url_pdf"] = clean_bibtex_str(entry["url"])
147-
148145
if "doi" in entry:
149146
page.fm["doi"] = clean_bibtex_str(entry["doi"])
150147

148+
links = []
149+
if all(f in entry for f in ["archiveprefix", "eprint"]) and entry["archiveprefix"].lower() == "arxiv":
150+
links += [{"name": "arXiv", "url": "https://arxiv.org/abs/" + clean_bibtex_str(entry["eprint"])}]
151+
152+
if "url" in entry:
153+
sane_url = clean_bibtex_str(entry["url"])
154+
155+
if sane_url[-4:].lower() == ".pdf":
156+
page.fm["url_pdf"] = sane_url
157+
else:
158+
links += [{"name": "URL", "url": sane_url}]
159+
160+
if links:
161+
page.fm["links"] = links
162+
151163
# Save Markdown file.
152164
try:
153165
log.info(f"Saving Markdown to '{markdown_path}'")

0 commit comments

Comments
 (0)