@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: OptionList;
        outputJax: OutputJax<N, T, D>;
        processed: BitField;
        renderActions: RenderList<N, T, D>;
        actionPromises(): Promise<any[]>;
        addRenderAction(id: string, ...action: any[]): void;
        clear(): MathDocument<N, T, D>;
        clearMathItemsWithin(containers: ContainerList<N>): MathItem<N, T, D>[];
        clearPromises(): void;
        compile(): MathDocument<N, T, D>;
        concat(list: MathList<N, T, D>): MathDocument<N, T, D>;
        convert(math: string, options?: OptionList): MmlNode | N;
        convertPromise(math: string, options?: OptionList): Promise<MmlNode | N>;
        done(): Promise<void>;
        findMath(options?: OptionList): MathDocument<N, T, D>;
        getMathItemsWithin(elements: ContainerList<N>): MathItem<N, T, D>[];
        getMetrics(): MathDocument<N, T, D>;
        removeFromDocument(restore?: boolean): MathDocument<N, T, D>;
        removeRenderAction(id: string): void;
        render(): MathDocument<N, T, D>;
        renderPromise(): Promise<MathDocument<N, T, D>>;
        rerender(start?: number): MathDocument<N, T, D>;
        rerenderPromise(start?: number): Promise<MathDocument<N, T, D>>;
        reset(options?: ResetList): MathDocument<N, T, D>;
        savePromise(promise: Promise<any>): void;
        state(state: number, restore?: boolean): MathDocument<N, T, D>;
        typeset(): MathDocument<N, T, D>;
        updateDocument(): MathDocument<N, T, D>;
        whenReady(action: () => any): Promise<any>;
    }

    Type Parameters

    • N

      The HTMLElement node class

    • T

      The Text node class

    • D

      The Document class

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    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: OptionList

    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

    Methods

    • 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

    • 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

    • 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 MmlNode | N

      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<MmlNode | N>

      A promise that resolves when the conversion is complete

    • 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 MathDocument<N, T, D>

      The math document instance

    • Parameters

      • id: string

        The id of the action to remove

      Returns void

    • 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

    • 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 MathDocument<N, T, D>

      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>