Ticket #1694: BibTeX-file_export.patch
| File BibTeX-file_export.patch, 2.2 KB (added by karnesky, 6 years ago) |
|---|
-
BibTeX.js
1638 1638 } else if (field == "sentelink") { // the reference manager 'Sente' has a unique file scheme in exported BibTeX 1639 1639 item.attachments = [{url:value.split(",")[0], mimeType:"application/pdf", downloadable:true}]; 1640 1640 } else if (field == "file") { 1641 var [filetitle, filepath, filetype] = value.split(":"); 1642 if (filetitle.length == 0) { 1643 filetitle = "Attachment"; 1641 for each(var attachment in value.split(";")){ 1642 var [filetitle, filepath, filetype] = attachment.split(":"); 1643 if (filetitle.length == 0) { 1644 filetitle = "Attachment"; 1645 } 1646 if (filetype.match(/pdf/i)) { 1647 item.attachments.push({url:"file://"+filepath, mimeType:"application/pdf", title:filetitle, downloadable:true}); 1648 } else { 1649 item.attachments.push({url:"file://"+filepath, title:filetitle, downloadable:true}); 1650 } 1644 1651 } 1645 if (filetype.match(/pdf/i)) {1646 item.attachments = [{url:"file://"+filepath, mimeType:"application/pdf", title:filetitle, downloadable:true}];1647 } else {1648 item.attachments = [{url:"file://"+filepath, title:filetitle, downloadable:true}];1649 }1650 1652 } 1651 1653 } 1652 1654 … … 1827 1829 if(!isMacro) Zotero.write("{"); 1828 1830 // url field is preserved, for use with \href and \url 1829 1831 // Other fields (DOI?) may need similar treatment 1830 if(!((field == "url") || (field == "doi") )) {1832 if(!((field == "url") || (field == "doi") | (field == "file"))) { 1831 1833 // I hope these are all the escape characters! 1832 1834 value = value.replace(/[|\<\>\~\^\\]/g, mapEscape).replace(/([\#\$\%\&\_])/g, "\\$1"); 1833 1835 // Case of words with uppercase characters in non-initial positions is preserved with braces. … … 2075 2077 } 2076 2078 2077 2079 if(Zotero.getOption("exportFileData")) { 2078 if(item.attachments) { 2080 if(item.attachments) { 2081 var attachmentString = ""; 2079 2082 for each(var attachment in item.attachments) { 2080 writeField("file", ":" + attachment.path + ":" + attachment.mimeType);2083 attachmentString += ";" + attachment.title + ":" + attachment.path + ":" + attachment.mimeType; 2081 2084 } 2085 writeField("file", attachmentString.substr(1)); 2082 2086 } 2083 2087 } 2084 2088