More of Carol's typo corrections. She probably has two more days to go!

This commit is contained in:
Davide P. Cervone 2011-03-21 20:21:00 -04:00
parent fe11cb9807
commit 683fa0291d
25 changed files with 174 additions and 170 deletions

View File

@ -25,9 +25,9 @@ callback specifications as arguments and return callback structures.
These routines always will return a callback even when none was
specified in the arguments, and in that case, the callback is a "do
nothing" callback. The reason for this is so that the resulting
callback can be used can be used in a `MathJax.Callback.Queue` for
synchronization purposes, so that the actions following it in the
queue will not be performed until after the callback has been fired.
callback can be used in a `MathJax.Callback.Queue` for synchronization
purposes, so that the actions following it in the queue will not be
performed until after the callback has been fired.
For example, the :meth:`MathJax.Ajax.Require()` method can be used to
load external files, and it returns a callback that is called when the
@ -36,7 +36,7 @@ and wait for them all to be loaded before performing some action, you
can create a `Queue` into which you push the results of the
:meth:`MathJax.Ajax.Require()` calls, and then push a callback for the
action. The final action will not be performed until all the
file-load callbacks (which preceed it int he queue) have been called;
file-load callbacks (which precede it in the queue) have been called;
i.e., the action will not occur until all the files are loaded.
@ -124,7 +124,7 @@ For example,
creates an object that contains three items, a `firstname`, and
`lastname`, and a method that shows the person's full name in an
alert. So ``aPerson.fullName()`` would cause an alert with the text
alert. So ``aPerson.showName()`` would cause an alert with the text
``John Smith`` to appear. Note, however that this only works if the
method is called as ``aPerson.showName()``; if instead you did
@ -182,7 +182,7 @@ well by including them in the array that specifies the callback:
MathJax.Ajax.Require("filename",["method",object,arg1,arg2,...]);
This approach is useful when you are pushing a callback for one one
This approach is useful when you are pushing a callback for one of
MathJax's Hub routines into the MathJax processing queue. For example,
.. code-block:: javascript
@ -221,7 +221,7 @@ you. For example,
.. code-block:: javascript
function myTimer (x) {alert("x = "+x)}
function f(x) {alert("x = "+x)}
setTimeout(MathJax.Callback([f,"Hello World!"]),500);
would create a callback that calls ``f("Hello World!")``, and

View File

@ -45,7 +45,7 @@ Here is an example of how to load and configure MathJax dynamically:
You can adjust the ``config`` variable to your needs, but be careful to get
the commas right. The ``window.opera`` test is because some versions of
Opera doesn't handle setting ``script.text`` properly, while Internet
Opera don't handle setting ``script.text`` properly, while Internet
Explorer doesn't handle setting the ``innerHTML`` of a script tag.
Here is a version that uses the ``config=filename`` method to
@ -97,9 +97,9 @@ server-based copy. The MathJax CDN works nicely for this.
----
Here is a script that runs MathJax in any document that contains
MathML (whether its includes MathJax or not). That allows
MathML (whether it includes MathJax or not). That allows
browsers that don't have native MathML support to view any web pages
with MathML, even if they say it only works in Forefox and
with MathML, even if they say it only works in Firefox and
IE+MathPlayer.
.. code-block:: javascript

View File

@ -38,7 +38,7 @@ preprocessors for :ref:`TeX notation <TeX-support>`, :ref:`MathML
notation <MathML-support>`, and the :ref:`jsMath notation
<jsMath-support>` that uses `span` and `div` tags.
For pages that are constructed programatically, such as HTML
For pages that are constructed programmatically, such as HTML
pages that result from running a processor on text in some other
format (e.g., pages produced from Markdown documents, or via programs
like `tex4ht`), it would be best to use MathJax's special tags
@ -46,7 +46,7 @@ directly, as described below, rather than having MathJax run
another preprocessor. This will speed up the final display of the
mathematics, since the extra preprocessing step would not be needed,
and it also avoids the conflict between the use of the less-than sign,
``<``, in mathematics and asn an HTML special character (that starts
``<``, in mathematics and as an HTML special character (that starts
an HTML tag).
@ -192,21 +192,21 @@ by MathJax (called an `element jax`). This internal format is
essentially MathML (represented as JavaScript objects), so an input
jax acts as a translator into MathML.
**Output jax** convert that internal element jax format into a specific
output format. For example, the NativeMML output jax inserts MathML
tags into the page to represent the mathematics, while the HTML-CSS
output jax uses HTML with CSS styling to lay out the mathematics so
that it can be displayed even in browsers that dont understand
MathML. Output jax could be produced that render the mathematics
using SVG, for example, or that speak an equation for the blind
users. The MathJax contextual menu can be used to switch between the
output jax that are available.
**Output jax** convert that internal element jax format into a
specific output format. For example, the NativeMML output jax inserts
MathML tags into the page to represent the mathematics, while the
HTML-CSS output jax uses HTML with CSS styling to lay out the
mathematics so that it can be displayed even in browsers that don't
understand MathML. Output jax could be produced that render the
mathematics using SVG, for example, or that speak an equation for
blind users. The MathJax contextual menu can be used to switch
between the output jax that are available.
Each input and output jax has a small configuration file that is
loaded when that input jax is included in the `jax` array in the
MathJax configuration, and a larger file that implements the core
functionality of that particular jax. The latter file is loaded
when the first time the jax is needed by MathJax to process some
the first time the jax is needed by MathJax to process some
mathematics.
The **MathJax Hub** keeps track of the internal representations of the

View File

@ -8,7 +8,7 @@ The `callback queue` is one of MathJax's main tools for synchronizing
its actions, both internally, and with external programs, like
javascript code that you may write as part of dynamic web pages.
Because many actions in MathJax (like loading files) operate
asynchornously, MathJax needs a way to coordinate those actions so
asynchronously, MathJax needs a way to coordinate those actions so
that they occur in the right order. The
`MathJax.Callback.Queue` object provides that mechanism.
@ -69,11 +69,11 @@ that could operate asynchronously. For example:
[f, 2]
);
Here, the command ``MathJax.Ajax.require("extensions/AMSmath.js")`` is
queued between two calls to ``f``. The first call to ``f(1)`` will be
made immediately, then the :meth:`MathJax.Ajax.Require` statement will
be performed. Since the ``Require`` method loads a file, it operates
asynchronously, and its return value is a `MathJax.Callback`
Here, the command ``MathJax.Ajax.Require("[MathJax]/extensions/AMSmath.js")``
is queued between two calls to ``f``. The first call to ``f(1)`` will
be made immediately, then the :meth:`MathJax.Ajax.Require` statement
will be performed. Since the ``Require`` method loads a file, it
operates asynchronously, and its return value is a `MathJax.Callback`
object that will be called when the file is loaded. The call to
``f(2)`` will not be made until that callback is performed,
effectively synchronizing the second call to ``f`` with the completion
@ -197,13 +197,13 @@ instead are defined in extensions that are loaded automatically when
needed. The typesetting of an expression containing one of these TeX
commands can cause the typesetting process to be suspended while the
file is loaded, and then restarted when the extension has become
evailable.
available.
As a result, any call to :meth:`MathJax.Hub.Typeset()` (or
:meth:`MathJax.Hub.Process()`, or :meth:`MathJax.Hub.Update()`, etc.)
could return long before the mathematics is actually typeset, and the
rest of your code may run before the mathematics is available. If you
have code that relys on the mathematics being visible on screen, you
have code that relies on the mathematics being visible on screen, you
will need to break that out into a separate operation that is
synchronized with the typesetting via the MathJax queue.

