fix: note sync format
This commit is contained in:
parent
239fd2e787
commit
083c24b6ae
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue