Skip to content

Commit a56694a

Browse files
authored
fix: fix no journal name in Semanticscholar and underscore in DOIs (#69)
1 parent 19c6863 commit a56694a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

wenxian/feeder/semanticscholar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _from_identifier(self, identifier: str) -> Reference | None:
3030
authors.append(Author(first=first, last=last))
3131
# journal may be null, e.g.,
3232
# https://api.semanticscholar.org/graph/v1/paper/10.1103/PhysRevB.109.174106?fields=title,year,abstract,authors.name,journal,externalIds
33-
if res["journal"] is not None:
33+
if res["journal"] is not None and "name" in res["journal"]:
3434
journal = res["journal"]["name"]
3535
# the journal might be HTML escaped, e.g., Journal of Materials Science & Technology
3636
# https://api.semanticscholar.org/graph/v1/paper/10.1016/j.jmst.2023.09.059?fields=title,year,abstract,authors.name,journal,externalIds

wenxian/reference.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ def bibtex(self) -> str:
207207
# prevent {} in author that is used to split first and last name
208208
# be escaped
209209
valuestr = valuestr.replace(r"{\{}", r"{").replace(r"{\}}", r"}")
210+
if key == "doi":
211+
# for DOI, underscore should not be escaped
212+
# https://tex.stackexchange.com/questions/550123/underscore-in-doi-in-bibtex-file
213+
valuestr = valuestr.replace(r"{\_}", r"_")
210214
if key == "title":
211215
valuestr = f"{{{{{valuestr}}}}}"
212216
else:

0 commit comments

Comments
 (0)