mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-20 21:04:17 +08:00
Make sure math equations are rendered sequentially (#294)
This commit is contained in:
parent
122c6f27d7
commit
2e0195f658
1 changed files with 11 additions and 11 deletions
|
@ -79,18 +79,18 @@ class Markdown {
|
|||
|
||||
// Replaces TeX formulas in string with rendered HTML using KaTeX.
|
||||
__renderMathInString(string) {
|
||||
const options = {
|
||||
throwOnError: false,
|
||||
errorColor: "inherit",
|
||||
};
|
||||
return string.replace(
|
||||
/(\${1,2})([\s\S]*?)\1/g,
|
||||
(match, delimiter, math) => {
|
||||
const displayMode = delimiter === "$$";
|
||||
|
||||
return string
|
||||
.replace(/\$\$([\s\S]*?)\$\$/g, (match, math) => {
|
||||
return katex.renderToString(math, { ...options, displayMode: true });
|
||||
})
|
||||
.replace(/\$([\s\S]*?)\$/g, (match, math) => {
|
||||
return katex.renderToString(math, options);
|
||||
});
|
||||
return katex.renderToString(math.trim(), {
|
||||
displayMode,
|
||||
throwOnError: false,
|
||||
errorColor: "inherit",
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue