Make sure math equations are rendered sequentially (#294)

This commit is contained in:
Jonatan Kłosko 2021-05-25 14:36:55 +02:00 committed by GitHub
parent 122c6f27d7
commit 2e0195f658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,18 +79,18 @@ class Markdown {
// Replaces TeX formulas in string with rendered HTML using KaTeX. // Replaces TeX formulas in string with rendered HTML using KaTeX.
__renderMathInString(string) { __renderMathInString(string) {
const options = { return string.replace(
throwOnError: false, /(\${1,2})([\s\S]*?)\1/g,
errorColor: "inherit", (match, delimiter, math) => {
}; const displayMode = delimiter === "$$";
return string return katex.renderToString(math.trim(), {
.replace(/\$\$([\s\S]*?)\$\$/g, (match, math) => { displayMode,
return katex.renderToString(math, { ...options, displayMode: true }); throwOnError: false,
}) errorColor: "inherit",
.replace(/\$([\s\S]*?)\$/g, (match, math) => { });
return katex.renderToString(math, options); }
}); );
} }
} }