mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-29 04:09:43 +02:00
Remove katex from mermaid.tiny
This commit is contained in:
@@ -68,7 +68,7 @@ export const addDiagrams = () => {
|
||||
}
|
||||
);
|
||||
|
||||
if (includeLargeDiagrams) {
|
||||
if (includeLargeFeatures) {
|
||||
registerLazyLoadedDiagrams(flowchartElk, mindmap);
|
||||
}
|
||||
|
||||
|
@@ -341,29 +341,36 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise<
|
||||
return text.replace(katexRegex, 'MathML is unsupported in this environment.');
|
||||
}
|
||||
|
||||
const { default: katex } = await import('katex');
|
||||
return text
|
||||
.split(lineBreakRegex)
|
||||
.map((line) =>
|
||||
hasKatex(line)
|
||||
? `
|
||||
if (includeLargeFeatures) {
|
||||
const { default: katex } = await import('katex');
|
||||
return text
|
||||
.split(lineBreakRegex)
|
||||
.map((line) =>
|
||||
hasKatex(line)
|
||||
? `
|
||||
<div style="display: flex; align-items: center; justify-content: center; white-space: nowrap;">
|
||||
${line}
|
||||
</div>
|
||||
`
|
||||
: `<div>${line}</div>`
|
||||
)
|
||||
.join('')
|
||||
.replace(katexRegex, (_, c) =>
|
||||
katex
|
||||
.renderToString(c, {
|
||||
throwOnError: true,
|
||||
displayMode: true,
|
||||
output: isMathMLSupported() ? 'mathml' : 'htmlAndMathml',
|
||||
})
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
);
|
||||
: `<div>${line}</div>`
|
||||
)
|
||||
.join('')
|
||||
.replace(katexRegex, (_, c) =>
|
||||
katex
|
||||
.renderToString(c, {
|
||||
throwOnError: true,
|
||||
displayMode: true,
|
||||
output: isMathMLSupported() ? 'mathml' : 'htmlAndMathml',
|
||||
})
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
);
|
||||
}
|
||||
|
||||
return text.replace(
|
||||
katexRegex,
|
||||
'Katex is unsupported in mermaid.tiny.js. Please use mermaid.js or mermaid.min.js.'
|
||||
);
|
||||
};
|
||||
|
||||
export default {
|
||||
|
@@ -32,7 +32,7 @@ import type { DiagramMetadata, DiagramStyleClassDef } from './diagram-api/types.
|
||||
import { preprocessDiagram } from './preprocess.js';
|
||||
import { decodeEntities } from './utils.js';
|
||||
|
||||
const version = packageVersion + (includeLargeDiagrams ? '' : '-tiny');
|
||||
const version = packageVersion + (includeLargeFeatures ? '' : '-tiny');
|
||||
|
||||
const MAX_TEXTLENGTH = 50_000;
|
||||
const MAX_TEXTLENGTH_EXCEEDED_MSG =
|
||||
|
2
packages/mermaid/src/type.d.ts
vendored
2
packages/mermaid/src/type.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
// eslint-disable-next-line no-var
|
||||
declare var includeLargeDiagrams: boolean;
|
||||
declare var includeLargeFeatures: boolean;
|
||||
|
Reference in New Issue
Block a user