This file is indexed.

/usr/share/doc/libjs-mathjax-doc/html/_sources/advanced/toMathML.rst.txt is in libjs-mathjax-doc 2.7+20171212-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.. _toMathML:

**************************************
Obtaining the MathML for an Expression
**************************************

The ``toMathML`` extension generates a string containing the MathML stored in MathJax's internal format. It is used in the MathJax Menu to generate MathML output for copy&paste under ``Show Math as -> MathML Code``. 

The ``toMathML`` extension generally works asynchronously because it potentially has to load additional files, in particular if the extension is used before MathJax has produced output rendering.

To use the extension, add ``"toMathML.js"`` to the `extensions` array of your configuration. For example,

.. code-block:: javascript

    MathJax.Hub.Config({
      extensions: ["toMathML.js"]
    });


The extension can be used by developers to access the MathML representation of an equation (e.g., to be stored for later use). Here is an example of how to make use of the ``toMathML.js``.

.. code-block:: javascript

    function getMathML(jax,callback) {
      var mml;
      try {
        //
        //  Try to produce the MathML (if an asynchronous
        //     action occurs, a reset error is thrown)
        //   Otherwise we got the MathML and call the
        //     user's callback passing the MathML.
        //
        mml = jax.root.toMathML("");
      } catch(err) {
        if (!err.restart) {throw err} // an actual error
        //
        //  For a delay due to file loading
        //    call this routine again after waiting for the
        //    the asynchronous action to finish.
        //
        return MathJax.Callback.After([getMathML,jax,callback],err.restart);
      }
      //
      //  Pass the MathML to the user's callback
      MathJax.Callback(callback)(mml);
    }


This will give you a function that you can pass an Element Jax and a callback function to.  The callback will be called with the MathML from the element.

Here is a complete example:

.. code-block:: html

    <!DOCTYPE html>
    <html>
    <head>
    <title>MathJax TeX to MathML Page</title>
    <script>
    function toMathML(jax,callback) {
      var mml;
      try {
        mml = jax.root.toMathML("");
      } catch(err) {
        if (!err.restart) {throw err} // an actual error
        return MathJax.Callback.After([toMathML,jax,callback],err.restart);
      }
      MathJax.Callback(callback)(mml);
    }
    </script>
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {inlineMath: [["$","$"],["\\\\​(","\\\\​)"]]}
      });
      MathJax.Hub.Queue(
        function () {
          var jax = MathJax.Hub.getAllJax();
          for (var i = 0; i < jax.length; i++) {
            toMathML(jax[i],function (mml) {
              alert(jax[i].originalText + "\n\n=>\n\n"+ mml);
            });
          }
        }
      );
    </script>
    <script type="text/javascript" src="http://example.com/MathJax.js?config=TeX-AMS_HTML-full"></script>
    </head>
    <body>
    <p>
    When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
    $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$
    </p>
    </body>
    </html>

This example loops through the math elements on the page and displays the original TeX and the resulting MathML.

Note that using the callbacks is the only safe way to do this, as the ``jax.root.toMathML()`` call may signal that it needs to load a file by throwing the reset error.  If you do not take this into account, your code may work most of the time, but will cause errors in isolated circumstances.