Karol
Karol

Reputation: 1254

MathJax: do not show raw latex preview

If you visit a page with MathJax on it, you will see raw latex for a moment, before is is processed and turned into nice "math". Is it possible to not show that raw source, and only display the math once it is ready?

Example page: http://www.mathjax.org/demos/tex-samples/

Upvotes: 2

Views: 602

Answers (1)

Peter Krautzberger
Peter Krautzberger

Reputation: 5305

It depends what you mean by that. Naturally, what's in the page will be displayed and if you rely on JS to remove it then there's always a chance it will be visible for a minimal amount.

The straight-forward approach is to hide your content and tell MathJax to unhide it once typesetting is done. (This will depend on the complexity of your content and your design.)

This sample (which can be found in the main code repository) shows as simple approach:

a) set visibility:hidden on some global element

b) Add a function to the MathJax queue to change it back once MathJax layout is done. E.g.,

 <script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function () {
       document.getElementById("hide_page").style.visibility = "";
    });
 </script>

Upvotes: 2

Related Questions