Skip to content

Commit

Permalink
feat: add support for arXiv entries and non-PDF URLs (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
k4rtik authored Aug 16, 2021
1 parent 56757a6 commit 061ef0e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions academic/import_bibtex.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,24 @@ def parse_bibtex_entry(
if "keywords" in entry:
page.fm["tags"] = clean_bibtex_tags(entry["keywords"], normalize)

if "url" in entry:
page.fm["url_pdf"] = clean_bibtex_str(entry["url"])

if "doi" in entry:
page.fm["doi"] = clean_bibtex_str(entry["doi"])

links = []
if all(f in entry for f in ["archiveprefix", "eprint"]) and entry["archiveprefix"].lower() == "arxiv":
links += [{"name": "arXiv", "url": "https://arxiv.org/abs/" + clean_bibtex_str(entry["eprint"])}]

if "url" in entry:
sane_url = clean_bibtex_str(entry["url"])

if sane_url[-4:].lower() == ".pdf":
page.fm["url_pdf"] = sane_url
else:
links += [{"name": "URL", "url": sane_url}]

if links:
page.fm["links"] = links

# Save Markdown file.
try:
log.info(f"Saving Markdown to '{markdown_path}'")
Expand Down

0 comments on commit 061ef0e

Please sign in to comment.