mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 10:36:43 +02:00
fix(katex): fixed rendering of KaTeX errors
This commit is contained in:
@@ -29,16 +29,18 @@ export const draw = (_text: string, id: string, mermaidVersion: string, error: E
|
|||||||
const svg = select('#' + id);
|
const svg = select('#' + id);
|
||||||
|
|
||||||
const g = svg.append('g');
|
const g = svg.append('g');
|
||||||
|
if (error && error.message?.includes('KaTeX')) {
|
||||||
if (error && error.message.includes('KaTeX')) {
|
|
||||||
const title = error.message.split(': ')[0];
|
const title = error.message.split(': ')[0];
|
||||||
const body = error.message.replace(/[A-z]*:/, '').replace('KaTeX parse ', '');
|
const body = error.message.replace(/[A-z]*:/, '').replace('KaTeX parse ', '');
|
||||||
g.append('foreignObject')
|
g.append('foreignObject')
|
||||||
.attr('width', 2000)
|
.attr('height', 100)
|
||||||
.attr('height', 500)
|
.attr('width', 500)
|
||||||
.append('xhtml:div')
|
.append('xhtml:div')
|
||||||
.style('font-size', '70px')
|
.style('font-size', '18px')
|
||||||
.html(`<h1>${title}</h1><p>${body}</p>`);
|
.style('color', '#552222')
|
||||||
|
.html(`<div style="font-size: 26px; margin-bottom: 8px">${title}</div><div>${body}</div>`);
|
||||||
|
svg.attr('height', 100);
|
||||||
|
svg.attr('width', 500);
|
||||||
} else {
|
} else {
|
||||||
g.append('path')
|
g.append('path')
|
||||||
.attr('class', 'error-icon')
|
.attr('class', 'error-icon')
|
||||||
|
Reference in New Issue
Block a user