From 1d86cf01ad81596789650cca21d86762af05187a Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 7 Dec 2023 00:37:25 +0530 Subject: [PATCH] refactor: Cleanup error renderer --- packages/mermaid/src/diagrams/error/errorRenderer.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/error/errorRenderer.ts b/packages/mermaid/src/diagrams/error/errorRenderer.ts index c9efa1054..778206139 100644 --- a/packages/mermaid/src/diagrams/error/errorRenderer.ts +++ b/packages/mermaid/src/diagrams/error/errorRenderer.ts @@ -2,10 +2,9 @@ import { log } from '../../logger.js'; import type { Group, SVG } from '../../diagram-api/types.js'; import { selectSvgElement } from '../../rendering-util/selectSvgElement.js'; import { configureSvgSize } from '../../setupGraphViewbox.js'; -import type { Diagram } from '../../Diagram.js'; /** - * Draws a an info picture in the tag with id: id based on the graph definition in text. + * Draws an info picture in the tag with id: id based on the graph definition in text. * * @param _text - Mermaid graph definition. * @param id - The text for the error @@ -16,15 +15,15 @@ export const draw = ( _text: string, id: string, version: string, - _diagramObject: Diagram, + _diagramObject: unknown, error?: Error ) => { - log.debug('renering svg for syntax error\n'); + log.debug('rendering svg for syntax error\n'); const svg: SVG = selectSvgElement(id); const g: Group = svg.append('g'); if (error?.message?.includes('KaTeX')) { const title = error.message.split(': ')[0]; - const body = error.message.replace(/[A-z]*:/, '').replace('KaTeX parse ', ''); + const body = error.message.slice(title.length + 2).replace('KaTeX parse ', ''); g.append('foreignObject') .attr('height', 100) .attr('width', 500)