Skip to content

Commit

Permalink
T&F: BibTeX hotfix (#3399)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam3smith authored Dec 3, 2024
1 parent f7f06c2 commit a2bd2f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Taylor and Francis+NEJM.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-07-02 20:00:15"
"lastUpdated": "2024-12-03 15:37:21"
}

/*
Expand Down Expand Up @@ -107,10 +107,18 @@ async function scrape(doc, url = doc.location.href) {

let bibtexText = await requestText(postUrl, { method: 'POST', body: postBody + doi + bibtexFormat });
let risText = await requestText(postUrl, { method: 'POST', body: postBody + doi + risFormat });

// Z.debug(bibtexText)
// Y1 is online publication date
if (/^DA\s+-\s+/m.test(risText)) {
risText = risText.replace(/^Y1(\s+-.*)/gm, '');
}
// Fix broken BibTeX as in https://github.com/zotero/translators/issues/3398
if (/@article\{[^,]+\}/.test(bibtexText)) {
Z.debug("Fixing BibTeX");
bibtexText = bibtexText.replace(/(@article\{[^,]+)\}/, '$1');
// Z.debug(bibtexText);
}

var item;
var risItem;
Expand Down Expand Up @@ -142,7 +150,6 @@ async function scrape(doc, url = doc.location.href) {
}

item.bookTitle = item.publicationTitle;

if (!item.title) item.title = "<no title>"; // RIS title can be even worse, it actually says "null"
if (risItem.date) item.date = risItem.date; // More complete
if (item.date && /^\d{4}$/.test(item.date)) {
Expand Down

0 comments on commit a2bd2f2

Please sign in to comment.