Ticket #1694: BibTeX-file_export.patch

File BibTeX-file_export.patch, 2.2 KB (added by karnesky, 6 years ago)
  • BibTeX.js

     
    16381638        } else if (field == "sentelink") { // the reference manager 'Sente' has a unique file scheme in exported BibTeX 
    16391639                        item.attachments = [{url:value.split(",")[0], mimeType:"application/pdf", downloadable:true}]; 
    16401640        } 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                        } 
    16441651                } 
    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                 } 
    16501652        } 
    16511653} 
    16521654 
     
    18271829        if(!isMacro) Zotero.write("{"); 
    18281830        // url field is preserved, for use with \href and \url 
    18291831        // Other fields (DOI?) may need similar treatment 
    1830         if(!((field == "url") || (field == "doi"))) { 
     1832        if(!((field == "url") || (field == "doi") | (field == "file"))) { 
    18311833                // I hope these are all the escape characters! 
    18321834                value = value.replace(/[|\<\>\~\^\\]/g, mapEscape).replace(/([\#\$\%\&\_])/g, "\\$1"); 
    18331835                // Case of words with uppercase characters in non-initial positions is preserved with braces. 
     
    20752077                }                
    20762078                 
    20772079                if(Zotero.getOption("exportFileData")) { 
    2078                          if(item.attachments) { 
     2080                        if(item.attachments) { 
     2081                                var attachmentString = ""; 
    20792082                                for each(var attachment in item.attachments) { 
    2080                                         writeField("file",      ":" + attachment.path + ":" + attachment.mimeType); 
     2083                                        attachmentString += ";" + attachment.title + ":" + attachment.path + ":" + attachment.mimeType; 
    20812084                                } 
     2085                                writeField("file", attachmentString.substr(1)); 
    20822086                        } 
    20832087                } 
    20842088