Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tf hotfix #3399

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading