Skip to content

Commit c899d8e

Browse files
committed
Update processing model page
1 parent 7374822 commit c899d8e

File tree

1 file changed

+163
-1
lines changed

1 file changed

+163
-1
lines changed

advanced/model.rst

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,168 @@
44
The MathJax Processing Model
55
############################
66

7-
**This page is under construction**
7+
The purpose of MathJax is to bring the ability to include mathematics
8+
easily in web pages to as wide a range of browsers as possible.
9+
Authors can specify mathematics in a variety of formats (e.g.,
10+
:ref:`MathML <mathml-support>`, :ref:`LaTeX <tex-support>`, or
11+
:ref:`AsciiMath <asciimath-support>`), and MathJax provides
12+
high-quality mathematical typesetting even in those browsers that do
13+
not have native MathML support. This all happens without the need for
14+
special downloads or browser plugins, or installation of fonts, etc.
15+
16+
MathJax is broken into several different kinds of components: page
17+
handlers, input processors, output processors, and the MathJax object
18+
classes that organize and connect the others. The input and output
19+
processors are called `jax`, and are described in more detail
20+
below.
21+
22+
When MathJax runs, it looks through the page for special markers that
23+
delimitindicate mathematics; for each such marker, it locates an
24+
appropriate input jax, which it uses to convert the mathematics into
25+
an internal form (a MathML tree as javascript objects), and then calls
26+
an output jax to transform the internal format into HTML content that
27+
displays the mathematics within the page. The page author configures
28+
MathJax by indicating which input and output jax are to be used, and
29+
which extensions should be included.
30+
31+
While MathML notation is an XML format that consists of tags like
32+
those that make up the HTML language, it is not a format that is easy
33+
for page authors to write by hand. Many sites prefer to use a more
34+
natural input format like LaTeX or AsciiMath, especially when the
35+
sites allow readers to enter comments or post questions and answers.
36+
In this case, the mathematics is regular text within the page, and the
37+
author must indicate what parts of the text are methematics by using
38+
special `delimiters` to mark the start and of the expressions within
39+
the text. For example, LaTeX expressions may be delimited by
40+
``\(...\)`` for in-line expressions, and ``\[...\]`` or ``$$...$$``
41+
(though MathJax can be configured to use other ones as well).
42+
43+
See the :ref:`configuration` section for details about configuring the
44+
math delimiters. See the :ref:`tex-support`,
45+
:ref:`asciimath-support`, or :ref:`mathml-support` sections for
46+
information about using those formats, and for important caveats about
47+
how to include mathematical expressions within an HTML page.
48+
49+
Internally, the processing of the page is mediated by an object called
50+
a :data:`MathDocument`. This receives the HTML document that it is to
51+
process, and the input and output jax to be used in processing that
52+
page, along with any configuration options to control that processing.
53+
The individual expressions are representing internally using
54+
:data:`MathItem` objects that hold pointers to the locations of the
55+
math, the math strings to be processed, and other information needed
56+
by MathJax to handle the individual expressions.
57+
58+
These :data:`MathItem` objects are stored in a list within the
59+
:data:`MathDocument` so that they can be reprocessed, if needed. For
60+
example, changes in the MathJax contextual menu may require that the
61+
math be reprocessed, e.g., if the renderer is changed, of if speech
62+
settings change.
63+
64+
This list must be kept up to date, so if you remove sections of the
65+
page that may contain mathematics, you should inform MathJax of that
66+
beforehand. The :ref:`typeset-clear` section discusses this in more
67+
detail. Note that if you typeset expressions by hand using the
68+
:ref:`conversion functions <convert-math>`, they will not be added
69+
into the math list, and so will not participate in any changes request
70+
by the contextual menu.
71+
72+
73+
The components of MathJax
74+
=========================
75+
76+
The main components of MathJax are its input and output jax, the
77+
MathDocument, which coordinates the actions of the other components.
78+
79+
**Input jax**
80+
These are associated with the different input formats (TeX/LaTeX,
81+
MathML, and AsciiMath), and includes information about what
82+
delimiters it uses, and how to locate math within the document.
83+
The main role of the input jax is to convert the math notation
84+
entered by the author into the internal format used by MathJax,
85+
which is essentially MathML (represented as JavaScript objects).
86+
So an input jax acts as a translator of its mathematical notation
87+
into MathML.
88+
89+
**Input extensions**
90+
A number of extensions are available for the TeX input jax that
91+
implement optional LaTeX macros or features. The MathJax
92+
configuration object can be used to load them explicitly, or the
93+
:ref:`tex-autoload` extension may load some of them automatically
94+
when they are needed. The non-standard ``\require`` macro can be
95+
used to load an extension by name from within a typeset expression
96+
(see the :ref:`tex-require` page). The :ref:`extension-list`
97+
gives the names of the various extensions and links to their
98+
descriptions and configuration options. See the
99+
:ref:`tex-extensions` section for information about loading
100+
extensions and configuring the TeX input jax to include them.
101+
102+
The MathML input jax also supports extensions, though there
103+
currently is only one, the `mml3` extension that gives
104+
experimental support for the MathML3 `elementary math
105+
<https://www.w3.org/TR/MathML3/chapter3.html#presm.elementary>`__
106+
tags. See the :ref:`mml3 <mathml-mml3>` section for details.
107+
108+
**Output jax**
109+
These convert the internal MathML format into a specific output
110+
format. For example, the CHTML output jax uses HTML with CSS
111+
styling to lay out the mathematics, while the SVG output jax use
112+
Scalable Vector Graphic (SVG) elements to do so. Output jax could
113+
be produced that render the mathematics using HTML5 canvas
114+
elements, for example. The MathJax contextual menu can be used to
115+
switch between the output jax that are available.
116+
117+
**Fonts**
118+
In v4, several different fonts are available for the output jax.
119+
See the :ref:`font-support` section for details. The tools for
120+
creating the data needed by MathJax to support a font will be made
121+
available so that page authors can their own fonts or font
122+
extensions for use with MathJax.
123+
124+
**Contextual Menu**
125+
This component gives the reader access to several important
126+
informational options (such as viewing or copying the mathematical
127+
notation, or generating an SVG image from an expression), along
128+
with options that modify how MathJax operates. These include
129+
control over how long lines are treated, which render to use, and
130+
whether speech or other assistive extensions are to be activated.
131+
While it is possible to disable the MathJax contextual menu, doing
132+
so will impair the ability of your users to control MathJax, and
133+
in particular, users with accessibility needs may not be able to
134+
make the changes they need to support their particular
135+
disabilities.
136+
137+
**MathDocument**
138+
This is the internal object that handles the coordination of all
139+
of MathJax actions on a particular HTML page. It contains the
140+
input and output jax that are in use, and maintains a list of the
141+
expressions that have been typeset in the page. It maintains a
142+
list of actions to take when the page, or a portion of it, is to
143+
be typeset (see the :ref:`renderActions <document-renderactions>`
144+
description for details). For applications using the
145+
:ref:`MathJax Components framework <web-components>`,
146+
:data:`MathJax.startup.document` gives the :data:`MathDocument`
147+
instance being used.
148+
149+
150+
.. _api-documentation:
151+
152+
The MathJax API Documentation
153+
=============================
154+
155+
Many of the important details about the MathJax Application
156+
Programming Interface (API) are described within these documentation
157+
pages, but certainly not every function and object within the MathJax
158+
code.
159+
160+
The :ref:`web-examples` and :ref:`node-examples` pages give links to
161+
most of the examples within these documentation pages that illustrate
162+
the MathJax API, along with links to repositories containing more
163+
examples of web-based and node-based applications.
164+
165+
The MathJax `source code <https://github.com/mathjax/MathJax-src>`__
166+
internals are documented using jsDoc comments, and the resulting HTML
167+
pages are `available <https://mathjax.github.io/MathJax-src>`__ on
168+
line.
169+
8170

9171
|-----|

0 commit comments

Comments
 (0)