View File

@ -5,7 +5,7 @@ Using Signals
*************
Because much of MathJax operates asynchronously, it is important for
MathJax to be able to indicated to other components operating on the
MathJax to be able to indicate to other components operating on the
page that certain actions have been taken. For example, as MathJax is
starting up, it loads external files such as its configuration files
and the various input and output :term:`jax` that are used on the
@ -59,7 +59,7 @@ have the listener perform the configuration when the message arrives.
But even if the extension *has* already been loaded, this will still
work, because the listener will receive the ready signal even if it
has already been posted. In this way, listening for signals is a
robust method of synchonizing code components no matter when they are
robust method of synchronizing code components no matter when they are
loaded and run.
In some cases, it may be inappropriate for a new listener to receive
@ -106,7 +106,7 @@ details of the messages sent during startup. See also the
``test/sample-signals.html`` file (and its source) for examples of
using signals. This example lists all the signals that occur while
MathJax is processing that page, so it gives useful information about
the details of the signals produced by variuous components.
the details of the signals produced by various components.
In this example, the listener starts loading an extra configuration
file (from the same directory as the web page). Since it returns

View File

@ -154,7 +154,7 @@ are requested simultaneously, so they load concurrently. That means they
can load in any order, and that the begin and end signals for the jax and
extensions can be intermixed. (In general, you will get `Begin Jax`
followed by `Begin Extensions`, but the order of `End Jax` and `End
Extensions` will depend on the file sbeing loaded.) Both 5 and 6 must
Extensions` will depend on the files being loaded.) Both 5 and 6 must
complete, however, before 7 will be performed.
See the ``test/sample-signals.html`` file to see the signals in action.
See the ``test/sample-signals.html`` file to see the signals in action.

View File

@ -22,14 +22,14 @@ initiates an action, waits for it to complete, and then goes on, you
break the function into two parts: a first part that sets up and
initiates the action, and a second that runs after the action is
finished. Callbacks are similar to event handlers that you attach to
DOM elements, and are called when an certain action occurs. See the
DOM elements, and are called when a certain action occurs. See the
:ref:`Callback Object <api-callback>` reference page for details of
how to specify a callback.
**Queues** are MathJax's means of synchronizing actions that must be
performed sequentially, even when they involve asynchronous events
like loading files or dynamically creating stylesheets. The actions
that you put in the queue are `Callback` objects that will be perfomed
that you put in the queue are `Callback` objects that will be performed
in sequence, with MathJax handling the linking of one action to the
next. MathJax maintains a master queue that you can use to
synchronize with MathJax, but you can also create your own private
@ -47,7 +47,7 @@ will call your code. This works somewhat like an event handler, except
that many different types of events can go through the same signal, and the
signals have a "memory", meaning that if you register an interest in a
particular type of signal and that signal has already occurred, you will be
told about the past occurrances as well as any future ones. See the
told about the past occurrences as well as any future ones. See the
:ref:`Signal Object <api-signal>` reference page for more details. See
also the ``test/sample-signals.html`` file in the MathJax ``test``
directory for a working example of using signals.

View File

@ -19,7 +19,7 @@ MathJax operates asynchonously (see :ref:`Synchronizing with MathJax
your call to :meth:`MathJax.Hub.Typeset()` is synchronized with the
other actions that MathJax is taking. For example, it may already be
typesetting portions of the page, or it may be waiting for an output
jax to load, etc., and so you need to queue to typeset action to be
jax to load, etc., and so you need to queue the typeset action to be
performed after MathJax has finished whatever else it may be doing.
That may be immediately, but it may not, and there is no way to tell.
@ -32,13 +32,13 @@ To queue the typeset action, use the command
This will cause MathJax to typeset the page when it is next able to do
so. It guarantees that the typesetting will synchronize properly
with the loading of jax, extensions, fonts, stylesheets, and other
asynchornous activity, and is the only truely safe way to ask MathJax
asynchronous activity, and is the only truly safe way to ask MathJax
to process additional material.
The :meth:`MathJax.Hub.Typeset()` command also accepts a parameter
that is a DOM element whose contents is to be typeset. That could be
that is a DOM element whose content is to be typeset. That could be
a paragraph, or a ``<div>`` element, or even a MathJax math
``<script>`` tag. It could also be a the DOM `id` of such an object, in
``<script>`` tag. It could also be the DOM `id` of such an object, in
which case, MathJax will look up the DOM element for you. So
.. code-block:: javascript
@ -60,7 +60,7 @@ Note that the :meth:`MathJax.Hub.Queue()` method will return
immediately, regardless of whether the typesetting has taken place or
not, so you can not assume that the mathematics is visible after you
make this call. That means that things like the size of the container
for the mathematics may not yet reflect the size of the typeet
for the mathematics may not yet reflect the size of the typeset
mathematics. If you need to perform actions that depend on the
mathematics being typeset, you should push *those* actions onto the
``MathJax.Hub.queue`` as well.
@ -78,7 +78,7 @@ Manipulating Individual Math Elements
If you are not changing a complete DOM structure, but simply want to
update the contents of a single mathematical equation, you do not need
to use ``innerHTML`` and :meth:`MathJax.Hub.Typeset()` to preprocess
and process an elements new content. Instead, you can ask MathJax to
and process an element's new content. Instead, you can ask MathJax to
find the `element jax` for the math element on the page, and use its
methods to modify and update the mathematics that it displays.
@ -95,7 +95,7 @@ within dollar signs (it will be blank). A student has typed
something elsewhere on the page, and you want to typeset their answer
in the location of the mathematics that is already there. You could
replace the entire contents of the `MathDiv` element and call
:meth:`MathJax.Hub.Typeset()` as described above, but there is more
:meth:`MathJax.Hub.Typeset()` as described above, but there is a more
efficient approach, which is to ask MathJax for the element jax for
the mathematics, and call its method for replacing the formula shown
by that element. For example:
@ -105,20 +105,21 @@ by that element. For example:
var math = MathJax.Hub.getAllJax("MathDiv")[0];
MathJax.Hub.Queue(["Text",math,"x+1"]);
This looks up the list of math elements in `MathDiv` element (there is
only one) and takes the first one (element 0) and stores it in
``math``. This is an `element jax` object (see the :ref:`Element Jax
<api-element-jax>` specification for details), which has a
This looks up the list of math elements in the `MathDiv` element
(there is only one) and takes the first one (element 0) and stores it
in ``math``. This is an `element jax` object (see the :ref:`Element
Jax <api-element-jax>` specification for details), which has a
:meth:`Text()` method that can be used to set the input text of the
math element, and retypeset it.
Again, since the typesetting should be synchronized with other actions
of MathJax, the call should be pushed onto the ``MathJax.Hub.queue``,
as shown above, rather than called directly. The example above
performs the equivalent of ``math.Text("x+1")`` as soon as MathJax is
able to do so. Any additional actions the rely on the equation
``x+1`` actually showing on screen should also be pushed onto the
queue so that they will not occur before the math is typeset.
of MathJax, the call should be pushed onto the MathJax processing
queue using :meth:`MathJax.Hub.Queue()`, as shown above, rather than
called directly. The example above performs the equivalent of
``math.Text("x+1")`` as soon as MathJax is able to do so. Any
additional actions that rely on the expression ``x+1`` actually
showing on screen should also be pushed onto the queue so that they
will not occur before the math is typeset.
The actions you can perform on an element jax include:
@ -140,7 +141,7 @@ The actions you can perform on an element jax include:
.. describe:: SourceElement()
to obtain a reference to the original
``<script>`` object that is assocaited with this element jax.
``<script>`` object that is associated with this element jax.
Note that once you have located an element jax, you can keep using it
@ -153,7 +154,7 @@ displayed.
To get the element jax the first time, you need to be sure that you
ask MathJax for it **after** MathJax has processed the page the first
time. This is another sitaution where you want to use the MathJax
time. This is another situation where you want to use the MathJax
queue. If your startup code performs the commands
.. code-block:: javascript

View File

@ -72,9 +72,9 @@ callback specifications as arguments and return callback structures.
These routines always will return a callback even when none was
specified in the arguments, and in that case, the callback is a &#8220;do
nothing&#8221; callback. The reason for this is so that the resulting
callback can be used can be used in a <cite>MathJax.Callback.Queue</cite> for
synchronization purposes, so that the actions following it in the
queue will not be performed until after the callback has been fired.</p>
callback can be used in a <cite>MathJax.Callback.Queue</cite> for synchronization
purposes, so that the actions following it in the queue will not be
performed until after the callback has been fired.</p>
<p>For example, the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.Require()</span></tt> method can be used to
load external files, and it returns a callback that is called when the
file has been loaded and executed. If you want to load several files
@ -82,7 +82,7 @@ and wait for them all to be loaded before performing some action, you
can create a <cite>Queue</cite> into which you push the results of the
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.Require()</span></tt> calls, and then push a callback for the
action. The final action will not be performed until all the
file-load callbacks (which preceed it int he queue) have been called;
file-load callbacks (which precede it in the queue) have been called;
i.e., the action will not occur until all the files are loaded.</p>
<div class="section" id="specifying-a-callback">
<h2>Specifying a Callback<a class="headerlink" href="#specifying-a-callback" title="Permalink to this headline"></a></h2>
@ -151,7 +151,7 @@ the object without knowing explicitly where the object is stored.</p>
</div>
<p>creates an object that contains three items, a <cite>firstname</cite>, and
<cite>lastname</cite>, and a method that shows the person&#8217;s full name in an
alert. So <tt class="docutils literal"><span class="pre">aPerson.fullName()</span></tt> would cause an alert with the text
alert. So <tt class="docutils literal"><span class="pre">aPerson.showName()</span></tt> would cause an alert with the text
<tt class="docutils literal"><span class="pre">John</span> <span class="pre">Smith</span></tt> to appear. Note, however that this only works if the
method is called as <tt class="docutils literal"><span class="pre">aPerson.showName()</span></tt>; if instead you did</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">aPerson</span><span class="p">.</span><span class="nx">showName</span><span class="p">;</span> <span class="c1">// assign f the function from aPerson</span>
@ -197,7 +197,7 @@ well by including them in the array that specifies the callback:</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Ajax</span><span class="p">.</span><span class="nx">Require</span><span class="p">(</span><span class="s2">&quot;filename&quot;</span><span class="p">,[</span><span class="s2">&quot;method&quot;</span><span class="p">,</span><span class="nx">object</span><span class="p">,</span><span class="nx">arg1</span><span class="p">,</span><span class="nx">arg2</span><span class="p">,...]);</span>
</pre></div>
</div>
<p>This approach is useful when you are pushing a callback for one one
<p>This approach is useful when you are pushing a callback for one of
MathJax&#8217;s Hub routines into the MathJax processing queue. For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Queue</span><span class="p">([</span><span class="s2">&quot;Typeset&quot;</span><span class="p">,</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">,</span><span class="s2">&quot;MathDiv&quot;</span><span class="p">]);</span>
</pre></div>
@ -227,7 +227,7 @@ when it is called, Internet Explorer does not implement that feature,
so you can&#8217;t rely on it.) You can use a <cite>Callback</cite> object to
do this, and the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Callback()</span></tt> method will create one for
you. For example,</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">myTimer</span> <span class="p">(</span><span class="nx">x</span><span class="p">)</span> <span class="p">{</span><span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;x = &quot;</span><span class="o">+</span><span class="nx">x</span><span class="p">)}</span>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">function</span> <span class="nx">f</span><span class="p">(</span><span class="nx">x</span><span class="p">)</span> <span class="p">{</span><span class="nx">alert</span><span class="p">(</span><span class="s2">&quot;x = &quot;</span><span class="o">+</span><span class="nx">x</span><span class="p">)}</span>
<span class="nx">setTimeout</span><span class="p">(</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Callback</span><span class="p">([</span><span class="nx">f</span><span class="p">,</span><span class="s2">&quot;Hello World!&quot;</span><span class="p">]),</span><span class="mi">500</span><span class="p">);</span>
</pre></div>
</div>

View File

