diff --git a/chrome/content/zotero/fileInterface.js b/chrome/content/zotero/fileInterface.js index 9fb8b4d2eb..d74c8af86b 100644 --- a/chrome/content/zotero/fileInterface.js +++ b/chrome/content/zotero/fileInterface.js @@ -626,7 +626,12 @@ var Zotero_File_Interface = new function() { if(window.zoteroLastRepaint && (now - window.zoteroLastRepaint) < 100) return // Start a nested event queue - Zotero.mainThread.pushEventQueue(null); + // TODO Remove when Fx > 14 + var eventQueuePushed = "pushEventQueue" in Zotero.mainThread; + if(eventQueuePushed) { + Zotero.mainThread.pushEventQueue(null); + } + try { // Add the redraw event onto event queue window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) @@ -637,7 +642,7 @@ var Zotero_File_Interface = new function() { Zotero.mainThread.processNextEvent(false); } finally { // Close nested event queue - Zotero.mainThread.popEventQueue(); + if(eventQueuePushed) Zotero.mainThread.popEventQueue(); } window.zoteroLastRepaint = now; diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 0767282811..8893f1126e 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -39,7 +39,7 @@ const Zotero_Lookup = new function () { if(doi) { var item = {itemType:"journalArticle", DOI:doi}; } else { - identifier = identifier.replace("-", "", "g"); + identifier = identifier.trim().replace("-", "", "g"); if(identifier.length == 10 || identifier.length == 13) { // ISBN var item = {itemType:"book", ISBN:identifier}; diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 909637898a..dcfd3498f7 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -404,12 +404,19 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback translate.setHandler("done", function(obj, returnValue) { me._checkResult(test, obj, returnValue, errorReturned, testDoneCallback); }); + var selectCalled = false; translate.setHandler("select", function(obj, items, callback) { if(test.items !== "multiple" && test.items.length <= 1) { testDoneCallback(me, test, "failed", "Zotero.selectItems() called, but only one item defined in test"); callback({}); + return; + } else if(selectCalled) { + testDoneCallback(me, test, "failed", "Zotero.selectItems() called multiple times"); + callback({}); + return; } + selectCalled = true; var newItems = {}; var haveItems = false; for(var i in items) { diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index c0904bb0d6..b8383cfc97 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -697,12 +697,12 @@ CSL_CHROME.prototype.deleteAttribute = function (myxml,attr) { myxml.removeAttribute(attr); } CSL_CHROME.prototype.setAttribute = function (myxml,attr,val) { - var attribute; if (!myxml.ownerDocument) { myxml = myxml.firstChild; } - attribute = myxml.ownerDocument.createAttribute(attr); - myxml.setAttribute(attr, val); + if (myxml.setAttribute) { + myxml.setAttribute(attr, val); + } return false; } CSL_CHROME.prototype.nodeCopy = function (myxml) { @@ -1122,7 +1122,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) { if (state.normalDecorIsOrphan(blobjr, params)) { continue; } - b = state.fun.decorate[params[0]][params[1]](state, b); + b = state.fun.decorate[params[0]][params[1]](state, b, params[2]); } } if (b && b.length) { @@ -1169,7 +1169,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) { if (state.normalDecorIsOrphan(blobjr, params)) { continue; } - blobs_start = state.fun.decorate[params[0]][params[1]](state, blobs_start); + blobs_start = state.fun.decorate[params[0]][params[1]](state, blobs_start, params[2]); } } b = blobs_start; @@ -1188,7 +1188,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) { if (["@bibliography", "@display"].indexOf(params[0]) === -1) { continue; } - blobs_start = state.fun.decorate[params[0]][params[1]].call(blob, state, blobs_start); + blobs_start = state.fun.decorate[params[0]][params[1]].call(blob, state, blobs_start, params[2]); } } } @@ -1286,7 +1286,7 @@ CSL.Output.Queue.prototype.renderBlobs = function (blobs, delim, has_more) { if (state.normalDecorIsOrphan(blob, params)) { continue; } - str = state.fun.decorate[params[0]][params[1]](state, str); + str = state.fun.decorate[params[0]][params[1]](state, str, params[2]); } } str = blob.strings.prefix + str + blob.strings.suffix; @@ -1610,7 +1610,7 @@ CSL.Output.Queue.adjustPunctuation = function (state, myblobs, stk, finish) { state.tmp.last_chr = lastchr; return lastchr; }; -CSL.compareAmbigConfig = function(a, b) { +CSL.ambigConfigDiff = function(a, b) { var ret, pos, len, ppos, llen; if (a.names.length !== b.names.length) { return 1; @@ -1619,7 +1619,7 @@ CSL.compareAmbigConfig = function(a, b) { if (a.names[pos] !== b.names[pos]) { return 1; } else { - for (ppos = 0, llen = a.names[pos]; ppos < llen; ppos += 1) { + for (ppos = 0, llen = a.givens[pos]; ppos < llen; ppos += 1) { if (a.givens[pos][ppos] !== b.givens[pos][ppos]) { return 1; } @@ -1627,6 +1627,12 @@ CSL.compareAmbigConfig = function(a, b) { } } } + if (a.disambiguate != b.disambiguate) { + return 1; + } + if (a.year_suffix !== b.year_suffix) { + return 1; + } return 0; }; CSL.cloneAmbigConfig = function (config, oldconfig, tainters) { @@ -1638,23 +1644,11 @@ CSL.cloneAmbigConfig = function (config, oldconfig, tainters) { ret.disambiguate = false; for (i = 0, ilen = config.names.length; i < ilen; i += 1) { param = config.names[i]; - if (oldconfig && (!oldconfig.names[i] || oldconfig.names[i] !== param)) { - for (j = 0, jlen = tainters.length; j < jlen; j += 1) { - this.tmp.taintedItemIDs[tainters[j].id] = true; - } - oldconfig = false; - } ret.names[i] = param; } for (i = 0, ilen = config.givens.length; i < ilen; i += 1) { param = []; for (j = 0, jlen = config.givens[i].length; j < jlen; j += 1) { - if (oldconfig && oldconfig.givens[i][j] !== config.givens[i][j]) { - for (k = 0, klen = tainters.length; k < klen; k += 1) { - this.tmp.taintedItemIDs[tainters[k].id] = true; - } - oldconfig = false; - } param.push(config.givens[i][j]); } ret.givens.push(param); @@ -1710,8 +1704,10 @@ CSL.expandMacro = function (macro_key_token) { this.build.macro_stack.push(mkey); } var hasDate = false; + var macroid = false; macro_nodes = this.sys.xml.getNodesByName(this.cslXml, 'macro', mkey); if (macro_nodes.length) { + macroid = this.sys.xml.getAttributeValue(macro_nodes[0],'cslid'); hasDate = this.sys.xml.getAttributeValue(macro_nodes[0], "macro-has-date"); } if (hasDate) { @@ -1723,6 +1719,7 @@ CSL.expandMacro = function (macro_key_token) { macro_key_token.execs.push(func); } macro_key_token.tokentype = CSL.START; + macro_key_token.cslid = macroid; CSL.Node.group.build.call(macro_key_token, this, this[this.build.area].tokens, true); if (!this.sys.xml.getNodeValue(macro_nodes)) { throw "CSL style error: undefined macro \"" + mkey + "\""; @@ -2156,7 +2153,7 @@ CSL.DateParser = function () { }; CSL.Engine = function (sys, style, lang, forceLang) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.305"; + this.processor_version = "1.0.316"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -2184,6 +2181,22 @@ CSL.Engine = function (sys, style, lang, forceLang) { this.output = new CSL.Output.Queue(this); this.dateput = new CSL.Output.Queue(this); this.cslXml = this.sys.xml.makeXml(style); + if (this.opt.development_extensions.csl_reverse_lookup_support) { + this.build.cslNodeId = 0; + this.setCslNodeIds = function(myxml, nodename) { + var children = this.sys.xml.children(myxml); + this.sys.xml.setAttribute(myxml, 'cslid', this.build.cslNodeId); + this.opt.nodenames.push(nodename); + this.build.cslNodeId += 1; + for (var i = 0, ilen = this.sys.xml.numberofnodes(children); i < ilen; i += 1) { + nodename = this.sys.xml.nodename(children[i]); + if (nodename) { + this.setCslNodeIds(children[i], nodename); + } + } + } + this.setCslNodeIds(this.cslXml, "style"); + } this.sys.xml.addMissingNameNodes(this.cslXml); this.sys.xml.addInstitutionNodes(this.cslXml); this.sys.xml.insertPublisherAndPlace(this.cslXml); @@ -2509,6 +2522,20 @@ CSL.Engine.prototype.retrieveItem = function (id) { } } } + if (this.opt.development_extensions.atomic_statutes) { + if (Item.type && ["legislation","bill"].indexOf(Item.type) > -1 + && Item.title + && Item.jurisdiction) { + var legislation_id = []; + for (var i = 0, ilen = 3; i < ilen; i += 1) { + var varname = ["type", "genre", "jurisdiction"][i]; + if (Item[varname]) { + legislation_id.push(Item[varname]); + } + } + Item.legislation_id = legislation_id.join("::"); + } + } for (var i = 1, ilen = CSL.DATE_VARIABLES.length; i < ilen; i += 1) { var dateobj = Item[CSL.DATE_VARIABLES[i]]; if (dateobj) { @@ -2750,6 +2777,9 @@ CSL.Engine.Opt = function () { this.development_extensions.flip_parentheses_to_braces = true; this.development_extensions.parse_section_variable = true; this.development_extensions.jurisdiction_subfield = true; + this.development_extensions.atomic_statutes = false; + this.development_extensions.csl_reverse_lookup_support = false; + this.nodenames = []; this.gender = {}; this['cite-lang-prefs'] = { persons:['orig'], @@ -3494,13 +3524,29 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, } for (k = 0, klen = citations[j].sortedItems.length; k < klen; k += 1) { item = citations[j].sortedItems[k]; + var myid = item[0].id; + var mylocator = item[1].locator; + var mylabel = item[1].label; + if (item[0].legislation_id) { + myid = item[0].legislation_id; + mylocator = item[0].section; + mylabel = ""; + } + var incitationid; + if (k > 0) { + if (onecitation.sortedItems[k - 1][0].legislation_id) { + incitationid = onecitation.sortedItems[k - 1][0].legislation_id; + } else { + incitationid = onecitation.sortedItems[k - 1][1].id + } + } if (flag === CSL.PREVIEW) { if (onecitation.citationID != citation.citationID) { if ("undefined" === typeof first_ref[item[1].id]) { - first_ref[item[1].id] = onecitation.properties.noteIndex; - last_ref[item[1].id] = onecitation.properties.noteIndex; + first_ref[myid] = onecitation.properties.noteIndex; + last_ref[myid] = onecitation.properties.noteIndex; } else { - last_ref[item[1].id] = onecitation.properties.noteIndex; + last_ref[myid] = onecitation.properties.noteIndex; } continue; } @@ -3511,17 +3557,27 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, oldvalue["near-note"] = item[1]["near-note"]; item[1]["first-reference-note-number"] = 0; item[1]["near-note"] = false; - if ("undefined" === typeof first_ref[item[1].id]) { - first_ref[item[1].id] = onecitation.properties.noteIndex; - last_ref[item[1].id] = onecitation.properties.noteIndex; + if ("undefined" === typeof first_ref[myid]) { + first_ref[myid] = onecitation.properties.noteIndex; + last_ref[myid] = onecitation.properties.noteIndex; item[1].position = CSL.POSITION_FIRST; } else { var ibidme = false; var suprame = false; + if (j > 0) { + var oldlastid = citations[j - 1].sortedItems.slice(-1)[0][1].id; + if (citations[j - 1].sortedItems[0].slice(-1)[0].legislation_id) { + oldlastid = citations[j - 1].sortedItems[0].slice(-1)[0].legislation_id; + } + } if (j > 0 && parseInt(k, 10) === 0 && citations[j - 1].properties.noteIndex !== citations[j].properties.noteIndex) { var items = citations[(j - 1)].sortedItems; var useme = false; - if ((citations[j - 1].sortedItems[0][1].id == item[1].id && citations[j - 1].properties.noteIndex >= (citations[j].properties.noteIndex - 1)) || citations[j - 1].sortedItems[0][1].id == this.registry.registry[item[1].id].parallel) { + var oldid = citations[j - 1].sortedItems[0][0].id; + if (citations[j - 1].sortedItems[0][0].legislation_id) { + oldid = citations[j - 1].sortedItems[0][0].legislation_id; + } + if ((oldid == myid && citations[j - 1].properties.noteIndex >= (citations[j].properties.noteIndex - 1)) || citations[j - 1].sortedItems[0][1].id == this.registry.registry[item[1].id].parallel) { if (citationsInNote[citations[j - 1].properties.noteIndex] == 1 || citations[j - 1].properties.noteIndex == 0) { useme = true; } @@ -3537,41 +3593,55 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, } else { suprame = true; } - } else if (k > 0 && onecitation.sortedItems[k - 1][1].id == item[1].id) { + } else if (k > 0 && incitationid == myid) { ibidme = true; } else if (k == 0 && citations[j - 1].properties.noteIndex == citations[j].properties.noteIndex && citations[j - 1].sortedItems.length - && citations[j - 1].sortedItems.slice(-1)[0][1].id == item[1].id) { + && oldlastid == myid) { ibidme = true; } else { suprame = true; } var prev, prev_locator, prev_label, curr_locator, curr_label; if (ibidme) { + var myprev_locator; + var myprev_label; if (k > 0) { - prev = onecitation.sortedItems[(k - 1)][1]; + if (onecitation.sortedItems[(k - 1)][0].legislation_id) { + myprev_locator = onecitation.sortedItems[(k - 1)][0].section; + myprev_label = ""; + } else { + myprev_locator = onecitation.sortedItems[(k - 1)][1].locator; + myprev_label = onecitation.sortedItems[(k - 1)][1].label; + } } else { - prev = citations[(j - 1)].sortedItems[0][1]; + if (citations[(j - 1)].sortedItems[0][0].legislation_id) { + myprev_locator = citations[(j - 1)].sortedItems[0][0].section; + myprev_label = ""; + } else { + myprev_locator = citations[(j - 1)].sortedItems[0][1].locator; + myprev_label = citations[(j - 1)].sortedItems[0][1].label; + } } - if (prev.locator) { - if (prev.label) { - prev_label = prev.label; + if (myprev_locator) { + if (myprev_label) { + prev_label = myprev_label; } else { prev_label = ""; } - prev_locator = "" + prev.locator + prev_label; + prev_locator = "" + myprev_locator + prev_label; } else { - prev_locator = prev.locator; + prev_locator = myprev_locator; } - if (item[1].locator) { - if (item[1].label) { - curr_label = item[1].label; + if (mylocator) { + if (mylabel) { + curr_label = mylabel; } else { curr_label = ""; } - curr_locator = "" + item[1].locator + curr_label; + curr_locator = "" + mylocator + curr_label; } else { - curr_locator = item[1].locator; + curr_locator = mylocator; } } if (ibidme && prev_locator && !curr_locator) { @@ -3594,18 +3664,18 @@ CSL.Engine.prototype.processCitationCluster = function (citation, citationsPre, } if (suprame) { item[1].position = CSL.POSITION_SUBSEQUENT; - if (first_ref[item[1].id] != onecitation.properties.noteIndex) { - item[1]["first-reference-note-number"] = first_ref[item[1].id]; + if (first_ref[myid] != onecitation.properties.noteIndex) { + item[1]["first-reference-note-number"] = first_ref[myid]; } } } if (onecitation.properties.noteIndex) { - var note_distance = parseInt(onecitation.properties.noteIndex, 10) - parseInt(last_ref[item[1].id], 10); + var note_distance = parseInt(onecitation.properties.noteIndex, 10) - parseInt(last_ref[myid], 10); if (item[1].position !== CSL.POSITION_FIRST && note_distance <= this.citation.opt["near-note-distance"]) { item[1]["near-note"] = true; } - last_ref[item[1].id] = onecitation.properties.noteIndex; + last_ref[myid] = onecitation.properties.noteIndex; } if (onecitation.citationID != citation.citationID) { for (n = 0, nlen = CSL.POSITION_TEST_VARS.length; n < nlen; n += 1) { @@ -4084,6 +4154,19 @@ CSL.citeEnd = function (Item, item) { this.tmp.cut_var = false; this.tmp.disambig_request = false; this.tmp.cite_locales.push(this.tmp.last_cite_locale); + if (this.tmp.original_date && this.tmp.renders_collection_number) { + var buf = []; + for (var i = this.tmp.original_date.list.length - 1; i > this.tmp.original_date.pos; i += -1) { + buf.push(this.tmp.original_date.list.pop()); + } + this.tmp.original_date.list.pop(); + for (var i = buf.length - 1; i > -1; i += -1) { + this.tmp.original_date.list.push(buf.pop()); + } + this.parallel.cite["original-date"] = false; + } + this.tmp.original_date = false; + this.tmp.renders_collection_number = false; if (this.opt.development_extensions.flip_parentheses_to_braces && item && item.suffix) { var openBrace = CSL.checkNestedBraceOpen.exec(item.suffix); var closeBrace = CSL.checkNestedBraceClose.exec(item.suffix); @@ -4393,15 +4476,6 @@ CSL.Node.date = { } } dp = dpx.slice(); - if (!state.tmp.extension && ("" + Item.volume) === "" + state.tmp.date_object.year && this.dateparts.length === 1 && this.dateparts[0] === "year") { - for (key in state.tmp.date_object) { - if (state.tmp.date_object.hasOwnProperty(key)) { - if (key.slice(0, 4) === "year" && state.tmp.citeblob.can_suppress_identical_year) { - delete state.tmp.date_object[key]; - } - } - } - } mypos = 2; len = dp.length; for (pos = 0; pos < len; pos += 1) { @@ -4422,6 +4496,23 @@ CSL.Node.date = { this.execs.push(func); func = function (state, Item) { state.output.startTag("date", this); + if (this.variables[0] === "original-date" + && Item.type === "legal_case" + && !state.tmp.extension + && "" + Item["collection-number"] === "" + state.tmp.date_object.year + && this.dateparts.length === 1 + && this.dateparts[0] === "year") { + for (key in state.tmp.date_object) { + if (state.tmp.date_object.hasOwnProperty(key)) { + if (key.slice(0, 4) === "year") { + state.tmp.original_date = {}; + var lst = state.output.current.mystack.slice(-2)[0].blobs; + state.tmp.original_date.list = lst; + state.tmp.original_date.pos = lst.length - 1; + } + } + } + } }; this.execs.push(func); } @@ -5121,7 +5212,6 @@ CSL.Node.layout = { this.execs.push(func); func = function (state, Item) { state.output.openLevel("empty"); - state.tmp.citeblob = state.output.queue[state.output.queue.length - 1]; }; this.execs.push(func); target.push(this); @@ -5279,7 +5369,6 @@ CSL.NameOutput.prototype.init = function (names) { if (!this.state.tmp.value.length) { return; } - this.state.tmp.group_context.value()[2] = false; }; CSL.NameOutput.prototype.reinit = function (names) { if (this.state.tmp.can_substitute.value()) { @@ -5333,6 +5422,7 @@ CSL.NameOutput.prototype.outputNames = function () { this.getEtAlConfig(); this.divideAndTransliterateNames(); this.truncatePersonalNameLists(); + this.disambigNames(); this.constrainNames(); if (this.name.strings.form === "count") { if (this.state.tmp.extension || this.names_count != 0) { @@ -5341,7 +5431,6 @@ CSL.NameOutput.prototype.outputNames = function () { } return; } - this.disambigNames(); this.setEtAlParameters(); this.setCommonTerm(); this.state.tmp.name_node = {}; @@ -5381,15 +5470,20 @@ CSL.NameOutput.prototype.outputNames = function () { this.state.output.append(blob, this.names); this.state.tmp.name_node.top = this.state.output.current.value(); if (variables[0] !== "authority") { - var oldSuppressDecorations = this.state.tmp.suppress_decorations; - this.state.tmp.suppress_decorations = true; - var lastBlob = this.state.tmp.name_node.top.blobs.pop(); - var name_node_string = this.state.output.string(this.state, lastBlob.blobs, false); - this.state.tmp.name_node.top.blobs.push(lastBlob); + var name_node_string = []; + var nameobjs = this.Item[variables[0]]; + if (nameobjs) { + for (var i = 0, ilen = nameobjs.length; i < ilen; i += 1) { + substring = CSL.Util.Names.getRawName(nameobjs[i]); + if (substring) { + name_node_string.push(substring); + } + } + } + name_node_string = name_node_string.join(", "); if (name_node_string) { this.state.tmp.name_node.string = name_node_string; } - this.state.tmp.suppress_decorations = oldSuppressDecorations; } if (this.state.tmp.name_node.string && !this.state.tmp.first_name_string) { this.state.tmp.first_name_string = this.state.tmp.name_node.string; @@ -5414,24 +5508,6 @@ CSL.NameOutput.prototype.outputNames = function () { } } } - if (this.Item.type === "personal_communication" || this.Item.type === "interview") { - var author = ""; - author = this.state.tmp.name_node.string; - if (author && this.state.sys.getAbbreviation && !(this.item && this.item["suppress-author"])) { - this.state.transform.loadAbbreviation("default", "nickname", author); - var myLocalName = this.state.transform.abbrevs["default"].nickname[author]; - if (myLocalName) { - if (myLocalName === "{suppress}") { - this.state.tmp.name_node.top.blobs.pop(); - this.state.tmp.group_context.value()[2] = false; - } else { - this.state.output.append(myLocalName, "empty", true) - blob = this.state.output.pop(); - this.state.tmp.name_node.top.blobs = [blob]; - } - } - } - } this._collapseAuthor(); this.variables = []; }; @@ -5692,7 +5768,10 @@ CSL.NameOutput.prototype._getFreeters = function (v, values) { this.freeters[v] = []; for (var i = values.length - 1; i > -1; i += -1) { if (this.isPerson(values[i])) { - this.freeters[v].push(values.pop()); + var value = this._checkNickname(values.pop()); + if (value) { + this.freeters[v].push(value); + } } else { break; } @@ -5710,7 +5789,10 @@ CSL.NameOutput.prototype._getPersonsAndInstitutions = function (v, values) { var first = true; for (var i = values.length - 1; i > -1; i += -1) { if (this.isPerson(values[i])) { - persons.push(values[i]); + var value = this._checkNickname(values[i]); + if (value) { + persons.push(value); + } } else { has_affiliates = true; this.institutions[v].push(values[i]); @@ -5734,6 +5816,22 @@ CSL.NameOutput.prototype._clearValues = function (values) { values.pop(); } }; +CSL.NameOutput.prototype._checkNickname = function (name) { + var author = ""; + author = CSL.Util.Names.getRawName(name); + if (author && this.state.sys.getAbbreviation && !(this.item && this.item["suppress-author"])) { + this.state.transform.loadAbbreviation("default", "nickname", author); + var myLocalName = this.state.transform.abbrevs["default"].nickname[author]; + if (myLocalName) { + if (myLocalName === "{suppress}") { + name = false; + } else { + name = {family:myLocalName,given:''}; + } + } + } + return name; +} CSL.NameOutput.prototype.joinPersons = function (blobs, pos) { var ret; if (this.etal_spec[pos] === 1) { @@ -5842,11 +5940,9 @@ CSL.NameOutput.prototype.disambigNames = function () { var v = this.variables[i]; if (this.freeters[v].length) { this._runDisambigNames(this.freeters[v], pos); - this.state.tmp.disambig_settings.givens.push([]); pos += 1; } if (this.institutions[v].length) { - this.state.tmp.disambig_settings.givens.push([]); pos += 1; } for (var j = 0, jlen = this.persons[v].length; j < jlen; j += 1) { @@ -5861,23 +5957,26 @@ CSL.NameOutput.prototype.disambigNames = function () { CSL.NameOutput.prototype._runDisambigNames = function (lst, pos) { var chk, myform, myinitials, param, i, ilen, paramx; for (i = 0, ilen = lst.length; i < ilen; i += 1) { - if (!lst[i].given || !lst[i].family) { + if (!lst[i].given && !lst[i].family) { continue; } + myinitials = this.name.strings["initialize-with"]; this.state.registry.namereg.addname("" + this.Item.id, lst[i], i); chk = this.state.tmp.disambig_settings.givens[pos]; if ("undefined" === typeof chk) { - this.state.tmp.disambig_settings.givens.push([]); + for (var j = 0, jlen = pos + 1; j < jlen; j += 1) { + if (!this.state.tmp.disambig_settings.givens[j]) { + this.state.tmp.disambig_settings.givens[j] = []; + } + } } chk = this.state.tmp.disambig_settings.givens[pos][i]; if ("undefined" === typeof chk) { myform = this.name.strings.form; - myinitials = this.name.strings["initialize-with"]; param = this.state.registry.namereg.evalname("" + this.Item.id, lst[i], i, 0, myform, myinitials); this.state.tmp.disambig_settings.givens[pos].push(param); } myform = this.name.strings.form; - myinitials = this.name.strings["initialize-with"]; paramx = this.state.registry.namereg.evalname("" + this.Item.id, lst[i], i, 0, myform, myinitials); if (this.state.tmp.disambig_request) { var val = this.state.tmp.disambig_settings.givens[pos][i]; @@ -5898,6 +5997,11 @@ CSL.NameOutput.prototype._runDisambigNames = function (lst, pos) { } if (!this.state.tmp.sort_key_flag) { this.state.tmp.disambig_settings.givens[pos][i] = param; + if ("string" === typeof myinitials + && ("undefined" === typeof this.name.strings["initialize"] + || true === this.name.strings["initialize"])) { + this.state.tmp.disambig_settings.use_initials = true; + } } } }; @@ -6024,9 +6128,6 @@ CSL.NameOutput.prototype._imposeNameConstraints = function (lst, count, key, pos } } this.state.tmp.disambig_settings.names[pos] = lst[key].length; - if (!this.state.tmp.disambig_request) { - this.state.tmp.disambig_settings.givens[pos] = []; - } }; CSL.NameOutput.prototype.getEtAlConfig = function () { var item = this.item; @@ -6708,6 +6809,7 @@ CSL.NameOutput.prototype._splitInstitution = function (value, v, i) { jurisdiction = this.state.transform.loadAbbreviation(jurisdiction, "institution-entire", str); if (this.state.transform.abbrevs[jurisdiction]["institution-entire"][str]) { var splitLst = this.state.transform.abbrevs[jurisdiction]["institution-entire"][str]; + splitLst = this.state.transform.quashCheck(splitLst); var splitSplitLst = splitLst.split(/>>[0-9]{4}>>/); var m = splitLst.match(/>>([0-9]{4})>>/); splitLst = splitSplitLst.pop(); @@ -6853,6 +6955,11 @@ CSL.evaluateLabel = function (node, state, Item, item) { } plural = state.tmp.shadow_numbers[myterm].plural; } + if (node.decorations && state.opt.development_extensions.csl_reverse_lookup_support) { + node.decorations.reverse(); + node.decorations.push(["@showid","true", node.cslid]); + node.decorations.reverse(); + } } return CSL.castLabel(state, node, myterm, plural, CSL.TOLERANT); }; @@ -7302,11 +7409,14 @@ CSL.Node.number = { varname = this.variables[0]; state.parallel.StartVariable(this.variables[0]); state.parallel.AppendToVariable(Item[this.variables[0]]); + if (varname === 'collection-number' && Item.type === 'legal_case') { + state.tmp.renders_collection_number = true; + } + var value = Item[this.variables[0]]; if (this.text_case_normal) { - var value = Item[this.variables[0]]; if (value) { value = value.replace("\\", ""); - state.output.append(value, this) + state.output.append(value, this); } } else { var node = this; @@ -7568,14 +7678,6 @@ CSL.Node.text = { abbrfall = true; } func = state.transform.getOutputFunction(this.variables, abbrevfam, abbrfall, altvar, transfall); - if (this.variables_real[0] === "container-title") { - var xfunc = function (state, Item, item) { - if (Item['container-title'] && state.tmp.citeblob.has_volume) { - state.tmp.citeblob.can_suppress_identical_year = true; - } - }; - this.execs.push(xfunc); - } } else { if (CSL.CITE_FIELDS.indexOf(this.variables_real[0]) > -1) { func = function (state, Item, item) { @@ -7611,7 +7713,6 @@ CSL.Node.text = { if (this.variables[0]) { var value = state.getVariable(Item, this.variables[0], form); if (value) { - state.tmp.citeblob.has_volume = true; state.output.append(value, this); } } @@ -7708,6 +7809,9 @@ CSL.Node.text = { } }; CSL.Attributes = {}; +CSL.Attributes["@cslid"] = function (state, arg) { + this.cslid = parseInt(arg, 10); +} CSL.Attributes["@is-plural"] = function (state, arg) { var func = function (state, Item, item) { var nameList = Item[arg]; @@ -8890,16 +8994,7 @@ CSL.Transform = function (state) { if (myabbrev_family) { primary = abbreviate(state, Item, alternative_varname, primary, myabbrev_family, true); if (primary) { - var m = primary.match(/^!([-,_a-z]+)<<); - if (m) { - var fields = m[1].split(","); - primary = primary.slice(m[0].length); - for (var i = 0, ilen = fields.length; i < ilen; i += 1) { - if (state.tmp.done_vars.indexOf(fields[i]) === -1) { - state.tmp.done_vars.push(fields[i]); - } - } - } + primary = quashCheck(primary); } secondary = abbreviate(state, Item, false, secondary, myabbrev_family, true); tertiary = abbreviate(state, Item, false, tertiary, myabbrev_family, true); @@ -8976,6 +9071,20 @@ CSL.Transform = function (state) { return [jurisdiction, hereinafter_key]; } this.getHereinafter = getHereinafter; + function quashCheck(value) { + var m = value.match(/^!([-,_a-z]+)<<); + if (m) { + var fields = m[1].split(","); + value = value.slice(m[0].length); + for (var i = 0, ilen = fields.length; i < ilen; i += 1) { + if (state.tmp.done_vars.indexOf(fields[i]) === -1) { + state.tmp.done_vars.push(fields[i]); + } + } + } + return value; + } + this.quashCheck = quashCheck; }; CSL.Parallel = function (state) { this.state = state; @@ -9721,6 +9830,16 @@ CSL.Util.Names.stripRight = function (str) { } return str.slice(0, end); }; +CSL.Util.Names.getRawName = function (name) { + var ret = []; + if (name.given) { + ret.push(name.given); + } + if (name.family) { + ret.push(name.family); + } + return ret.join(" "); +}; CSL.Util.Dates = {}; CSL.Util.Dates.year = {}; CSL.Util.Dates.year["long"] = function (state, num) { @@ -9857,6 +9976,11 @@ CSL.Util.substituteStart = function (state, target) { } }; this.execs.push(func); + if (this.decorations && state.opt.development_extensions.csl_reverse_lookup_support) { + this.decorations.reverse(); + this.decorations.push(["@showid","true", this.cslid]); + this.decorations.reverse(); + } nodetypes = ["number", "date", "names"]; if (("text" === this.name && !this.postponed_macro) || nodetypes.indexOf(this.name) > -1) { element_trace = function (state, Item, item) { @@ -10133,11 +10257,14 @@ CSL.Util.Suffixator.prototype.format = function (N) { CSL.Engine.prototype.processNumber = function (node, ItemObject, variable) { var num, m, i, ilen, j, jlen; var debug = false; - num = ItemObject[variable]; this.tmp.shadow_numbers[variable] = {}; this.tmp.shadow_numbers[variable].values = []; this.tmp.shadow_numbers[variable].plural = 0; this.tmp.shadow_numbers[variable].numeric = false; + if (!ItemObject) { + return; + } + num = ItemObject[variable]; if ("undefined" !== typeof num) { if ("number" === typeof num) { num = "" + num; @@ -10947,6 +11074,9 @@ CSL.Output.Formats.prototype.html = { }, "@display/indent": function (state, str) { return "