In minilatex.lamdera.app, KaTeX renders math in Firefox but not Chrome
See original GitHub issueBefore reporting a bug
- Check common issues.
- Check the bug is reproducible in the demo. If not, check KaTeX is up-to-date and installed correctly.
- Search for existing issues.
Describe the bug: In https://minilatex.lamdera.app/g/1 KaTeX renders math in Firefox, but not Chrome.
To Reproduce: Steps to reproduce the behavior:
- Go to https://minilatex.lamdera.app/g/1 first in Firefox.
- Scroll down to look at the math. It is OK
- Now do the same with Chrome. The math is not rendered =
Expected behavior: See above
Environment (please complete the following information):
- KaTeX Version: 0.12.0
- Device: Desktop
- OS: MacOS 10.5.5
- Browser: Firefox 78.0.2, Chrome 83.0.4103.116
Additional context:
The error occurs in an app (https://minilatex.lamdera.app) built with Elm does on-the-fly compilation of LaTeX to HTML, with the math-mode stuff rendered by KaTeX. Elm compiles its code to Javascript and interfaces with KaTeX via a custom element. Below is the code for that. Note that it uses katex.renderToString
exports.init = async function(app) {
console.log("I am starting elm-katex: init");
var katexJs = document.createElement('script')
katexJs.type = 'text/javascript'
katexJs.src = "https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.js"
katexJs.onload = initKatex
document.head.appendChild(katexJs);
console.log("elm-katex: I have appended katexJs to document.head");
}
function initKatex() {
console.log("elm-katex: initializing");
class MathText extends HTMLElement {
constructor() {
// Always call super first in constructor
super();
}
connectedCallback() {
this.attachShadow({mode: "open"});
this.shadowRoot.innerHTML =
katex.renderToString(
this.content,
{ throwOnError: false, output: "mathml", displayMode: this.display }
);
}
}
customElements.define('math-text', MathText)
}
PS. There are some display issues with equation numbers. That is my problem, not that of KaTeX. I’ve had to make some small changes in the MiniLaTeX compiler to make it work with KaTeX. Still a few things left to do.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)

Top Related StackOverflow Question
Yes indeed!! Thanks^{10}
Setting
innerHTMLwill remove the child. You’d need to do those operations in the opposite order, I guess.