For now, use Zotero item DB ids when passing items to citeproc
citeproc-js relies on this in several locations. Seems that Zotero passes these IDs to citeproc from the item picker. We also need to consider existing embedded items in Word/LO documents, but they do have embedded URIs, so it shouldn't be a problem. CC @fbennett
This commit is contained in:
parent
c84a16984b
commit
ec786bf15c
2 changed files with 8 additions and 17 deletions
|
@ -524,6 +524,9 @@ Zotero.Cite.System.prototype = {
|
|||
|
||||
var cslItem = Zotero.Utilities.itemToCSLJSON(zoteroItem);
|
||||
|
||||
// TEMP: citeproc-js currently expects the id property to be the item DB id
|
||||
cslItem.id = zoteroItem.id;
|
||||
|
||||
if (!Zotero.Prefs.get("export.citePaperJournalArticleURL")) {
|
||||
var itemType = Zotero.ItemTypes.getName(zoteroItem.itemTypeID);
|
||||
// don't return URL or accessed information for journal articles if a
|
||||
|
|
|
@ -419,25 +419,13 @@ function generateCiteProcJSExportData(currentData) {
|
|||
let zItem = Zotero.Items.get(items[itemName].id);
|
||||
cslExportData[itemName] = Zotero.Cite.System.prototype.retrieveItem(zItem);
|
||||
|
||||
// Don't replace id as long as it follows expected format
|
||||
if (!currentData || !currentData[itemName]) continue;
|
||||
|
||||
// For simplicity, be more lenient than for item key
|
||||
let idRe = /^http:\/\/zotero\.org\/users\/local\/\w{8}\/items\/\w{8}$/;
|
||||
for (let field in cslExportData[itemName]) {
|
||||
let oldVal = currentData[itemName][field];
|
||||
if (!oldVal) continue;
|
||||
|
||||
let val = cslExportData[itemName][field];
|
||||
switch (field) {
|
||||
case 'id':
|
||||
if (!idRe.test(oldVal) || !idRe.test(val)) continue;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
cslExportData[itemName][field] = oldVal;
|
||||
// Don't replace id as long as it follows expected format
|
||||
if (Number.isInteger(currentData[itemName].id)
|
||||
&& Number.isInteger(cslExportData[itemName].id)
|
||||
) {
|
||||
cslExportData[itemName].id = currentData[itemName].id;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue