// These are slightly preliminary and can use some more strong typing here and there. Please feel free to improve.
declare namespace MathJax {
export const Hub: Hub;
export const Ajax: Ajax;
export const Message: Message;
export const HTML: HTML;
export const Callback: Callback;
export const Localization: Localization;
export const InputJax: InputJax;
export const OutputJax: OutputJax;
export interface Callback {
(fn: Function): CallbackObject;
(fns: Function[]): CallbackObject;
(objs: any[]): CallbackObject;
(obj: any): CallbackObject;
(code: string): CallbackObject;
/*Waits for the specified time (given in milliseconds) and then performs the callback. It returns the Callback
* object (or a blank one if none was supplied). The returned callback structure has a timeout property set to
* the result of the setTimeout() call that was used to perform the wait so that you can cancel the wait, if
* needed. Thus MathJax.Callback.Delay() can be used to start a timeout delay that executes the callback if an
* action doesn’t occur within the given time (and if the action does occur, the timeout can be canceled).
* Since MathJax.Callback.Delay() returns a callback structure, it can be used in a callback queue to insert a
* delay between queued commands.
*/
Delay(time: number, callback: any): CallbackObject;
/*Creates a MathJax.CallBack.Queue object and pushes the given callbacks into the queue. See Using Queues for
* more details about MathJax queues.
*/
Queue(...args: any[]): Queue;
/*Looks for a named signal, creates it if it doesn’t already exist, and returns the signal object. See Using
* Signals for more details.
*/
Signal(name: string): Signal;
/*Calls each callback in the hooks array (or the single hook if it is not an array), passing it the arguments
* stored in the data array. If reset is true, then the callback’s reset() method will be called before each hook
* is executed. If any of the hooks returns a Callback object, then it collects those callbacks and returns a new
* callback that will execute when all the ones returned by the hooks have been completed. Otherwise,
* MathJax.Callback.ExecuteHooks() returns null.
*/
ExecuteHooks(hooks: any[], data: any[], reset: boolean): CallbackObject;
/*Creates a prioritized list of hooks that are called in order based on their priority (low priority numbers are
* handled first). This is meant to replace MathJax.Callback.ExecuteHooks() and is used internally for signal
* callbacks, pre- and post-filters, and other lists of callbacks.
*/
Hooks(reset: boolean): Hooks;
}
export interface Hooks {
Add(hook: any, priority: number): CallbackObject;
Remove(hook: CallbackObject): void;
Execute(): CallbackObject;
}
export interface Queue {
/*This is non-zero when the queue is waiting for a command to complete, i.e. a command being processed returns a
* Callback object, indicating that the queue should wait for that action to complete before processing
* additional commands.
*/
pending: number;
/*This is non-zero when the queue is executing one of the commands in the queue.*/
running: number;
/*An array containing the queued commands that are yet to be performed.*/
queue: any[];
/*Adds commands to the queue and runs them (if the queue is not pending or running another command). If one of
* the callbacks is an actual Callback object rather than a callback specification, then the command queued is
* an internal command to wait for the given callback to complete. That is, that callback is not itself queued
* to be executed, but a wait for that callback is queued. The Push() method returns the last callback that was
* added to the queue (so that it can be used for further synchronization, say as an entry in some other queue).
*/
Push(specs: any[]): CallbackObject;
/*Process the commands in the queue, provided the queue is not waiting for another command to complete. This
* method is used internally; you should not need to call it yourself.
*/
Process(): void;
/*Increments the running property, indicating that any commands that are added to the queue should not be
* executed immediately, but should be queued for later execution (when its Resume() is called). This method is
* used internally; you should not need to call it yourself.
*/
Suspend(): void;
/*Decrements the running property, if it is positive. When it is zero, commands can be processed, but that is
* not done automatically — you would need to call Process() to make that happen. This method is used
* internally; you should not need to call it yourself.
*/
Resume(): void;
/*Used internally when an entry in the queue is a Callback object rather than a callback specification.
* A callback to this function (passing it the original callback) is queued instead, and it simply returns the
* callback it was passed. Since the queue will wait for a callback if it is the return value of one of the
* commands it executes, this effectively makes the queue wait for the original callback at that point in the
* command queue.
*/
wait(callback: Function): Function;
/*An internal function used to restart processing of the queue after it has been waiting for a command to
* complete.
*/
call(): void;
}
export interface Signal {
/*The name of the signal. Each signal is named so that various components can access it. The first one to
* request a particular signal causes it to be created, and other requests for the signal return references
* to the same object.
*/
name: string;
/*Array used internally to store the post history so that when new listeners express interests in this signal,
* they can be informed of the signals that have been posted so far. This can be cleared using the signal’s
* Clear() method.
*/
posted: any[];
/*Array of callbacks to the listeners who have expressed interest in hearing about posts to this signal.
* When a post occurs, the listeners are called, each in turn, passing them the message that was posted.
*/
listeners: CallbackObject[];
/*Posts a message to all the listeners for the signal. The listener callbacks are called in turn (with the
* message as an argument), and if any return a Callback object, the posting will be suspended until the callback
* is executed. In this way, the Post() call can operate asynchronously, and so the callback parameter is used to
* synchronize with its operation; the callback will be called when all the listeners have responded to the post.
*
* If a Post() to this signal occurs while waiting for the response from a listener (either because a listener
* returned a Callback object and we are waiting for it to complete when the Post() occurred, or because the
* listener itself called the Post() method), the new message will be queued and will be posted after the current
* message has been sent to all the listeners, and they have all responded. This is another way in which posting
* can be asynchronous; the only sure way to know that a posting has occurred is through its callback. When the
* posting is complete, the callback is called, passing it the signal object that has just completed.
*
* Returns the callback object (or a blank callback object if none was provided).
*/
Post(message: string): CallbackObject;
Post(message: string, callback: CallbackObject): CallbackObject;
/*This causes the history of past messages to be cleared so new listeners will not receive them. Note that since
* the signal may be operating asynchronously, the Clear() may be queued for later. In this way, the Post() and
* Clear() operations will be performed in the proper order even when they are delayed. The callback is called
* when the Clear() operation is completed.
*
* Returns the callback (or a blank callback if none is provided).
*/
Clear(): CallbackObject;
Clear(callback: CallbackObject): CallbackObject;
/*This method registers a new listener on the signal. It creates a Callback object from the callback
* specification, attaches it to the signal, and returns that Callback object. When new messages are posted to
* the signal, it runs the callback, passing it the message that was posted. If the callback itself returns a
* Callback object, that indicates that the listener has started an asynchronous operation and the poster should
* wait for that callback to complete before allowing new posts on the signal.
*
* If ignorePast is false or not present, then before Interest() returns, the callback will be called with all
* the past messages that have been sent to the signal.
*/
Interest(callback: CallbackObject): CallbackObject;
Interest(callback: CallbackObject, ignorePast: boolean): CallbackObject;
/*This removes a listener from the signal so that no new messages will be sent to it. The callback should be the
* one returned by the original Interest() call that attached the listener to the signal in the first place.
* Once removed, the listener will no longer receive messages from the signal.
*/
NoInterest(callback: CallbackObject): void;
/*This creates a callback that is called whenever the signal posts the given message. This is a little easier
* than having to write a function that must check the message each time it is called. Although the message here
* is a string, if a message posted to the signal is an array, then only the first element of that array is used
* to match against the message. That way, if a message contains an identifier plus arguments, the hook will
* match the identifier and still get called with the complete set of arguments.
*
* Returns the Callback object that was produced.
*/
MessageHook(message: string, callback: CallbackObject): CallbackObject;
/*Used internally to call the listeners when a particular message is posted to the signal.*/
ExecuteHook(message: string): void;
}
export interface CallbackObject {
/*The function to be called when the callback is executed.*/
hook: number;
/*An array containing the arguments to pass to the callback function when it is executed.*/
data: any[];
/*The object to use as this during the call to the callback function.*/
object: any;
/*Set to true after the callback has been called, and undefined otherwise. A callback will not be executed a
* second time unless the callback’s reset() method is called first, or its autoReset property is set to true.
*/
called: boolean;
/*Set this to true if you want to be able to call the callback more than once. (This is the case for signal
* listeners, for example).*/
autoReset: boolean;
/*Clears the callback’s called property.*/
reset(): void;
}
export interface Hub {
/*This holds the configuration parameters for MathJax. Set these values using MathJax.Hub.Config() described
* below. The options and their default values are given in the Core Options reference page.
*/
config?: Config | undefined;
/*The pause (in milliseconds) between input and output phases of MathJax’s processing. Set this to 0 to avoid
* jitter when updating output frequently (e.g., in a live preview environment).
*/
processSectionDelay?: number | undefined;
/*The minimum time (in milliseconds) between updates of the “Processing Math” message. After this amount of time
* has passed, and after the next equation has finished being processed, MathJax will stop processing momentarily
* so that the update message can be displayed, and so that the browser can handle user interaction.
*/
processUpdateTime?: number | undefined;
/*The amount of time (in milliseconds) that MathJax pauses after issuing its processing message before starting
* the processing again (to give browsers time to handle user interaction).
*/
processUpdateDelay?: number | undefined;
/*The hub processing signal (tied to the MathJax.Hub.Register.MessageHook() method).*/
signal?: Signal | undefined;
/*MathJax’s main processing queue. Use MathJax.Hub.Queue() to push callbacks onto this queue.*/
queue?: any;
/*The name of the browser as determined by MathJax. It will be one of Firefox, Safari, Chrome, Opera, MSIE,
* Konqueror, or unkown. This is actually an object with additional properties and methods concerning the
* browser
*/
Browser?: BrowserInfo | undefined;
/*An object storing the MIME types associated with the various registered input jax (these are the types of the
*
* would display “[math]” in place of the math until MathJax is able to typeset it.
*/
preRemoveClass?: string | undefined;
/*This value controls whether the Processing Math: nn% messages are displayed in the lower left-hand corner.
* Set to false to prevent those messages (though file loading and other messages will still be shown).
*/
showProcessingMessages?: boolean | undefined;
/*This value controls the verbosity of the messages in the lower left-hand corner. Set it to "none" to eliminate
* all messages, or set it to "simple" to show “Loading...” and “Processing...” rather than showing the full file
* name or the percentage of the mathematics processed.
*/
messageStyle?: string | undefined;
/*These two parameters control the alignment and shifting of displayed equations. The first can be "left",
* "center", or "right", and determines the alignment of displayed equations. When the alignment is not "center",
* the second determines an indentation from the left or right side for the displayed equations.*/
displayAlign?: string | undefined;
displayIndent?: string | undefined;
/*Normally MathJax will perform its startup commands (loading of configuration, styles, jax, and so on) as soon
* as it can. If you expect to be doing additional configuration on the page, however, you may want to have it
* wait until the page’s onload handler is called. If so, set this to "onload". You can also set this to
* "configured", in which case, MathJax will delay its startup until you explicitly call
* MathJax.Hub.Configured(). See Configuring MathJax after it is loaded for more details.
*/
delayStartupUntil?: string | undefined;
/*Normally MathJax will typeset the mathematics on the page as soon as the page is loaded. If you want to delay
* that process, in which case you will need to call MathJax.Hub.Typeset() yourself by hand, set this value to
* true.
*/
skipStartupTypeset?: boolean | undefined;
/*This is a list of DOM element ID’s that are the ones to process for mathematics when any of the Hub typesetting
* calls (Typeset(), Process(), Update(), etc.) are called with no element specified, and during MathJax’s initial
* typesetting run when it starts up. This lets you restrict the processing to particular containers rather than
* scanning the entire document for mathematics. If none are supplied, the complete document is processed.
*/
elements?: string[] | undefined;
/*ince typesetting usually changes the vertical dimensions of the page, if the URL contains an anchor position,
* then after the page is typeset, you may no longer be positioned at the correct position on the page. MathJax
* can reposition to that location after it completes its initial typesetting of the page. This value controls
* whether MathJax will reposition the browser to the #hash location from the page URL after typesetting for
* the page.
*/
positionToHash?: boolean | undefined;
/*These control whether to attach the MathJax contextual menu to the expressions typeset by MathJax. Since the
* code for handling MathPlayer in Internet Explorer is somewhat delicate, it is controlled separately via
* showMathMenuMSIE, but the latter is now deprecated in favor of the MathJax contextual menu settings for
* MathPlayer (see below).
*
* If showMathMenu is true, then right-clicking (on Windows or Linux) or control-clicking (on Mac OS X) will
* produce a MathJax menu that allows you to get the source of the mathematics in various formats, change the
* size of the mathematics relative to the surrounding text, get information about MathJax, and configure other
* MathJax settings.
*
* Set this to false to disable the menu. When true, the MathMenu configuration block determines the operation
* of the menu. See the MathMenu options for more details.
*
* These values used to be listed in the separate output jax, but have been moved to this more central location
* since they are shared by all output jax. MathJax will still honor their values from their original positions,
* if they are set there.
*/
showMathMenu?: boolean | undefined;
showMathMenuMSIE?: boolean | undefined;
/*This block contains settings for the mathematics contextual menu that act as the defaults for the user’s
* settings in that menu.
* There are also settings for format, renderer, font, mpContext, and mpMouse, but these are maintained by
* MathJax and should not be set by the page author.
*/
menuSettings?: MenuSettings | undefined;
/*This block contains settings that control how MathJax responds to unexpected errors while processing
* mathematical equations. Rather than simply crash, MathJax can report an error and go on.
*/
errorSettings?: ErrorSettings | undefined;
"v1.0-compatible"?: boolean | undefined;
}
export interface MathZoom {
/*This is a list of CSS declarations for styling the zoomed mathematics. See the definitions in
* extensions/MathZoom.js for details of what are defined by default. See CSS Style Objects for details on how
* to specify CSS style in a JavaScript object.
*/
styles: any;
}
export interface MathMenu {
/*This is the hover delay for the display (in milliseconds) for submenus in the contextual menu: when the mouse
* is over a submenu label for this long, the menu will appear. (The submenu also will appear if you click on its
* label.)
*/
delay?: number | undefined;
/*This is the URL for the MathJax Help menu item. When the user selects that item, the browser opens a new window
* with this URL.
*/
helpURL?: string | undefined;
/*This controls whether the “Math Renderer” item will be displayed in the “Math Settings” submenu of the MathJax
* contextual menu. It allows the user to change between the HTML-CSS, NativeMML, and SVG output processors for
* the mathematics on the page. Set to false to prevent this menu item from showing.
*/
showRenderer?: boolean | undefined;
/*This controls whether the “Font Preference” item will be displayed in the “Math Settings” submenu of the MathJax
* contextual menu. This submenu lets the user select what font to use in the mathematics produced by the HTML-CSS
* output processor. Note that changing the selection in the font menu will cause the page to reload. Set to false
* to prevent this menu item from showing.
* */
showFontMenu?: boolean | undefined;
/*This controls whether the “Language” item will be displayed in the MathJax contextual menu. This submenu allows
* the user to select the language to use for the MathJax user interface, including the contextual menu, the about
* and help dialogs, the message box at the lower left, and any warning messages produced by MathJax. Set this to
* false to prevent this menu item from showing. This will force the user to use the language you have set for
* MathJax.
*/
showLocale?: boolean | undefined;
/*This controls whether the “MathPlayer” item will be displayed in the “Math Settings” submenu of the MathJax
* contextual menu. This submenu lets the user select what events should be passed on to the MathPlayer plugin,
* when it is present. Mouse events can be passed on (so that clicks will be processed by MathPlayer rather than
* MathJax), and menu events can be passed on (to allow the user access to the MathPlayer menu). Set to false to
* prevent this menu item from showing.
* */
showMathPlayer?: boolean | undefined;
/*This controls whether the “Contextual Menu” item will be displayed in the “Math Settings” submenu of the MathJax
* contextual menu. It allows the user to decide whether the MathJax menu or the browser’s default contextual menu
* will be shown when the context menu click occurs over mathematics typeset by MathJax. Set to false to prevent
* this menu item from showing.
*/
showContext?: boolean | undefined;
/*These are the settings for the Annotation submenu of the “Show Math As” menu. If the