From 7cb009cd38954f28b68a459e2eddd67596fff7e8 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Thu, 13 Jul 2023 23:54:49 +0100 Subject: [PATCH] build(docs): run remark plugins on MermaidConfig We use the `unified.stringify()` function on our remark plugins to stringify the Markdown AST for our MermaidConfig documentation. However, [`.stringify()`][1] only runs the stringify phase in unified, not the "run" phase. If we want to run our plugins on the Markdown AST, we need to also use the [`.run()`][2] function. [1]: https://github.com/unifiedjs/unified#processorstringifytree-file [2]: https://github.com/unifiedjs/unified#processorruntree-file-done --- packages/mermaid/src/docs.mts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/docs.mts b/packages/mermaid/src/docs.mts index 356cd3cd1..b3f356f34 100644 --- a/packages/mermaid/src/docs.mts +++ b/packages/mermaid/src/docs.mts @@ -420,7 +420,7 @@ async function transormJsonSchema(file: string) { } }); - const transformed = remark() + const transformer = remark() .use(remarkGfm) .use(remarkFrontmatter, ['yaml']) // support YAML front-matter in Markdown .use(transformMarkdownAst, { @@ -428,8 +428,9 @@ async function transormJsonSchema(file: string) { originalFilename: file, addAutogeneratedWarning: !noHeader, removeYAML: !noHeader, - }) - .stringify(markdownAst as Root); + }); + + const transformed = transformer.stringify(await transformer.run(markdownAst as Root)); const formatted = prettier.format(transformed, { parser: 'markdown',