From 077cc653d0a59c160e06ee9592dacae50a5e957c Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Wed, 31 May 2023 16:42:54 +0900 Subject: [PATCH] chore(katex): included uncommited files --- packages/mermaid/src/diagrams/common/common.ts | 6 +++--- packages/mermaid/src/diagrams/flowchart/flowRenderer.js | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index 87f6653fe..1ba26f0c6 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -174,7 +174,7 @@ export const parseGenericTypes = function (text: string): string { // TODO: find a better method for detecting support. This interface was added in the MathML 4 spec. // Firefox versions between [4,71] (0.47%) and Safari versions between [5,13.4] (0.17%) don't have this interface implemented but MathML is supported -export const isMathMLSupported = window.MathMLElement !== undefined; +export const isMathMLSupported = () => window.MathMLElement !== undefined; export const katexRegex = /\$\$(.*)\$\$/g; @@ -223,7 +223,7 @@ export const calculateMathMLDimensions = (text: string, config: MermaidConfig) = * @returns String containing MathML if KaTeX is supported, or an error message if it is not and stylesheets aren't present */ export const renderKatex = (text: string, config: MermaidConfig): string => { - if (isMathMLSupported || (!isMathMLSupported && config.legacyMathML)) { + if (isMathMLSupported() || (!isMathMLSupported() && config.legacyMathML)) { return text .split(lineBreakRegex) .map((line) => @@ -241,7 +241,7 @@ export const renderKatex = (text: string, config: MermaidConfig): string => { .renderToString(c, { throwOnError: true, displayMode: true, - output: isMathMLSupported ? 'mathml' : 'htmlAndMathml', + output: isMathMLSupported() ? 'mathml' : 'htmlAndMathml', }) .replace(/\n/g, ' ') .replace(//g, '') diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js index f85d20219..c5ce60c43 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js @@ -61,7 +61,8 @@ export const addVertices = function (vert, g, svgId, root, _doc, diagObj) { vertexText.replace( /fa[blrs]?:fa-[\w-]+/g, (s) => `` - ) + ), + getConfig() ), }; vertexNode = addHtmlLabel(svg, node).node(); @@ -242,7 +243,11 @@ export const addEdges = function (edges, g, diagObj) { edgeData.label = `${renderKatex( - edge.text.replace(/fa[blrs]?:fa-[\w-]+/g, (s) => ``) + edge.text.replace( + /fa[blrs]?:fa-[\w-]+/g, + (s) => `` + ), + getConfig() )}`; } else { edgeData.labelType = 'text';