Attention
Version 3 is now the current version of MathJax. This document is for version 2.
The Base Jax Class¶
The MathJax.InputJax, MathJax.OutputJax and MathJax.ElementJax classes are all subclasses of the base Jax class in MathJax. This is a private class that implements the methods common to all three other jax classes.
Unlike most MathJax.Object classes, calling the class object creates a subclass of the class, rather than an instance of the class. E.g.,
MathJax.InputJax.MyInputJax = MathJax.InputJax({
id: "MyInputJax",
version: "1.0",
...
});
creates MathJax.InputJax.MyInputJax
as a subclass of MathJax.InputJax
.
Class Properties¶
- directory
The name of the jax directory (usually
"[MathJax]/jax"
). Overridden in the subclass to be the specific directory for the class, e.g."[MathJax]/jax/input"
.
- extensionDir
The name of the extensions directory (usually
"[MathJax]/extensions"
).
Instance Properties¶
- id
The name of the jax.
- version
The version number of the jax.
- directory
The directory for the jax (e.g.,
"[MathJax]/jax/input/TeX"
).
- require: null
An array of files to load before the
jax.js
file calls theMathJax.Ajax.loadComplete()
method.
- config: {}
An object that contains the default configuration options for the jax. These can be modified by the author by including a configuration subsection for the specific jax in question.
- JAXFILE: "jax.js"
The name of the file that contains the main code for the jax.
Methods¶
- Translate(script)¶
This is a stub for a routine that should be defined by the jax’s
jax.js
file when it is loaded. It should perform the translation action for the specific jax. For an input jax, it should return the ElementJax object that it created. TheTranslate()
method is never called directly by MathJax; during theloadComplete()
call, this function is copied to theProcess()
method, and is called via that name. The defaultTranslate()
method throws an error indicating that theTranslate()
method was not redefined. That way, if thejax.js
file fails to load for some reason, you will receive an error trying to process mathematics with this jax.- Parameters:
- script — reference to the DOM
<script>
object for the mathematics to be translated
- script — reference to the DOM
- Returns:
an ElementJax object, or
null
- Register(mimetype)¶
This method is overridden in the InputJax, OutputJax and ElementJax subclasses to handle the registration of those classes of jax.
- Parameters:
mimetype — the MIME-type to be associated with the jax
- Returns:
null
- Config()
Inserts the configuration block for this jax from the author’s configuration specification into the jax’s
config
property. If the configuration includes anAugment
object, that is used to augment the jax (that is, the configuration can override the methods of the object, as well as the data). This is called automatically during the loading of thejax.js
file.
- Startup()¶
This is a method that can be overridden in the subclasses to perform initialization at startup time (after the configuration has occurred).
- loadComplete(file)
This is called by the
config.js
andjax.js
files when they are completely loaded and are ready to signal that fact to MathJax. Forconfig.js
, this simply calls theMathJax.Ajax.loadComplete()
method for theconfig.js
file. Forjax.js
, the actions performed here are the following:Post the “[name] Jax Config” message to the startup signal.
Perform the jax’s
Config()
method.Post the “[name] Jax Require” message to the startup signal.
Load the files from the jax’s
require
andconfig.extensions
arrays.Post the “[name] Jax Startup” message to the startup signal.
Perform the jax’s
Startup()
method.Post the “[name] Jax Ready” message to the startup signal.
Copy the
preTranslate
,Translate
, andpostTranslate
functions topreProcess
,Process
, andpostProcess
.Perform the
MathJax.Ajax.loadComplete()
call for thejax.js
file.
Note that the configuration process (the
Config()
call) can modify therequire
orconfig.extensions
arrays to add more files that need to be loaded, and that theStartup()
method isn’t called until those files are completely loaded.