Markdown note export: Replace zotero:// without separate saving code path
This commit is contained in:
parent
19977598eb
commit
ad21d73ad9
2 changed files with 15 additions and 19 deletions
|
@ -123,6 +123,9 @@ Zotero_File_Exporter.prototype.save = async function () {
|
|||
}
|
||||
|
||||
async function _exportDone(obj, worked) {
|
||||
// Close the items exported indicator
|
||||
Zotero_File_Interface.Progress.close();
|
||||
|
||||
if (!worked) {
|
||||
Zotero.alert(
|
||||
null,
|
||||
|
@ -132,27 +135,9 @@ Zotero_File_Exporter.prototype.save = async function () {
|
|||
Zotero_File_Interface.Progress.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// For Note Markdown translator replace zotero:// URI scheme,
|
||||
// if the current app is not Zotero
|
||||
if (io.selectedTranslator.translatorID == '154c2785-ec83-4c27-8a8a-d27b3a2eded1'
|
||||
&& ZOTERO_CONFIG.ID != 'zotero') {
|
||||
let text = obj.string;
|
||||
text = text.replace(/zotero:\/\//g, ZOTERO_CONFIG.ID + '://');
|
||||
await Zotero.File.putContentsAsync(fp.file, text);
|
||||
}
|
||||
|
||||
// Close the items exported indicator
|
||||
Zotero_File_Interface.Progress.close();
|
||||
}
|
||||
|
||||
// Post process and save translator output in _exportDone, if using
|
||||
// Note Markdown translator and the current app is not Zotero.
|
||||
// For other translators setLocation is better because it uses streaming
|
||||
if (!(io.selectedTranslator.translatorID == '154c2785-ec83-4c27-8a8a-d27b3a2eded1'
|
||||
&& ZOTERO_CONFIG.ID != 'zotero')) {
|
||||
translation.setLocation(Zotero.File.pathToFile(fp.file));
|
||||
}
|
||||
translation.setLocation(Zotero.File.pathToFile(fp.file));
|
||||
translation.setTranslator(io.selectedTranslator);
|
||||
translation.setDisplayOptions(io.displayOptions);
|
||||
translation.setHandler("itemDone", function () {
|
||||
|
|
|
@ -809,9 +809,20 @@ Zotero.Translate.IO.Write.prototype = {
|
|||
this._charset = charset;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a function to modify data on each write()
|
||||
*/
|
||||
setDataProcessor: function (processor) {
|
||||
this._processor = processor;
|
||||
},
|
||||
|
||||
"write":function(data) {
|
||||
if(!this._charset) this.setCharacterSet("UTF-8");
|
||||
|
||||
if (this._processor) {
|
||||
data = this._processor(data);
|
||||
}
|
||||
|
||||
if(!this._writtenToStream && this._charset.substr(this._charset.length-4) == "xBOM"
|
||||
&& BOMs[this._charset.substr(0, this._charset.length-4).toUpperCase()]) {
|
||||
// If stream has not yet been written to, and a UTF type has been selected, write BOM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue