fix(katex): enforce html output for consistency

This commit is contained in:
Nicolas Newman 2022-03-29 17:25:51 -04:00
parent 275f2002b5
commit 4736e59393
2 changed files with 7 additions and 3 deletions

View File

@ -142,7 +142,9 @@ export const addVertices = function (vert, g, svgId, root, doc) {
_shape = 'rect';
}
const labelText = vertexText.replace(/\$\$(.*)\$\$/g, (r, c) =>
katex.renderToString(c, { throwOnError: true, displayMode: true }).replace(/\n/g, ' ')
katex
.renderToString(c, { throwOnError: true, displayMode: true, output: 'html' })
.replace(/\n/g, ' ')
);
console.log(labelText);
// Add the node

View File

@ -65,7 +65,9 @@ export const addVertices = function (vert, g, svgId, root, _doc) {
label: vertexText
.replace(/fa[lrsb]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
.replace(/\$\$(.*)\$\$/g, (r, c) =>
katex.renderToString(c, { throwOnError: true, displayMode: true }).replace(/\n/g, ' ')
katex
.renderToString(c, { throwOnError: true, displayMode: true, output: 'html' })
.replace(/\n/g, ' ')
),
};
vertexNode = addHtmlLabel(svg, node).node();
@ -245,7 +247,7 @@ export const addEdges = function (edges, g) {
.replace(/fa[lrsb]?:fa-[\w-]+/g, (s) => `<i class='${s.replace(':', ' ')}'></i>`)
.replace(/\$\$(.*)\$\$/g, (r, c) =>
katex
.renderToString(c, { output: 'mathml', throwOnError: true, displayMode: true })
.renderToString(c, { throwOnError: true, displayMode: true, output: 'html' })
.replace(/\n/g, ' ')
)}</span>`;
} else {