closes #1694, PATCH: BibTeX file export of descriptions, proper support for multiple files (thanks to karnesky)
This commit is contained in:
parent
0acaf22576
commit
bc3b405e82
1 changed files with 15 additions and 11 deletions
|
@ -1638,14 +1638,16 @@ function processField(item, field, value) {
|
||||||
} else if (field == "sentelink") { // the reference manager 'Sente' has a unique file scheme in exported BibTeX
|
} else if (field == "sentelink") { // the reference manager 'Sente' has a unique file scheme in exported BibTeX
|
||||||
item.attachments = [{url:value.split(",")[0], mimeType:"application/pdf", downloadable:true}];
|
item.attachments = [{url:value.split(",")[0], mimeType:"application/pdf", downloadable:true}];
|
||||||
} else if (field == "file") {
|
} else if (field == "file") {
|
||||||
var [filetitle, filepath, filetype] = value.split(":");
|
for each(var attachment in value.split(";")){
|
||||||
if (filetitle.length == 0) {
|
var [filetitle, filepath, filetype] = attachment.split(":");
|
||||||
filetitle = "Attachment";
|
if (filetitle.length == 0) {
|
||||||
}
|
filetitle = "Attachment";
|
||||||
if (filetype.match(/pdf/i)) {
|
}
|
||||||
item.attachments = [{url:"file://"+filepath, mimeType:"application/pdf", title:filetitle, downloadable:true}];
|
if (filetype.match(/pdf/i)) {
|
||||||
} else {
|
item.attachments.push({url:"file://"+filepath, mimeType:"application/pdf", title:filetitle, downloadable:true});
|
||||||
item.attachments = [{url:"file://"+filepath, title:filetitle, downloadable:true}];
|
} else {
|
||||||
|
item.attachments.push({url:"file://"+filepath, title:filetitle, downloadable:true});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1827,7 +1829,7 @@ function writeField(field, value, isMacro) {
|
||||||
if(!isMacro) Zotero.write("{");
|
if(!isMacro) Zotero.write("{");
|
||||||
// url field is preserved, for use with \href and \url
|
// url field is preserved, for use with \href and \url
|
||||||
// Other fields (DOI?) may need similar treatment
|
// Other fields (DOI?) may need similar treatment
|
||||||
if(!((field == "url") || (field == "doi"))) {
|
if(!((field == "url") || (field == "doi") | (field == "file"))) {
|
||||||
// I hope these are all the escape characters!
|
// I hope these are all the escape characters!
|
||||||
value = value.replace(/[|\<\>\~\^\\]/g, mapEscape).replace(/([\#\$\%\&\_])/g, "\\$1");
|
value = value.replace(/[|\<\>\~\^\\]/g, mapEscape).replace(/([\#\$\%\&\_])/g, "\\$1");
|
||||||
// Case of words with uppercase characters in non-initial positions is preserved with braces.
|
// Case of words with uppercase characters in non-initial positions is preserved with braces.
|
||||||
|
@ -2075,10 +2077,12 @@ function doExport() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Zotero.getOption("exportFileData")) {
|
if(Zotero.getOption("exportFileData")) {
|
||||||
if(item.attachments) {
|
if(item.attachments) {
|
||||||
|
var attachmentString = "";
|
||||||
for each(var attachment in item.attachments) {
|
for each(var attachment in item.attachments) {
|
||||||
writeField("file", ":" + attachment.path + ":" + attachment.mimeType);
|
attachmentString += ";" + attachment.title + ":" + attachment.path + ":" + attachment.mimeType;
|
||||||
}
|
}
|
||||||
|
writeField("file", attachmentString.substr(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue