chore(katex): lint:fix

This commit is contained in:
NicolasNewman 2023-02-13 16:02:49 -06:00
parent fb5d80a7a1
commit bbc6eb6ee7
3 changed files with 33 additions and 22 deletions

View File

@ -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');

View File

@ -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) {

View File

@ -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');