diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts b/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts index 9c8fbaa2d..4fce38f97 100644 --- a/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts +++ b/packages/mermaid/src/diagrams/sankey/sankeyDiagram.ts @@ -4,6 +4,10 @@ import parser from './parser/sankey.jison'; import db from './sankeyDB.js'; import styles from './styles.js'; import renderer from './sankeyRenderer.js'; +import { prepareTextForParsing } from './sankeyUtils.js'; + +const originalParse = parser.parse.bind(parser); +parser.parse = (text: string) => originalParse(prepareTextForParsing(text)); export const diagram: DiagramDefinition = { parser, diff --git a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts index b034e8c24..4bb5bbd15 100644 --- a/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts +++ b/packages/mermaid/src/diagrams/sankey/sankeyRenderer.ts @@ -17,7 +17,6 @@ import { sankeyJustify as d3SankeyJustify, } from 'd3-sankey'; import { configureSvgSize } from '../../setupGraphViewbox.js'; -import { prepareTextForParsing } from './sankeyUtils.js'; /** * Draws a sequenceDiagram in the tag with id: id based on the graph definition in text. @@ -28,14 +27,6 @@ import { prepareTextForParsing } from './sankeyUtils.js'; * @param diagObj - A standard diagram containing the db and the text and type etc of the diagram */ export const draw = function (text: string, id: string, _version: string, diagObj: Diagram): void { - // Clear DB before parsing - // - diagObj.db.clear?.(); - - // Launch parsing - const preparedText = prepareTextForParsing(text); - diagObj.parser.parse(preparedText); - // TODO: Figure out what is happening there // The main thing is svg object that is a d3 wrapper for svg operations //