@ -88,7 +88,7 @@ configuration.</p>
</div>
<p>You can adjust the <tt class="docutils literal"><span class="pre">config</span></tt> variable to your needs, but be careful to get
the commas right. The <tt class="docutils literal"><span class="pre">window.opera</span></tt> test is because some versions of
Opera doesn&#8217;t handle setting <tt class="docutils literal"><span class="pre">script.text</span></tt> properly, while Internet
Opera don&#8217;t handle setting <tt class="docutils literal"><span class="pre">script.text</span></tt> properly, while Internet
Explorer doesn&#8217;t handle setting the <tt class="docutils literal"><span class="pre">innerHTML</span></tt> of a script tag.</p>
<p>Here is a version that uses the <tt class="docutils literal"><span class="pre">config=filename</span></tt> method to
configure MathJax:</p>
@ -132,9 +132,9 @@ script load a local copy of MathJax, so you have to refer to a
server-based copy. The MathJax CDN works nicely for this.</p>
<hr class="docutils" />
<p>Here is a script that runs MathJax in any document that contains
MathML (whether its includes MathJax or not). That allows
MathML (whether it includes MathJax or not). That allows
browsers that don&#8217;t have native MathML support to view any web pages
with MathML, even if they say it only works in Forefox and
with MathML, even if they say it only works in Firefox and
IE+MathPlayer.</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="c1">// ==UserScript==</span>
<span class="c1">// @name MathJax MathML</span>

View File

@ -82,7 +82,7 @@ run a preprocessor to locate the math delimiters and replace them by
the special tags that it uses to mark the formulas. There are
preprocessors for <a class="reference internal" href="tex.html#tex-support"><em>TeX notation</em></a>, <a class="reference internal" href="mathml.html#mathml-support"><em>MathML
notation</em></a>, and the <a class="reference internal" href="jsMath.html#jsmath-support"><em>jsMath notation</em></a> that uses <cite>span</cite> and <cite>div</cite> tags.</p>
<p>For pages that are constructed programatically, such as HTML
<p>For pages that are constructed programmatically, such as HTML
pages that result from running a processor on text in some other
format (e.g., pages produced from Markdown documents, or via programs
like <cite>tex4ht</cite>), it would be best to use MathJax&#8217;s special tags
@ -90,7 +90,7 @@ directly, as described below, rather than having MathJax run
another preprocessor. This will speed up the final display of the
mathematics, since the extra preprocessing step would not be needed,
and it also avoids the conflict between the use of the less-than sign,
<tt class="docutils literal"><span class="pre">&lt;</span></tt>, in mathematics and asn an HTML special character (that starts
<tt class="docutils literal"><span class="pre">&lt;</span></tt>, in mathematics and as an HTML special character (that starts
an HTML tag).</p>
<div class="section" id="how-mathematics-is-stored-in-the-page">
<span id="mathjax-script-tags"></span><h2>How mathematics is stored in the page<a class="headerlink" href="#how-mathematics-is-stored-in-the-page" title="Permalink to this headline"></a></h2>
@ -209,20 +209,20 @@ the math notation entered by the author into the internal format used
by MathJax (called an <cite>element jax</cite>). This internal format is
essentially MathML (represented as JavaScript objects), so an input
jax acts as a translator into MathML.</p>
<p><strong>Output jax</strong> convert that internal element jax format into a specific
output format. For example, the NativeMML output jax inserts MathML
tags into the page to represent the mathematics, while the HTML-CSS
output jax uses HTML with CSS styling to lay out the mathematics so
that it can be displayed even in browsers that dont understand
MathML. Output jax could be produced that render the mathematics
using SVG, for example, or that speak an equation for the blind
users. The MathJax contextual menu can be used to switch between the
output jax that are available.</p>
<p><strong>Output jax</strong> convert that internal element jax format into a
specific output format. For example, the NativeMML output jax inserts
MathML tags into the page to represent the mathematics, while the
HTML-CSS output jax uses HTML with CSS styling to lay out the
mathematics so that it can be displayed even in browsers that don&#8217;t
understand MathML. Output jax could be produced that render the
mathematics using SVG, for example, or that speak an equation for
blind users. The MathJax contextual menu can be used to switch
between the output jax that are available.</p>
<p>Each input and output jax has a small configuration file that is
loaded when that input jax is included in the <cite>jax</cite> array in the
MathJax configuration, and a larger file that implements the core
functionality of that particular jax. The latter file is loaded
when the first time the jax is needed by MathJax to process some
the first time the jax is needed by MathJax to process some
mathematics.</p>
<p>The <strong>MathJax Hub</strong> keeps track of the internal representations of the
various mathematical equations on the page, and can be queried to

View File

@ -57,7 +57,7 @@
its actions, both internally, and with external programs, like
javascript code that you may write as part of dynamic web pages.
Because many actions in MathJax (like loading files) operate
asynchornously, MathJax needs a way to coordinate those actions so
asynchronously, MathJax needs a way to coordinate those actions so
that they occur in the right order. The
<cite>MathJax.Callback.Queue</cite> object provides that mechanism.</p>
<p>A <cite>callback queue</cite> is a list of commands that will be performed one at
@ -109,11 +109,11 @@ that could operate asynchronously. For example:</p>
<span class="p">);</span>
</pre></div>
</div>
<p>Here, the command <tt class="docutils literal"><span class="pre">MathJax.Ajax.require(&quot;extensions/AMSmath.js&quot;)</span></tt> is
queued between two calls to <tt class="docutils literal"><span class="pre">f</span></tt>. The first call to <tt class="docutils literal"><span class="pre">f(1)</span></tt> will be
made immediately, then the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.Require()</span></tt> statement will
be performed. Since the <tt class="docutils literal"><span class="pre">Require</span></tt> method loads a file, it operates
asynchronously, and its return value is a <cite>MathJax.Callback</cite>
<p>Here, the command <tt class="docutils literal"><span class="pre">MathJax.Ajax.Require(&quot;[MathJax]/extensions/AMSmath.js&quot;)</span></tt>
is queued between two calls to <tt class="docutils literal"><span class="pre">f</span></tt>. The first call to <tt class="docutils literal"><span class="pre">f(1)</span></tt> will
be made immediately, then the <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Ajax.Require()</span></tt> statement
will be performed. Since the <tt class="docutils literal"><span class="pre">Require</span></tt> method loads a file, it
operates asynchronously, and its return value is a <cite>MathJax.Callback</cite>
object that will be called when the file is loaded. The call to
<tt class="docutils literal"><span class="pre">f(2)</span></tt> will not be made until that callback is performed,
effectively synchronizing the second call to <tt class="docutils literal"><span class="pre">f</span></tt> with the completion
@ -218,12 +218,12 @@ instead are defined in extensions that are loaded automatically when
needed. The typesetting of an expression containing one of these TeX
commands can cause the typesetting process to be suspended while the
file is loaded, and then restarted when the extension has become
evailable.</p>
available.</p>
<p>As a result, any call to <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> (or
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Process()</span></tt>, or <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Update()</span></tt>, etc.)
could return long before the mathematics is actually typeset, and the
rest of your code may run before the mathematics is available. If you
have code that relys on the mathematics being visible on screen, you
have code that relies on the mathematics being visible on screen, you
will need to break that out into a separate operation that is
synchronized with the typesetting via the MathJax queue.</p>
<p>Furthermore, your own typesetting calls may need to wait for file loading

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@
<div class="section" id="using-signals">
<span id="id1"></span><h1>Using Signals<a class="headerlink" href="#using-signals" title="Permalink to this headline"></a></h1>
<p>Because much of MathJax operates asynchronously, it is important for
MathJax to be able to indicated to other components operating on the
MathJax to be able to indicate to other components operating on the
page that certain actions have been taken. For example, as MathJax is
starting up, it loads external files such as its configuration files
and the various input and output <a class="reference internal" href="glossary.html#term-jax"><em class="xref std std-term">jax</em></a> that are used on the
@ -105,7 +105,7 @@ have the listener perform the configuration when the message arrives.
But even if the extension <em>has</em> already been loaded, this will still
work, because the listener will receive the ready signal even if it
has already been posted. In this way, listening for signals is a
robust method of synchonizing code components no matter when they are
robust method of synchronizing code components no matter when they are
loaded and run.</p>
<p>In some cases, it may be inappropriate for a new listener to receive
past messages that were sent to a signal object. There are two ways to
@ -145,7 +145,7 @@ details of the messages sent during startup. See also the
<tt class="docutils literal"><span class="pre">test/sample-signals.html</span></tt> file (and its source) for examples of
using signals. This example lists all the signals that occur while
MathJax is processing that page, so it gives useful information about
the details of the signals produced by variuous components.</p>
the details of the signals produced by various components.</p>
<p>In this example, the listener starts loading an extra configuration
file (from the same directory as the web page). Since it returns
the callback from that request, the signal processing will wait until

