Skip to content

Commit

Permalink
NBIB: Ensure missing Extra does not break import (zotero#3046)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam3smith authored Jun 15, 2023
1 parent 1e4968c commit 70efd04
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions MEDLINEnbib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 1,
"lastUpdated": "2022-10-20 02:34:57"
"lastUpdated": "2023-06-09 02:21:30"
}

/*
Expand Down Expand Up @@ -80,6 +80,7 @@ var inputTypeMap = {
Books: "book", // ERIC
"Book Chapter": "bookSection", // can't find in specs, but is used.
"Case Reports": "journalArticle", // Case reports in medicine are basically always in journals
"Case Report": "journalArticle",
"Journal Article": "journalArticle",
"Newspaper Article": "newspaperArticle",
"Video-Audio Media": "videoRecording",
Expand Down Expand Up @@ -174,7 +175,7 @@ function processTag(item, tag, value) {
}
else if (value.includes("[pii]")) item.pagesBackup = value.replace(/\s*\[pii\]/, "");
}
else if (tag == "MH" || tag == "OT") {
else if (tag == "MH" || tag == "OT" || tag == "KW") { // KoreaMed uses KW
item.tags.push(value);
}
}
Expand All @@ -186,7 +187,7 @@ function doImport() {
do { // first valid line is type
Zotero.debug("ignoring " + line);
line = Zotero.read();
} while (line !== false && line.search(/^[A-Z0-9]+\s*-/) == -1);
} while (line !== false && !(/^[A-Z0-9]+\s*-/.test(line)));

var item = new Zotero.Item();
item.creatorsBackup = [];
Expand All @@ -204,7 +205,7 @@ function doImport() {
item.creatorsBackup = [];
}
}
else if (line.search(/^[A-Z0-9]+\s*-/) != -1) {
else if (/^[A-Z0-9]+\s*-/.test(line)) {
// if this line is a tag, take a look at the previous line to map
// its tag
if (tag) {
Expand Down Expand Up @@ -290,7 +291,7 @@ function finalizeItem(item) {
delete item.publicationTitle;
}
else if (!item.itemType) {
if (item.itemTypeBackup && !item.extra.includes("ERIC Number: EJ")) {
if (item.itemTypeBackup && (!item.extra || !item.extra.includes("ERIC Number: EJ"))) {
item.itemType = item.itemTypeBackup; // using report from above
item.institution = item.publicationTitle;
delete item.publicationTitle;
Expand Down

0 comments on commit 70efd04

Please sign in to comment.