Skip to content

Commit

Permalink
resolves #1632 workaround to produce valid xhtml
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Sep 23, 2023
1 parent e229e29 commit 2bc1c13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mermaid/src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<br>', '<br/>')
.replaceAll(/<img([^>]*)>/g, (m, g) => `<img ${g} />`)
return { svg, error: null }
} catch (err) {
return {
Expand Down

0 comments on commit 2bc1c13

Please sign in to comment.