mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
chore(katex): lint:fix
This commit is contained in:
parent
fb5d80a7a1
commit
bbc6eb6ee7
@ -22,7 +22,12 @@ export const setConf = function (cnf: any) {
|
||||
* @param mermaidVersion - The version
|
||||
* @param error - The caught error
|
||||
*/
|
||||
export const draw = (_text: string, id: string, mermaidVersion: string, error: Error | null = null) => {
|
||||
export const draw = (
|
||||
_text: string,
|
||||
id: string,
|
||||
mermaidVersion: string,
|
||||
error: Error | null = null
|
||||
) => {
|
||||
try {
|
||||
log.debug('Renering svg for syntax error\n');
|
||||
|
||||
|
@ -59,12 +59,14 @@ export const addVertices = function (vert, g, svgId, root, doc, diagObj) {
|
||||
if (evaluate(getConfig().flowchart.htmlLabels)) {
|
||||
// TODO: addHtmlLabel accepts a labelStyle. Do we possibly have that?
|
||||
const node = {
|
||||
label: vertexText.replace(
|
||||
/fa[blrs]?:fa-[\w-]+/g,
|
||||
(s) => `<i class='${s.replace(':', ' ')}'></i>`
|
||||
).replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' }).replace(/\n/g, ' ').replace(/<annotation.*<\/annotation>/g, '')
|
||||
),
|
||||
label: vertexText
|
||||
.replace(/fa[blrs]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
|
||||
.replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
),
|
||||
};
|
||||
vertexNode = addHtmlLabel(svg, node).node();
|
||||
vertexNode.parentNode.removeChild(vertexNode);
|
||||
@ -147,7 +149,8 @@ export const addVertices = function (vert, g, svgId, root, doc, diagObj) {
|
||||
const labelText = vertexText.replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ').replace(/<annotation.*<\/annotation>/g, '')
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
);
|
||||
// Add the node
|
||||
g.setNode(vertex.id, {
|
||||
@ -319,7 +322,10 @@ export const addEdges = function (edges, g, diagObj) {
|
||||
edgeData.label = edge.text
|
||||
.replace(common.lineBreakRegex, '\n')
|
||||
.replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' }).replace(/\n/g, ' ').replace(/<annotation.*<\/annotation>/g, '')
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
);
|
||||
|
||||
if (edge.style === undefined) {
|
||||
|
@ -58,13 +58,13 @@ export const addVertices = function (vert, g, svgId, root, _doc, diagObj) {
|
||||
if (evaluate(getConfig().flowchart.htmlLabels)) {
|
||||
// TODO: addHtmlLabel accepts a labelStyle. Do we possibly have that?
|
||||
const node = {
|
||||
label: vertexText.replace(
|
||||
/fa[blrs]?:fa-[\w-]+/g,
|
||||
(s) => `<i class='${s.replace(':', ' ')}'></i>`
|
||||
).replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
label: vertexText
|
||||
.replace(/fa[blrs]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
|
||||
.replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ').replace(/<annotation.*<\/annotation>/g, '')
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
),
|
||||
};
|
||||
vertexNode = addHtmlLabel(svg, node).node();
|
||||
@ -244,14 +244,14 @@ export const addEdges = function (edges, g, diagObj) {
|
||||
edgeData.labelType = 'html';
|
||||
edgeData.label = `<span id="L-${linkId}" class="edgeLabel L-${linkNameStart}' L-${linkNameEnd}" style="${
|
||||
edgeData.labelStyle
|
||||
}">${edge.text.replace(
|
||||
/fa[blrs]?:fa-[\w-]+/g,
|
||||
(s) => `<i class='${s.replace(':', ' ')}'></i>`
|
||||
).replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ').replace(/<annotation.*<\/annotation>/g, '')
|
||||
)}</span>`;
|
||||
}">${edge.text
|
||||
.replace(/fa[blrs]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
|
||||
.replace(/\$\$(.*)\$\$/g, (r, c) =>
|
||||
katex
|
||||
.renderToString(c, { throwOnError: true, displayMode: true, output: 'mathml' })
|
||||
.replace(/\n/g, ' ')
|
||||
.replace(/<annotation.*<\/annotation>/g, '')
|
||||
)}</span>`;
|
||||
} else {
|
||||
edgeData.labelType = 'text';
|
||||
edgeData.label = edge.text.replace(common.lineBreakRegex, '\n');
|
||||
|
Loading…
x
Reference in New Issue
Block a user