Skip to content

Commit 1e7f3c1

Browse files
zeripathlunny
andauthored
Fix environments for KaTeX and error reporting (#22453)
In #22447 it was noticed that display environments were not working correctly. This was due to the setting displayMode not being set. Further it was noticed that the error was not being displayed correctly. This PR fixes both of these issues by forcibly setting the displayMode setting and corrects an error in displayError. Fix #22447 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 2782c14 commit 1e7f3c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

web_src/js/markup/math.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function displayError(el, err) {
22
const target = targetElement(el);
3-
target.remove('is-loading');
3+
target.classList.remove('is-loading');
44
const errorNode = document.createElement('div');
55
errorNode.setAttribute('class', 'ui message error markup-block-error mono');
66
errorNode.textContent = err.str || err.message || String(err);
@@ -23,13 +23,15 @@ export async function renderMath() {
2323

2424
for (const el of els) {
2525
const source = el.textContent;
26-
const nodeName = el.classList.contains('display') ? 'p' : 'span';
26+
const displayMode = el.classList.contains('display');
27+
const nodeName = displayMode ? 'p' : 'span';
2728

2829
try {
2930
const tempEl = document.createElement(nodeName);
3031
katex.render(source, tempEl, {
3132
maxSize: 25,
3233
maxExpand: 50,
34+
displayMode,
3335
});
3436
targetElement(el).replaceWith(tempEl);
3537
} catch (error) {

0 commit comments

Comments
 (0)