fix: Remove data loss when unsupported markdown is encountered

This commit is contained in:
Sidharth Vinod
2025-08-14 13:05:44 +05:30
parent ce996346f8
commit d74013c642
2 changed files with 8 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
@@ -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('');