diff --git a/src/note/noteParse.ts b/src/note/noteParse.ts index a316ef3..45efa42 100644 --- a/src/note/noteParse.ts +++ b/src/note/noteParse.ts @@ -746,7 +746,7 @@ class NoteParse extends AddonBase { noteItem.libraryID, this._Addon.NoteExport._exportPath, options.skipSavingImages, - true, + false, NodeMode.direct ); console.log("rehype", rehype); @@ -852,6 +852,9 @@ class NoteParse extends AddonBase { // } // } // Check if image already belongs to note + this._Addon.SyncUtils.processM2NRehypeMetaImageNodes( + this._Addon.SyncUtils.getM2NRehypeImageNodes(rehype) + ); this._Addon.SyncUtils.processM2NRehypeHighlightNodes( this._Addon.SyncUtils.getM2NRehypeHighlightNodes(rehype) diff --git a/src/sync/syncUtils.ts b/src/sync/syncUtils.ts index 687f19e..5c4722f 100644 --- a/src/sync/syncUtils.ts +++ b/src/sync/syncUtils.ts @@ -910,8 +910,9 @@ class SyncUtils extends AddonBase { const newChild = h("span"); this.replace(newChild, node); newChild.properties.ztype = "zimage"; - const newNode = h("zimage", [newChild]); - this.replace(node, newNode); + // const newNode = h("zimage", [newChild]); + // this.replace(node, newNode); + node.properties.alt = toHtml(newChild); } console.log("zimage", node); } @@ -973,6 +974,26 @@ class SyncUtils extends AddonBase { return nodes; } + processM2NRehypeMetaImageNodes(nodes) { + if (!nodes.length) { + return; + } + + console.log("processing M2N meta images", nodes); + for (const node of nodes) { + if (/zimage/.test(node.properties.alt)) { + const newNode: any = unified() + .use(remarkGfm) + .use(remarkMath) + .use(rehypeParse, { fragment: true }) + .parse(node.properties.alt); + console.log(newNode); + newNode.properties.src = node.properties.src; + this.replace(node, newNode); + } + } + } + processM2NRehypeHighlightNodes(nodes) { if (!nodes.length) { return;