Merge pull request #6855 from mermaid-js/sidv/showRawData

fix: fallback to raw text instead of rendering *Unsupported markdown*
This commit is contained in:
Alois Klink
2025-08-14 11:01:58 +00:00
committed by GitHub
4 changed files with 41 additions and 2 deletions

View File

@@ -285,7 +285,11 @@ test('markdownToHTML - Unsupported formatting', () => {
- l1
- l2
- l3`)
).toMatchInlineSnapshot('"<p>Hello</p>Unsupported markdown: list"');
).toMatchInlineSnapshot(`
"<p>Hello</p> - l1
- l2
- l3"
`);
});
test('markdownToHTML - no auto wrapping', () => {

View File

@@ -3,6 +3,7 @@ import { marked } from 'marked';
import { dedent } from 'ts-dedent';
import type { MarkdownLine, MarkdownWordType } from './types.js';
import type { MermaidConfig } from '../config.type.js';
import { log } from '../logger.js';
/**
* @param markdown - markdown to process
@@ -61,6 +62,8 @@ export function markdownToLines(markdown: string, config: MermaidConfig = {}): M
});
} else if (treeNode.type === 'html') {
lines[currentLine].push({ content: treeNode.text, type: 'normal' });
} else {
lines[currentLine].push({ content: treeNode.raw, type: 'normal' });
}
});
@@ -89,7 +92,8 @@ export function markdownToHTML(markdown: string, { markdownAutoWrap }: MermaidCo
} else if (node.type === 'escape') {
return node.text;
}
return `Unsupported markdown: ${node.type}`;
log.warn(`Unsupported markdown: ${node.type}`);
return node.raw;
}
return nodes.map(output).join('');