From 054c8fa6c21c7eab666abb07e79ff50193b0a1ad Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:44:32 +0800 Subject: [PATCH] fix: export to freemind html unescape fix: #1000 --- src/modules/export/freemind.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/modules/export/freemind.ts b/src/modules/export/freemind.ts index 907bf1a..573a336 100644 --- a/src/modules/export/freemind.ts +++ b/src/modules/export/freemind.ts @@ -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) => { - mmXML += ``; if (