diff options
author | zeripath <art27@cantab.net> | 2023-01-16 10:25:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-16 18:25:46 +0800 |
commit | 1e7f3c16a4f4b309cf9259e284450e66652121ae (patch) | |
tree | a7b313facda0cae3fc25ae32b148b0648764e1c8 | |
parent | 2782c1439679402a1f8731a94dc66214781282ba (diff) | |
download | gitea-1e7f3c16a4f4b309cf9259e284450e66652121ae.tar.gz gitea-1e7f3c16a4f4b309cf9259e284450e66652121ae.zip |
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 <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
-rw-r--r-- | web_src/js/markup/math.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/web_src/js/markup/math.js b/web_src/js/markup/math.js index d4e40d5be2..cfd058c93c 100644 --- a/web_src/js/markup/math.js +++ b/web_src/js/markup/math.js @@ -1,6 +1,6 @@ function displayError(el, err) { const target = targetElement(el); - target.remove('is-loading'); + target.classList.remove('is-loading'); const errorNode = document.createElement('div'); errorNode.setAttribute('class', 'ui message error markup-block-error mono'); errorNode.textContent = err.str || err.message || String(err); @@ -23,13 +23,15 @@ export async function renderMath() { for (const el of els) { const source = el.textContent; - const nodeName = el.classList.contains('display') ? 'p' : 'span'; + const displayMode = el.classList.contains('display'); + const nodeName = displayMode ? 'p' : 'span'; try { const tempEl = document.createElement(nodeName); katex.render(source, tempEl, { maxSize: 25, maxExpand: 50, + displayMode, }); targetElement(el).replaceWith(tempEl); } catch (error) { |