Skip to content

Overloading "Show Source" as overlay etc

Davide P. Cervone edited this page May 28, 2013 · 2 revisions

From https://groups.google.com/d/msg/mathjax-users/Qg-tpH6CQGQ/0HCElAu3DmgJ


Add the following script to your page somewhere BEFORE the script that loads MathJax.js:

<script type="text/x-mathjax-config"> 
MathJax.Hub.Register.StartupHook("MathMenu Ready",function () { 
  MathJax.Menu.ShowSource.Window = function () {};  // don't open the Show Math window 
  MathJax.Menu.ShowSource.Text = function (text,event) { 
    ... your code here ... 
  }; 
}); 
</script> 

Note that I have disabled the routine that opens the window used by the current ShowSource.Text function, so you won't get an unwanted window.

Add your code in the place indicated. One reason that MathJax uses a separate window is that it is then easy to "select all" and copy the contents of the window. That is not so easy to do with a div. You might consider setting the selection to the contents of the div so that is is pre-selected when the source is shown.

Davide

Clone this wiki locally