mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-14 22:09:29 +02:00
fix: Remove data loss when unsupported markdown is encountered
This commit is contained in:
@@ -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', () => {
|
||||
|
@@ -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
|
||||
@@ -89,7 +90,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('');
|
||||
|
Reference in New Issue
Block a user