@mathjax/src
    Preparing search index...

    Interface MathDocument<N, T, D>

    The MathDocument interface

    The MathDocument is created by MathJax.Document() and holds the document, the math found in it, and so on. The methods of the MathDocument all return the MathDocument itself, so you can chain the method calls. E.g.,

    const html = MathJax.Document('...'); html.findMath() .compile() .getMetrics() .typeset() .updateDocument();

    The MathDocument is the main interface for page authors to interact with MathJax.

    interface MathDocument<N, T, D> {
        adaptor: DOMAdaptor<N, T, D>;
        document: D;
        inputJax: InputJax<N, T, D>[];
        kind: string;
        math: MathList<N, T, D>;
        mmlFactory: MmlFactory;
        options: DOCUMENT_OPTIONS<DOM<N, T, D>>;
        outputJax: OutputJax<N, T, D>;
        processed: BitField;
        renderActions: RenderList<N, T, D>;
        actionPromises(): Promise<any[]>;
        addRenderAction(id: string, ...action: any[]): void;
        clear(): this;
        clearMathItemsWithin(containers: ContainerList<N>): MathItem<N, T, D>[];
        clearPromises(): void;
        compile(): Promise<void> | MathDocument<N, T, D>;
        concat(list: MathList<N, T, D>): this;
        convert(math: string, options?: OptionList): N | MmlNode;
        convertPromise(math: string, options?: OptionList): Promise<N | MmlNode>;
        done(): Promise<void>;
        findMath(options?: OptionList): this;
        getMathItemsWithin(elements: ContainerList<N>): MathItem<N, T, D>[];
        getMetrics(): this;
        removeFromDocument(restore?: boolean): this;
        removeRenderAction(id: string): void;
        render(): this;
        renderPromise(): Promise<MathDocument<N, T, D>>;
        rerender(start?: number): this;
        rerenderPromise(start?: number): Promise<MathDocument<N, T, D>>;
        reset(options?: ResetList): this;
        savePromise(promise: Promise<any>): void;
        state(state: number, restore?: boolean): this;
        typeset(): Promise<void> | MathDocument<N, T, D>;
        updateDocument(): this;
        whenReady(action: () => any): Promise<any>;
    }

    Type Parameters

    • N

      The HTMLElement node class

    • T

      The Text node class

    • D

      The Document class

    Implemented by

    Index
    adaptor: DOMAdaptor<N, T, D>

    The DOM adaptor to use for input and output

    document: D

    The document being processed (e.g., DOM document, or Markdown string)

    inputJax: InputJax<N, T, D>[]

    An array of input jax to run on the document

    kind: string

    The kind of MathDocument (e.g., "HTML")

    math: MathList<N, T, D>

    The list of MathItems found in this page

    mmlFactory: MmlFactory

    The MmlFactory to be used for input jax and error processing

    options: DOCUMENT_OPTIONS<DOM<N, T, D>>

    The options for the document

    outputJax: OutputJax<N, T, D>

    The output jax to use for the document

    processed: BitField

    This object tracks what operations have been performed, so that (when asynchronous operations are used), the ones that have already been completed won't be performed again.

    renderActions: RenderList<N, T, D>

    The list of actions to take during a render() or convert() call

    • Return a promise that resolves when all of the action promises have been resolved

      Returns Promise<any[]>

    • Parameters

      • id: string

        The id of the action to add

      • ...action: any[]

        The RenderAction to take

      Returns void

    • Reset the processed values and clear the MathList (so that new math can be processed in the document).

      Returns this

      The math document instance

    • Clear the typeset MathItems that are within the given container from the document's MathList. (E.g., when the content of the container has been updated and you want to remove the associated MathItems)

      Parameters

      • containers: ContainerList<N>

        The container DOM elements whose math items are to be removed

      Returns MathItem<N, T, D>[]

      The removed MathItems

    • Merges a MathList into the list for this document.

      Parameters

      • list: MathList<N, T, D>

        The MathList to be merged into this document's list

      Returns this

      The math document instance

    • Convert a math string to the document's output format

      Parameters

      • math: string

        The math string to convert

      • Optionaloptions: OptionList

        The options for the conversion (e.g., format, ex, em, etc.)

      Returns N | MmlNode

      The MmlNode or N node for the converted content

    • Convert a math string to the document's output format

      Parameters

      • math: string

        The math string to convert

      • Optionaloptions: OptionList

        The options for the conversion (e.g., format, ex, em, etc.)

      Returns Promise<N | MmlNode>

      A promise that resolves when the conversion is complete

    • Indicate that the MathDocument is no longer needed.

      Returns Promise<void>

    • Locates the math in the document and constructs the MathList for the document.

      Parameters

      • Optionaloptions: OptionList

        The options for locating the math

      Returns this

      The math document instance

    • Gets the metric information for the MathItems

      Returns this

      The math document instance

    • Removes the typeset math from the document

      Parameters

      • Optionalrestore: boolean

        True if the original math should be put back into the document as well

      Returns this

      The math document instance

    • Parameters

      • id: string

        The id of the action to remove

      Returns void

    • Perform the renderActions on the document

      Returns this

      The math document instance

    • Rerender the MathItems on the page

      Parameters

      • Optionalstart: number

        The state to start rerendering at

      Returns this

      The math document instance

    • Rerender the MathItems on the page

      Parameters

      • Optionalstart: number

        The state to start rerendering at

      Returns Promise<MathDocument<N, T, D>>

      A promise that resolves when the rerender is complete

    • Clear the processed values so that the document can be reprocessed

      Parameters

      • Optionaloptions: ResetList

        The things to be reset

      Returns this

      The math document instance

    • Save a promise in the action romises list

      Parameters

      • promise: Promise<any>

      Returns void

    • Set the state of the document (allowing you to roll back the state to a previous one, if needed).

      Parameters

      • state: number

        The new state of the document

      • Optionalrestore: boolean

        True if the original math should be put back into the document during the rollback

      Returns this

      The math document instance

    • Updates the document to include the typeset math

      Returns this

      The math document instance

    • Perform an action when previous actions are complete. (Used to chain promise-based typeset and conversion actions.)

      Parameters

      • action: () => any

      Returns Promise<any>