question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In minilatex.lamdera.app, KaTeX renders math in Firefox but not Chrome

See original GitHub issue

Before reporting a bug

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:

  1. Go to https://minilatex.lamdera.app/g/1 first in Firefox.
  2. Scroll down to look at the math. It is OK
  3. 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:closed
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jxxcarlsoncommented, Jul 23, 2020

Yes indeed!! Thanks^{10}

Screen Shot 2020-07-23 at 5 27 05 PM
1reaction
edemainecommented, Jul 23, 2020

Setting innerHTML will remove the child. You’d need to do those operations in the opposite order, I guess.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LaTeX / KaTeX / math-jax doesn't render on many sites
Some math typesetting doesn't render. Neither on my desktop Firefox nor my android Firefox installs. I believe it is just KaTeX, especially from...
Read more >
Rendering doesn't work in Chrome, but works in Firefox
I'm creating a rich text editor with Tiptap together with MathJax to render Math nicely. I'm trying to get it working first, so...
Read more >
LaTeX in the Browser - James Carlson - Medium
The app is written in Elm and uses Lamdera, an integrated all-Elm front-to-backend solution. The app can also render Math-Markdown: like ...
Read more >
JFd - River Thames Conditions - Environment Agency - GOV.UK
Jabushe day and night cream, Kindness bible verses for kids, Max life insurance tvc, Non voting participating common shares, Seoul meteo 10 jours, ......
Read more >
MathJAX works in Firefox but not IE and Chrome????
The vendor sends us a zip file with HTMLML in it. We import it into Moodle. And the equations are rendered as equations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found