diff --git a/mermaid/src/worker.js b/mermaid/src/worker.js index 253acba37..60474094c 100644 --- a/mermaid/src/worker.js +++ b/mermaid/src/worker.js @@ -81,7 +81,13 @@ export class Worker { page.evaluate(async (definition, mermaidConfig) => { window.mermaid.initialize(mermaidConfig) try { - const { svg } = await window.mermaid.render('container', definition) + let { svg } = await window.mermaid.render('container', definition) + // workaround: https://github.com/yuzutech/kroki/issues/1632 + // upstream issue: https://github.com/mermaid-js/mermaid/issues/1766 + // taken from: https://github.com/mermaid-js/mermaid-live-editor/blob/83382901cd7e15414b6f18b48b7dd9c4775f3a21/src/lib/components/Actions.svelte#L23-L26 + svg = svg + .replaceAll('
', '
') + .replaceAll(/]*)>/g, (m, g) => ``) return { svg, error: null } } catch (err) { return { diff --git a/mermaid/test/convert-test.mjs b/mermaid/test/convert-test.mjs index 494e0e38c..a78c94c54 100644 --- a/mermaid/test/convert-test.mjs +++ b/mermaid/test/convert-test.mjs @@ -16,7 +16,8 @@ const svgTests = [ { content: 'Hello
World' }, { content: 'Hello
World' }, { content: 'Hello
World' }, - { content: 'Hello
World' } + { content: 'Hello
World' }, + { content: 'Hello\\nWorld' } ] const pngTests = [ @@ -65,7 +66,7 @@ describe('#convert', function () { const worker = new Worker(browser) const result = await worker.convert(new Task(`graph TD A{{ ${testCase.content} }}`)) - expect(result).to.contains('Hello
World
') + expect(result).to.contains('Hello
World
') } finally { await browser.close() }