View File

@ -191,7 +191,7 @@ are requested simultaneously, so they load concurrently. That means they
can load in any order, and that the begin and end signals for the jax and
extensions can be intermixed. (In general, you will get <cite>Begin Jax</cite>
followed by <cite>Begin Extensions</cite>, but the order of <cite>End Jax</cite> and <cite>End
Extensions</cite> will depend on the file sbeing loaded.) Both 5 and 6 must
Extensions</cite> will depend on the files being loaded.) Both 5 and 6 must
complete, however, before 7 will be performed.</p>
<p>See the <tt class="docutils literal"><span class="pre">test/sample-signals.html</span></tt> file to see the signals in action.</p>
</div>

View File

@ -68,13 +68,13 @@ initiates an action, waits for it to complete, and then goes on, you
break the function into two parts: a first part that sets up and
initiates the action, and a second that runs after the action is
finished. Callbacks are similar to event handlers that you attach to
DOM elements, and are called when an certain action occurs. See the
DOM elements, and are called when a certain action occurs. See the
<a class="reference internal" href="api/callback.html#api-callback"><em>Callback Object</em></a> reference page for details of
how to specify a callback.</p>
<p><strong>Queues</strong> are MathJax&#8217;s means of synchronizing actions that must be
performed sequentially, even when they involve asynchronous events
like loading files or dynamically creating stylesheets. The actions
that you put in the queue are <cite>Callback</cite> objects that will be perfomed
that you put in the queue are <cite>Callback</cite> objects that will be performed
in sequence, with MathJax handling the linking of one action to the
next. MathJax maintains a master queue that you can use to
synchronize with MathJax, but you can also create your own private
@ -91,7 +91,7 @@ will call your code. This works somewhat like an event handler, except
that many different types of events can go through the same signal, and the
signals have a &#8220;memory&#8221;, meaning that if you register an interest in a
particular type of signal and that signal has already occurred, you will be
told about the past occurrances as well as any future ones. See the
told about the past occurrences as well as any future ones. See the
<a class="reference internal" href="api/signal.html#api-signal"><em>Signal Object</em></a> reference page for more details. See
also the <tt class="docutils literal"><span class="pre">test/sample-signals.html</span></tt> file in the MathJax <tt class="docutils literal"><span class="pre">test</span></tt>
directory for a working example of using signals.</p>

View File

