fix: #176 export md with highlight bug

This commit is contained in:
xiangyu 2022-10-10 23:55:20 +08:00
parent 1838904bbe
commit bc4943fd57
2 changed files with 16 additions and 0 deletions

View File

@ -220,6 +220,7 @@ class NoteExportWindow extends AddonBase {
exportFile: exportFile,
exportSingleFile: exportSingleFile,
exportAutoSync: exportAutoSync,
exportHighlight: exportHighlight,
embedLink: embedLink,
exportNote: exportNote,
exportCopy: exportCopy,

View File

@ -708,6 +708,21 @@ class NoteParse extends AddonBase {
return "[" + content + "](" + href + title + ")";
},
});
if (Zotero.Prefs.get("Knowledge4Zotero.exportHighlight")) {
turndownService.addRule("backgroundColor", {
filter: function (node, options) {
return node.nodeName === "SPAN" && node.style["background-color"];
},
replacement: function (content, node) {
return `<span style="background-color: ${
(node as HTMLElement).style["background-color"]
}">${content}</span>`;
},
});
}
const parsedMD = turndownService.turndown(doc.body);
console.log(parsedMD);
return parsedMD;