parent
b994651baa
commit
054c8fa6c2
|
|
@ -1,6 +1,7 @@
|
|||
import TreeModel = require("tree-model");
|
||||
import { showHintWithLink } from "../../utils/hint";
|
||||
import { getNoteTree, parseHTMLLines, renderNoteHTML } from "../../utils/note";
|
||||
import { htmlEscape, htmlUnescape } from "../../utils/str";
|
||||
|
||||
export async function saveFreeMind(filename: string, noteId: number) {
|
||||
const noteItem = Zotero.Items.get(noteId);
|
||||
|
|
@ -22,20 +23,17 @@ async function note2mm(
|
|||
}
|
||||
e.childNodes.forEach((_e) => textNodeForEach(_e, callbackfn));
|
||||
};
|
||||
const html2Escape = (sHtml: string) => {
|
||||
return sHtml.replace(/[<>&"]/g, function (c) {
|
||||
return { "<": "<", ">": ">", "&": "&", '"': """ }[c]!;
|
||||
});
|
||||
};
|
||||
let lines: string[] = [];
|
||||
if (options.withContent) {
|
||||
const doc = ztoolkit
|
||||
.getDOMParser()
|
||||
.parseFromString(await renderNoteHTML(noteItem), "text/html");
|
||||
textNodeForEach(doc.body, (e: Text) => {
|
||||
e.data = html2Escape(e.data);
|
||||
e.data = htmlEscape(doc, e.data);
|
||||
});
|
||||
lines = parseHTMLLines(doc.body.innerHTML);
|
||||
lines = parseHTMLLines(doc.body.innerHTML).map((line) =>
|
||||
htmlUnescape(line),
|
||||
);
|
||||
}
|
||||
const convertClosingTags = (htmlStr: string) => {
|
||||
const regConfs = [
|
||||
|
|
@ -56,7 +54,8 @@ async function note2mm(
|
|||
return htmlStr;
|
||||
};
|
||||
const convertNode = (node: TreeModel.Node<NoteNodeData>) => {
|
||||
mmXML += `<node ID="${node.model.id}" TEXT="${html2Escape(
|
||||
mmXML += `<node ID="${node.model.id}" TEXT="${htmlEscape(
|
||||
Zotero.getMainWindow().document,
|
||||
node.model.name || noteItem.getNoteTitle(),
|
||||
)}"><hook NAME="AlwaysUnfoldedNode" />`;
|
||||
if (
|
||||
|
|
|
|||
Loading…
Reference in New Issue