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.

Display format not operative in custom element, poor/nonexistent display in some browsers

See original GitHub issue

Before reporting a bug

Describe the bug: In a functioning custom element, displayMode: true does not result in display mode rendering.

To Reproduce: Steps to reproduce the behavior:

  1. Go to https://jxxcarlson.github.io/app/katex/index.html using Firefox
  2. Look at last equation. It should be in display mode, but is not.

Expected behavior: As noted above. But:

  1. Second formula should be in display mode (Firefox)
  2. Poor display in Safari (second equation, superscript)
  3. No math display in Chrome

Screenshots: If applicable, add screenshots to help explain your problem.

Screen Shot 2020-07-08 at 7 24 18 PM Screen Shot 2020-07-08 at 7 25 10 PM Screen Shot 2020-07-08 at 7 24 33 PM

Environment (please complete the following information):

  • KaTeX Version: [Latest, first used today, July 8, 2020]
  • Device: [Desktop]
  • OS: [MacOS 10.14.6]
  • Browser: [Firefox, Safari, Chrome]
  • Version: [e.g. 77.0.1 ; 13.1.1 (14609.2.9.1.3); 83.0.4103.106]

Additional context: I am using KaTeX in an Elm app: See https://github.com/jxxcarlson/meenylatex and also https://minilatex.io See the katex branch, https://github.com/jxxcarlson/meenylatex/blob/katex/example/index-katex.html Am evaluating KaTeX for use in my LaTeX > Html compiler. (Contact: jxxcarlson at gmail) I use MathJax and KaTeX via custom elements. For KaTeX, it is https://github.com/jxxcarlson/meenylatex/blob/katex/example/assets/elm-katex.js

For convenience, here is the code for elm-katex.js:


const init =  async function(app) {

  console.log("I am starting elm-katex: init");
  var katexJs = document.createElement('script')
  katexJs.type = 'text/javascript'
  katexJs.onload = initKatex
  katexJs.src = "https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"

  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() {
      console.log('katex connectedCallback',this.content )
      console.log('katex format',this.format )
      const displayMode = (this.format == 'display') ? true : false ;
      console.log ('displayMode', displayMode)

      this.attachShadow({mode: "open"});
      this.shadowRoot.innerHTML =
        katex.renderToString(
          this.content,
          { throwOnError: false, output: "mathml", displayMode: displayMode }
        );
    }

  }

  customElements.define('math-text', MathText)

}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ronkokcommented, Jul 8, 2020

This is a duplicate of #2219, which was fixed by PR #2220 in March. The problem is that we have not had a release issued since September. There are also some bug fix PRs waiting for review, much less release.

0reactions
ronkokcommented, Jul 23, 2020

Re: Fonts. KaTeX HTML does require reference to the KaTeX fonts. If you are self-hosting KaTeX, then KaTeX expects the KaTeX fonts to be located in a directory called fonts which is a sibling of the katex.min.css stylesheet. All of those files are available from the tar files and zip files on the KaTeX releases page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using custom elements - Web Components | MDN
At this point, let's go through some more simple examples to show you how custom elements are created in more detail. Autonomous custom...
Read more >
Angular - Custom Elements not working on Firefox & Microsoft ...
I got my Custom Elements project to work in other browsers by removing encapsulation: ViewEncapsulation.Native.
Read more >
Custom Elements (V1) | Can I use... Support tables for HTML5 ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Custom elements - The Modern JavaScript Tutorial
To create a custom element, we need to tell the browser several details about it: how to show it, what to do when...
Read more >
Custom Elements v1 - Reusable Web Components
Once you've told the browser about a new tag, that's it. No take backs. Custom elements cannot be self-closing because HTML only allows...
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