File: debugging-tips.rst

package info (click to toggle)
mathjax-docs 2.7%2B20171212-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,100 kB
  • sloc: javascript: 28; sh: 22; python: 19; makefile: 8
file content (69 lines) | stat: -rw-r--r-- 1,823 bytes parent folder | download | duplicates (2)
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
.. _debugging-tips:

**********************
MathJax Debugging tips
**********************

This page documents basic tips for debugging MathJax in your application.


Using unpacked resources
========================

MathJax provides both packged (minified) and unpacked versions of all its components. For debugging, it is useful to switch to an unpacked versions.

For example, if your copy of MathJax lives at `https://example.com/MathJax.js` just add `unpacked/` before `MathJax.js`, e.g.,


.. code-block:: html

    <script type="text/javascript" async
      src="https://example.com/MathJax.js?config=TeX-MML-AM_CHTML">
    </script>

to


.. code-block:: html

    <script type="text/javascript" async
      src="https://example.com/unpacked/MathJax.js?config=TeX-MML-AM_CHTML">
    </script>


Getting traceback information
=============================

.. code-block:: javascript

  MathJax.Hub.lastError


MathJax stores the error object from the last `Math Processing Error` in `MathJax.Hub.lastError`. This allow developers to access the stack trace information when needed.


Add listener for MathJax errors
===============================

MathJax provides a detailed signaling infrastructure which a developers can hook into.

The following example hooks into Math Processing Errors.

.. code-block:: javascript

  MathJax.Hub.Register.MessageHook("Math Processing Error",function (message) {
    //  do something with the error.  message[2] is the Error object that records the problem.
  });


Another example hooks into TeX parsing errors.

.. code-block:: javascript

  MathJax.Hub.Register.MessageHook("TeX Jax - parse error",function (message) {
    // do something with the error.  message[1] will contain the data about the error.
  });

.. note::

  For more information, see :ref:`mathjax-api`.