From 6cf5d22a9fc1fc5f126d31b96953c802e568177d Mon Sep 17 00:00:00 2001 From: Daniel Gergely Banfi Date: Wed, 21 Feb 2024 17:28:45 +0100 Subject: [PATCH] add ::: highlight signal chars --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index d1c1c68b..6a31c5e9 100644 --- a/src/index.js +++ b/src/index.js @@ -103,7 +103,7 @@ async function cli () { .addOption(new Option('-t, --theme [theme]', 'Theme of the chart').choices(['default', 'forest', 'dark', 'neutral']).default('default')) .addOption(new Option('-w, --width [width]', 'Width of the page').argParser(parseCommanderInt).default(800)) .addOption(new Option('-H, --height [height]', 'Height of the page').argParser(parseCommanderInt).default(600)) - .option('-i, --input ', 'Input mermaid file. Files ending in .md will be treated as Markdown and all charts (e.g. ```mermaid (...)```) will be extracted and generated. Use `-` to read from stdin.') + .option('-i, --input ', 'Input mermaid file. Files ending in .md will be treated as Markdown and all charts (e.g. ```mermaid (...)``` or :::mermaid (...):::) will be extracted and generated. Use `-` to read from stdin.') .option('-o, --output [output]', 'Output file. It should be either md, svg, png or pdf. Optional. Default: input + ".svg"') .addOption(new Option('-e, --outputFormat [format]', 'Output format for the generated image.').choices(['svg', 'png', 'pdf']).default(null, 'Loaded from the output file extension')) .addOption(new Option('-b, --backgroundColor [backgroundColor]', 'Background color for pngs/svgs (not pdfs). Example: transparent, red, \'#F0F0F0\'.').default('white')) @@ -401,7 +401,7 @@ async function run (input, output, { puppeteerConfig = {}, quiet = false, output } // TODO: should we use a Markdown parser like remark instead of rolling our own parser? - const mermaidChartsInMarkdown = /^[^\S\n]*```(?:mermaid)([^\S\n]*\r?\n([\s\S]*?))```[^\S\n]*$/ + const mermaidChartsInMarkdown = /^[^\S\n]*[`:]{3}(?:mermaid)([^\S\n]*\r?\n([\s\S]*?))[`:]{3}[^\S\n]*$/ const mermaidChartsInMarkdownRegexGlobal = new RegExp(mermaidChartsInMarkdown, 'gm') const browser = await puppeteer.launch(puppeteerConfig) try {