Topic on Extension talk:SimpleMathJax

2003:C4:5F15:4B00:3493:8B84:43CB:CC05 (talkcontribs)

Hey folks,

I’m using the MinervaNeue skin in conjunction with the SimpleMathJax extension for math display (version numbers see below).

The live preview (…#editor) does not show rendered math output but raw LaTeX source code. Is there a way to re-invoke MathJax.Hub.Typeset() right after the preview text has been added to the DOM? Is there a hook or some other appropriate event for that?

MediaWiki: 1.31.0

MinervaNeue: (2e70e79)

SimpleMathJax: 0.7.3

(This is a copy of the original question: Topic:Uir4rbph9eogl2mq)

131.111.184.83 (talkcontribs)

Hey! I think I figured out how to do this. This is a bit hacky; adjust the retry time (currently 1000 ms) to your liking.

I've got this in MediaWiki:Common.js:

function waitForMathJax($content) {
  if (typeof MathJax === 'undefined') {
    setTimeout(function () { waitForMathJax($content); }, 1000);
  } else {
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, $content[0]]).execute();
  }
}

mw.hook('wikipage.content').add(waitForMathJax);
Sm8ps (talkcontribs)

Thanks for sharing! Working well with MW 1.31.4 and SimpleMathJax 0.7.3. I shall add this to the extension page.

Jmkim dot com (talkcontribs)

From version 0.8.0, preview is supported without additional code.

Sm8ps (talkcontribs)

Great, thanks for that! I changed to extension page in order to account for this.

Jmkim dot com (talkcontribs)

Good, Thanks!