Shun Miyazawa 2 лет назад
Родитель
Сommit
f256d1aa69
1 измененных файлов с 2 добавлено и 7 удалено
  1. 2 7
      apps/app/src/services/renderer/remark-plugins/mermaid.ts

+ 2 - 7
apps/app/src/services/renderer/remark-plugins/mermaid.ts

@@ -1,16 +1,11 @@
-import { fromMarkdown } from 'mdast-util-from-markdown';
 import { Plugin } from 'unified';
 import { Plugin } from 'unified';
 import { Node } from 'unist';
 import { Node } from 'unist';
 import { visit } from 'unist-util-visit';
 import { visit } from 'unist-util-visit';
 
 
 function rewriteNode(node: Node) {
 function rewriteNode(node: Node) {
-  const mermaidTree = fromMarkdown(node.value as string);
-
   // replace node
   // replace node
-  if (mermaidTree.children[0] != null) {
-    node.type = 'paragraph';
-    node.children = mermaidTree.children[0].children;
-  }
+  const data = node.data ?? (node.data = {});
+  data.hName = 'mermaid';
 }
 }
 
 
 export const remarkPlugin: Plugin = function() {
 export const remarkPlugin: Plugin = function() {