fix: #176 export md with highlight bug
This commit is contained in:
parent
1838904bbe
commit
bc4943fd57
|
|
@ -220,6 +220,7 @@ class NoteExportWindow extends AddonBase {
|
|||
exportFile: exportFile,
|
||||
exportSingleFile: exportSingleFile,
|
||||
exportAutoSync: exportAutoSync,
|
||||
exportHighlight: exportHighlight,
|
||||
embedLink: embedLink,
|
||||
exportNote: exportNote,
|
||||
exportCopy: exportCopy,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue