@mathjax/src
    Preparing search index...

    Class HTMLDomStrings<N, T, D>

    The HTMLDocument class (extends AbstractMathDocument)

    A class for extracting the text from DOM trees

    Type Parameters

    • N

      The HTMLElement node class

    • T

      The Text node class

    • D

      The Document class

    Index

    Constructors

    Properties

    adaptor: DOMAdaptor<N, T, D>

    The DOM Adaptor to managing HTML elements

    ignoreHtmlClass: RegExp

    Regular expression for which classes should stop processing of math

    nodes: HTMLNodeList<N, T>[]

    The list of node lists corresponding to the strings in this.strings

    options: OptionList

    The options for this instance

    processHtmlClass: RegExp

    Regular expression for which classes should start processing of math

    skipHtmlTags: RegExp

    Regular expression for the tags to be skipped processing of math

    snodes: HTMLNodeList<N, T>

    The list of nodes and lengths for the string being constructed

    stack: [N | T, boolean][]

    The container nodes that are currently being traversed, and whether their contents are being ignored or not

    string: string

    The string currently being constructed

    strings: string[]

    The array of strings found in the DOM

    OPTIONS: OptionList = ...

    The default options for string processing

    Methods

    • Add more text to the current string, and record the node and its position in the string.

      Parameters

      • node: N | T

        The node to be pushed

      • text: string

        The text to be added (it may not be the actual text of the node, if it is one of the nodes that gets translated to text, like
        to a newline).

      Returns void

    • Find the strings for a given DOM element: Initialize the state Get the element where we stop processing While we still have a node, and it is not the one where we are to stop: If it is a text node, handle it and get the next node Otherwise, if it is in the includeHtmlTags list, handle it and get the next node Otherwise, handle it as a container and get the next node and ignore status If there is no next node, and there are more nodes on the stack: Save the current string, and pop the node and ignore status from the stack Push the final string Get the string array and array of associated DOM nodes Clear the internal values (so the memory can be freed) Return the strings and node lists

      Parameters

      • node: N | T

        The node to search

      Returns [string[], HTMLNodeList<N, T>[]]

      The array of strings and their associated lists of nodes

    • Handle an arbitrary DOM node: Check the class to see if it matches the processHtmlClass regex If the node has a child and is not marked as created by MathJax (data-MJX) and either it is marked as restarting processing or is not a tag to be skipped, then Save the next node (if there is one) and whether we are currently ignoring content Move to the first child node Update whether we are ignoring content Otherwise Move on to the next sibling Return the next node to process and the ignore state

      Parameters

      • node: N

        The node to process

      • ignore: boolean

        Whether we are currently ignoring content

      Returns [N | T, boolean]

      The next element to process and whether to ignore its content

    • Handle an unknown node type (nodeType other than 1, 3, 8)

      Parameters

      • node: N

        The node to process

      • _ignore: boolean

        Whether we are currently ignoring content

      Returns N | T

      The next element to process

    • Handle a BR, WBR, or #comment element (or others in the includeHtmlTags object).

      Parameters

      • node: N

        The node to process

      • ignore: boolean

        Whether we are currently ignoring content

      Returns N | T

      The next element to process

    • Handle a #text node (add its text to the current string)

      Parameters

      • node: T

        The Text node to process

      • ignore: boolean

        Whether we are currently ignoring content

      Returns N | T

      The next element to process