@ -64,7 +64,7 @@ MathJax operates asynchonously (see <a class="reference internal" href="synchron
your call to <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> is synchronized with the
other actions that MathJax is taking. For example, it may already be
typesetting portions of the page, or it may be waiting for an output
jax to load, etc., and so you need to queue to typeset action to be
jax to load, etc., and so you need to queue the typeset action to be
performed after MathJax has finished whatever else it may be doing.
That may be immediately, but it may not, and there is no way to tell.</p>
<p>To queue the typeset action, use the command</p>
@ -74,12 +74,12 @@ That may be immediately, but it may not, and there is no way to tell.</p>
<p>This will cause MathJax to typeset the page when it is next able to do
so. It guarantees that the typesetting will synchronize properly
with the loading of jax, extensions, fonts, stylesheets, and other
asynchornous activity, and is the only truely safe way to ask MathJax
asynchronous activity, and is the only truly safe way to ask MathJax
to process additional material.</p>
<p>The <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> command also accepts a parameter
that is a DOM element whose contents is to be typeset. That could be
that is a DOM element whose content is to be typeset. That could be
a paragraph, or a <tt class="docutils literal"><span class="pre">&lt;div&gt;</span></tt> element, or even a MathJax math
<tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> tag. It could also be a the DOM <cite>id</cite> of such an object, in
<tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> tag. It could also be the DOM <cite>id</cite> of such an object, in
which case, MathJax will look up the DOM element for you. So</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Queue</span><span class="p">([</span><span class="s2">&quot;Typeset&quot;</span><span class="p">,</span><span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">,</span><span class="s2">&quot;MathExample&quot;</span><span class="p">]);</span>
</pre></div>
@ -96,7 +96,7 @@ typeset.</p>
immediately, regardless of whether the typesetting has taken place or
not, so you can not assume that the mathematics is visible after you
make this call. That means that things like the size of the container
for the mathematics may not yet reflect the size of the typeet
for the mathematics may not yet reflect the size of the typeset
mathematics. If you need to perform actions that depend on the
mathematics being typeset, you should push <em>those</em> actions onto the
<tt class="docutils literal"><span class="pre">MathJax.Hub.queue</span></tt> as well.</p>
@ -110,7 +110,7 @@ of calling the functions that do what you want.</p>
<p>If you are not changing a complete DOM structure, but simply want to
update the contents of a single mathematical equation, you do not need
to use <tt class="docutils literal"><span class="pre">innerHTML</span></tt> and <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> to preprocess
and process an elements new content. Instead, you can ask MathJax to
and process an element&#8217;s new content. Instead, you can ask MathJax to
find the <cite>element jax</cite> for the math element on the page, and use its
methods to modify and update the mathematics that it displays.</p>
<p>For example, suppose you have the following HTML in your document</p>
@ -124,7 +124,7 @@ within dollar signs (it will be blank). A student has typed
something elsewhere on the page, and you want to typeset their answer
in the location of the mathematics that is already there. You could
replace the entire contents of the <cite>MathDiv</cite> element and call
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> as described above, but there is more
<tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Typeset()</span></tt> as described above, but there is a more
efficient approach, which is to ask MathJax for the element jax for
the mathematics, and call its method for replacing the formula shown
by that element. For example:</p>
@ -132,18 +132,20 @@ by that element. For example:</p>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Queue</span><span class="p">([</span><span class="s2">&quot;Text&quot;</span><span class="p">,</span><span class="nx">math</span><span class="p">,</span><span class="s2">&quot;x+1&quot;</span><span class="p">]);</span>
</pre></div>
</div>
<p>This looks up the list of math elements in <cite>MathDiv</cite> element (there is
only one) and takes the first one (element 0) and stores it in
<tt class="docutils literal"><span class="pre">math</span></tt>. This is an <cite>element jax</cite> object (see the <a class="reference internal" href="api/elementjax.html#api-element-jax"><em>Element Jax</em></a> specification for details), which has a
<p>This looks up the list of math elements in the <cite>MathDiv</cite> element
(there is only one) and takes the first one (element 0) and stores it
in <tt class="docutils literal"><span class="pre">math</span></tt>. This is an <cite>element jax</cite> object (see the <a class="reference internal" href="api/elementjax.html#api-element-jax"><em>Element
Jax</em></a> specification for details), which has a
<a class="reference internal" href="api/elementjax.html#Text" title="Text"><tt class="xref py py-meth docutils literal"><span class="pre">Text()</span></tt></a> method that can be used to set the input text of the
math element, and retypeset it.</p>
<p>Again, since the typesetting should be synchronized with other actions
of MathJax, the call should be pushed onto the <tt class="docutils literal"><span class="pre">MathJax.Hub.queue</span></tt>,
as shown above, rather than called directly. The example above
performs the equivalent of <tt class="docutils literal"><span class="pre">math.Text(&quot;x+1&quot;)</span></tt> as soon as MathJax is
able to do so. Any additional actions the rely on the equation
<tt class="docutils literal"><span class="pre">x+1</span></tt> actually showing on screen should also be pushed onto the
queue so that they will not occur before the math is typeset.</p>
of MathJax, the call should be pushed onto the MathJax processing
queue using <tt class="xref py py-meth docutils literal"><span class="pre">MathJax.Hub.Queue()</span></tt>, as shown above, rather than
called directly. The example above performs the equivalent of
<tt class="docutils literal"><span class="pre">math.Text(&quot;x+1&quot;)</span></tt> as soon as MathJax is able to do so. Any
additional actions that rely on the expression <tt class="docutils literal"><span class="pre">x+1</span></tt> actually
showing on screen should also be pushed onto the queue so that they
will not occur before the math is typeset.</p>
<p>The actions you can perform on an element jax include:</p>
<blockquote>
<div><dl class="describe">
@ -171,7 +173,7 @@ the original <tt class="docutils literal"><span class="pre">&lt;script&gt;</span
<dt>
<tt class="descname">SourceElement()</tt></dt>
<dd><p>to obtain a reference to the original
<tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> object that is assocaited with this element jax.</p>
<tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> object that is associated with this element jax.</p>
</dd></dl>
</div></blockquote>
@ -184,7 +186,7 @@ then use that result each time you adjust the mathematics to be
displayed.</p>
<p>To get the element jax the first time, you need to be sure that you
ask MathJax for it <strong>after</strong> MathJax has processed the page the first
time. This is another sitaution where you want to use the MathJax
time. This is another situation where you want to use the MathJax
queue. If your startup code performs the commands</p>
<div class="highlight-javascript"><div class="highlight"><pre><span class="kd">var</span> <span class="nx">studentDisplay</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
<span class="nx">MathJax</span><span class="p">.</span><span class="nx">Hub</span><span class="p">.</span><span class="nx">Queue</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>

View File

@ -25,9 +25,9 @@ callback specifications as arguments and return callback structures.
These routines always will return a callback even when none was
specified in the arguments, and in that case, the callback is a "do
nothing" callback. The reason for this is so that the resulting
callback can be used can be used in a `MathJax.Callback.Queue` for
synchronization purposes, so that the actions following it in the
queue will not be performed until after the callback has been fired.
callback can be used in a `MathJax.Callback.Queue` for synchronization
purposes, so that the actions following it in the queue will not be
performed until after the callback has been fired.
For example, the :meth:`MathJax.Ajax.Require()` method can be used to
load external files, and it returns a callback that is called when the
@ -36,7 +36,7 @@ and wait for them all to be loaded before performing some action, you
can create a `Queue` into which you push the results of the
:meth:`MathJax.Ajax.Require()` calls, and then push a callback for the
action. The final action will not be performed until all the
file-load callbacks (which preceed it int he queue) have been called;
file-load callbacks (which precede it in the queue) have been called;
i.e., the action will not occur until all the files are loaded.
@ -124,7 +124,7 @@ For example,
creates an object that contains three items, a `firstname`, and
`lastname`, and a method that shows the person's full name in an
alert. So ``aPerson.fullName()`` would cause an alert with the text
alert. So ``aPerson.showName()`` would cause an alert with the text
``John Smith`` to appear. Note, however that this only works if the
method is called as ``aPerson.showName()``; if instead you did
@ -182,7 +182,7 @@ well by including them in the array that specifies the callback:
MathJax.Ajax.Require("filename",["method",object,arg1,arg2,...]);
This approach is useful when you are pushing a callback for one one
This approach is useful when you are pushing a callback for one of
MathJax's Hub routines into the MathJax processing queue. For example,
.. code-block:: javascript
@ -221,7 +221,7 @@ you. For example,
.. code-block:: javascript
function myTimer (x) {alert("x = "+x)}
function f(x) {alert("x = "+x)}
setTimeout(MathJax.Callback([f,"Hello World!"]),500);
would create a callback that calls ``f("Hello World!")``, and

View File

@ -45,7 +45,7 @@ Here is an example of how to load and configure MathJax dynamically:
You can adjust the ``config`` variable to your needs, but be careful to get
the commas right. The ``window.opera`` test is because some versions of
Opera doesn't handle setting ``script.text`` properly, while Internet
Opera don't handle setting ``script.text`` properly, while Internet
Explorer doesn't handle setting the ``innerHTML`` of a script tag.
Here is a version that uses the ``config=filename`` method to
@ -97,9 +97,9 @@ server-based copy. The MathJax CDN works nicely for this.
----
Here is a script that runs MathJax in any document that contains
MathML (whether its includes MathJax or not). That allows
MathML (whether it includes MathJax or not). That allows
browsers that don't have native MathML support to view any web pages
with MathML, even if they say it only works in Forefox and
with MathML, even if they say it only works in Firefox and
IE+MathPlayer.
.. code-block:: javascript

View File

@ -38,7 +38,7 @@ preprocessors for :ref:`TeX notation <TeX-support>`, :ref:`MathML
notation <MathML-support>`, and the :ref:`jsMath notation
<jsMath-support>` that uses `span` and `div` tags.
For pages that are constructed programatically, such as HTML
For pages that are constructed programmatically, such as HTML
pages that result from running a processor on text in some other
format (e.g., pages produced from Markdown documents, or via programs
like `tex4ht`), it would be best to use MathJax's special tags
@ -46,7 +46,7 @@ directly, as described below, rather than having MathJax run
another preprocessor. This will speed up the final display of the
mathematics, since the extra preprocessing step would not be needed,
and it also avoids the conflict between the use of the less-than sign,
``<``, in mathematics and asn an HTML special character (that starts
``<``, in mathematics and as an HTML special character (that starts
an HTML tag).
@ -192,21 +192,21 @@ by MathJax (called an `element jax`). This internal format is
essentially MathML (represented as JavaScript objects), so an input
jax acts as a translator into MathML.
**Output jax** convert that internal element jax format into a specific
output format. For example, the NativeMML output jax inserts MathML
tags into the page to represent the mathematics, while the HTML-CSS
output jax uses HTML with CSS styling to lay out the mathematics so
that it can be displayed even in browsers that dont understand
MathML. Output jax could be produced that render the mathematics
using SVG, for example, or that speak an equation for the blind
users. The MathJax contextual menu can be used to switch between the
output jax that are available.
**Output jax** convert that internal element jax format into a
specific output format. For example, the NativeMML output jax inserts
MathML tags into the page to represent the mathematics, while the
HTML-CSS output jax uses HTML with CSS styling to lay out the
mathematics so that it can be displayed even in browsers that don't
understand MathML. Output jax could be produced that render the
mathematics using SVG, for example, or that speak an equation for
blind users. The MathJax contextual menu can be used to switch
between the output jax that are available.
Each input and output jax has a small configuration file that is
loaded when that input jax is included in the `jax` array in the
MathJax configuration, and a larger file that implements the core
functionality of that particular jax. The latter file is loaded
when the first time the jax is needed by MathJax to process some
the first time the jax is needed by MathJax to process some
mathematics.
The **MathJax Hub** keeps track of the internal representations of the

View File

@ -8,7 +8,7 @@ The `callback queue` is one of MathJax's main tools for synchronizing
its actions, both internally, and with external programs, like
javascript code that you may write as part of dynamic web pages.
Because many actions in MathJax (like loading files) operate
asynchornously, MathJax needs a way to coordinate those actions so
asynchronously, MathJax needs a way to coordinate those actions so
that they occur in the right order. The
`MathJax.Callback.Queue` object provides that mechanism.
@ -69,11 +69,11 @@ that could operate asynchronously. For example:
[f, 2]
);
Here, the command ``MathJax.Ajax.require("extensions/AMSmath.js")`` is
queued between two calls to ``f``. The first call to ``f(1)`` will be
made immediately, then the :meth:`MathJax.Ajax.Require` statement will
be performed. Since the ``Require`` method loads a file, it operates
asynchronously, and its return value is a `MathJax.Callback`
Here, the command ``MathJax.Ajax.Require("[MathJax]/extensions/AMSmath.js")``
is queued between two calls to ``f``. The first call to ``f(1)`` will
be made immediately, then the :meth:`MathJax.Ajax.Require` statement
will be performed. Since the ``Require`` method loads a file, it
operates asynchronously, and its return value is a `MathJax.Callback`
object that will be called when the file is loaded. The call to
``f(2)`` will not be made until that callback is performed,
effectively synchronizing the second call to ``f`` with the completion
@ -197,13 +197,13 @@ instead are defined in extensions that are loaded automatically when
needed. The typesetting of an expression containing one of these TeX
commands can cause the typesetting process to be suspended while the
file is loaded, and then restarted when the extension has become
evailable.
available.
As a result, any call to :meth:`MathJax.Hub.Typeset()` (or
:meth:`MathJax.Hub.Process()`, or :meth:`MathJax.Hub.Update()`, etc.)
could return long before the mathematics is actually typeset, and the
rest of your code may run before the mathematics is available. If you
have code that relys on the mathematics being visible on screen, you
have code that relies on the mathematics being visible on screen, you
will need to break that out into a separate operation that is
synchronized with the typesetting via the MathJax queue.

View File

@ -5,7 +5,7 @@ Using Signals
*************
Because much of MathJax operates asynchronously, it is important for
MathJax to be able to indicated to other components operating on the
MathJax to be able to indicate to other components operating on the
page that certain actions have been taken. For example, as MathJax is
starting up, it loads external files such as its configuration files
and the various input and output :term:`jax` that are used on the
@ -59,7 +59,7 @@ have the listener perform the configuration when the message arrives.
But even if the extension *has* already been loaded, this will still
work, because the listener will receive the ready signal even if it
has already been posted. In this way, listening for signals is a
robust method of synchonizing code components no matter when they are
robust method of synchronizing code components no matter when they are
loaded and run.
In some cases, it may be inappropriate for a new listener to receive
@ -106,7 +106,7 @@ details of the messages sent during startup. See also the
``test/sample-signals.html`` file (and its source) for examples of
using signals. This example lists all the signals that occur while
MathJax is processing that page, so it gives useful information about
the details of the signals produced by variuous components.
the details of the signals produced by various components.
In this example, the listener starts loading an extra configuration
file (from the same directory as the web page). Since it returns

View File

@ -154,7 +154,7 @@ are requested simultaneously, so they load concurrently. That means they
can load in any order, and that the begin and end signals for the jax and
extensions can be intermixed. (In general, you will get `Begin Jax`
followed by `Begin Extensions`, but the order of `End Jax` and `End
Extensions` will depend on the file sbeing loaded.) Both 5 and 6 must
Extensions` will depend on the files being loaded.) Both 5 and 6 must
complete, however, before 7 will be performed.
See the ``test/sample-signals.html`` file to see the signals in action.
See the ``test/sample-signals.html`` file to see the signals in action.

View File

@ -22,14 +22,14 @@ initiates an action, waits for it to complete, and then goes on, you
break the function into two parts: a first part that sets up and
initiates the action, and a second that runs after the action is
finished. Callbacks are similar to event handlers that you attach to
DOM elements, and are called when an certain action occurs. See the
DOM elements, and are called when a certain action occurs. See the
:ref:`Callback Object <api-callback>` reference page for details of
how to specify a callback.
**Queues** are MathJax's means of synchronizing actions that must be
performed sequentially, even when they involve asynchronous events
like loading files or dynamically creating stylesheets. The actions
that you put in the queue are `Callback` objects that will be perfomed
that you put in the queue are `Callback` objects that will be performed
in sequence, with MathJax handling the linking of one action to the
next. MathJax maintains a master queue that you can use to
synchronize with MathJax, but you can also create your own private
@ -47,7 +47,7 @@ will call your code. This works somewhat like an event handler, except
that many different types of events can go through the same signal, and the
signals have a "memory", meaning that if you register an interest in a
particular type of signal and that signal has already occurred, you will be
told about the past occurrances as well as any future ones. See the
told about the past occurrences as well as any future ones. See the
:ref:`Signal Object <api-signal>` reference page for more details. See
also the ``test/sample-signals.html`` file in the MathJax ``test``
directory for a working example of using signals.

View File

@ -19,7 +19,7 @@ MathJax operates asynchonously (see :ref:`Synchronizing with MathJax
your call to :meth:`MathJax.Hub.Typeset()` is synchronized with the
other actions that MathJax is taking. For example, it may already be
typesetting portions of the page, or it may be waiting for an output
jax to load, etc., and so you need to queue to typeset action to be
jax to load, etc., and so you need to queue the typeset action to be
performed after MathJax has finished whatever else it may be doing.
That may be immediately, but it may not, and there is no way to tell.
@ -32,13 +32,13 @@ To queue the typeset action, use the command
This will cause MathJax to typeset the page when it is next able to do
so. It guarantees that the typesetting will synchronize properly
with the loading of jax, extensions, fonts, stylesheets, and other
asynchornous activity, and is the only truely safe way to ask MathJax
asynchronous activity, and is the only truly safe way to ask MathJax
to process additional material.
The :meth:`MathJax.Hub.Typeset()` command also accepts a parameter
that is a DOM element whose contents is to be typeset. That could be
that is a DOM element whose content is to be typeset. That could be
a paragraph, or a ``<div>`` element, or even a MathJax math
``<script>`` tag. It could also be a the DOM `id` of such an object, in
``<script>`` tag. It could also be the DOM `id` of such an object, in
which case, MathJax will look up the DOM element for you. So
.. code-block:: javascript
@ -60,7 +60,7 @@ Note that the :meth:`MathJax.Hub.Queue()` method will return
immediately, regardless of whether the typesetting has taken place or
not, so you can not assume that the mathematics is visible after you
make this call. That means that things like the size of the container
for the mathematics may not yet reflect the size of the typeet
for the mathematics may not yet reflect the size of the typeset
mathematics. If you need to perform actions that depend on the
mathematics being typeset, you should push *those* actions onto the
``MathJax.Hub.queue`` as well.
@ -78,7 +78,7 @@ Manipulating Individual Math Elements
If you are not changing a complete DOM structure, but simply want to
update the contents of a single mathematical equation, you do not need
to use ``innerHTML`` and :meth:`MathJax.Hub.Typeset()` to preprocess
and process an elements new content. Instead, you can ask MathJax to
and process an element's new content. Instead, you can ask MathJax to
find the `element jax` for the math element on the page, and use its
methods to modify and update the mathematics that it displays.
@ -95,7 +95,7 @@ within dollar signs (it will be blank). A student has typed
something elsewhere on the page, and you want to typeset their answer
in the location of the mathematics that is already there. You could
replace the entire contents of the `MathDiv` element and call
:meth:`MathJax.Hub.Typeset()` as described above, but there is more
:meth:`MathJax.Hub.Typeset()` as described above, but there is a more
efficient approach, which is to ask MathJax for the element jax for
the mathematics, and call its method for replacing the formula shown
by that element. For example:
@ -105,20 +105,21 @@ by that element. For example:
var math = MathJax.Hub.getAllJax("MathDiv")[0];
MathJax.Hub.Queue(["Text",math,"x+1"]);
This looks up the list of math elements in `MathDiv` element (there is
only one) and takes the first one (element 0) and stores it in
``math``. This is an `element jax` object (see the :ref:`Element Jax
<api-element-jax>` specification for details), which has a
This looks up the list of math elements in the `MathDiv` element
(there is only one) and takes the first one (element 0) and stores it
in ``math``. This is an `element jax` object (see the :ref:`Element
Jax <api-element-jax>` specification for details), which has a
:meth:`Text()` method that can be used to set the input text of the
math element, and retypeset it.
Again, since the typesetting should be synchronized with other actions
of MathJax, the call should be pushed onto the ``MathJax.Hub.queue``,
as shown above, rather than called directly. The example above
performs the equivalent of ``math.Text("x+1")`` as soon as MathJax is
able to do so. Any additional actions the rely on the equation
``x+1`` actually showing on screen should also be pushed onto the
queue so that they will not occur before the math is typeset.
of MathJax, the call should be pushed onto the MathJax processing
queue using :meth:`MathJax.Hub.Queue()`, as shown above, rather than
called directly. The example above performs the equivalent of
``math.Text("x+1")`` as soon as MathJax is able to do so. Any
additional actions that rely on the expression ``x+1`` actually
showing on screen should also be pushed onto the queue so that they
will not occur before the math is typeset.
The actions you can perform on an element jax include:
@ -140,7 +141,7 @@ The actions you can perform on an element jax include:
.. describe:: SourceElement()
to obtain a reference to the original
``<script>`` object that is assocaited with this element jax.
``<script>`` object that is associated with this element jax.
Note that once you have located an element jax, you can keep using it
@ -153,7 +154,7 @@ displayed.
To get the element jax the first time, you need to be sure that you
ask MathJax for it **after** MathJax has processed the page the first
time. This is another sitaution where you want to use the MathJax
time. This is another situation where you want to use the MathJax
queue. If your startup code performs the commands
.. code-block:: javascript