mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
chore(katex): included uncommited files
This commit is contained in:
parent
cf54ddc62b
commit
077cc653d0
@ -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(/<annotation.*<\/annotation>/g, '')
|
||||
|
@ -61,7 +61,8 @@ export const addVertices = function (vert, g, svgId, root, _doc, diagObj) {
|
||||
vertexText.replace(
|
||||
/fa[blrs]?:fa-[\w-]+/g,
|
||||
(s) => `<i class='${s.replace(':', ' ')}'></i>`
|
||||
)
|
||||
),
|
||||
getConfig()
|
||||
),
|
||||
};
|
||||
vertexNode = addHtmlLabel(svg, node).node();
|
||||
@ -242,7 +243,11 @@ export const addEdges = function (edges, g, diagObj) {
|
||||
edgeData.label = `<span id="L-${linkId}" class="edgeLabel L-${linkNameStart}' L-${linkNameEnd}" style="${
|
||||
edgeData.labelStyle
|
||||
}">${renderKatex(
|
||||
edge.text.replace(/fa[blrs]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
|
||||
edge.text.replace(
|
||||
/fa[blrs]?:fa-[\w-]+/g,
|
||||
(s) => `<i class='${s.replace(':', ' ')}'></i>`
|
||||
),
|
||||
getConfig()
|
||||
)}</span>`;
|
||||
} else {
|
||||
edgeData.labelType = 'text';
|
||||
|
Loading…
x
Reference in New Issue
Block a user