mimekit-ts - v1.0.0
    Preparing search index...

    Class HtmlTokenizer

    An HTML tokenizer.

    Tokenizes HTML text, emitting an HtmlToken for each token it encounters.

    Index
    • get decodeCharacterReferencesEnabled(): boolean

      Gets or sets whether the tokenizer should decode character references.

      Character references in attribute values are still decoded even when this is false.

      Returns boolean

    • set decodeCharacterReferencesEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get ignoreTruncatedTagsEnabled(): boolean

      Gets or sets whether the tokenizer should ignore truncated tags.

      If false and the input abruptly ends in the middle of an HTML tag, it is treated as an HtmlDataToken instead.

      Returns boolean

    • set ignoreTruncatedTagsEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get currentLineNumber(): number

      Gets the current line number.

      This is most commonly used for error reporting. The starting value is 1; together with currentLinePosition, 1,1 indicates the start of the document.

      Returns number

    • get currentLinePosition(): number

      Gets the current line position.

      This is most commonly used for error reporting. The starting value is 1; together with currentLineNumber, 1,1 indicates the start of the document.

      Returns number

    • Creates a tokenizer from raw bytes with the given charset and BOM handling.

      If byte-order-mark detection is enabled, UTF-8, little-endian UTF-16, big-endian UTF-16, little-endian UTF-32, and big-endian UTF-32 BOMs override the supplied encoding. Otherwise the supplied encoding is used.

      Parameters

      • bytes: Uint8Array

        The input bytes.

      • encoding: string = 'utf-8'

        The charset encoding of the bytes.

      • detectEncodingFromByteOrderMarks: boolean = true

        true if byte order marks should be detected.

      Returns HtmlTokenizer

      A tokenizer over the decoded HTML text.

      bytes or encoding is null or undefined.

    • Creates an HTML tag token.

      Parameters

      • tagName: string

        The tag name.

      • isEndTag: boolean = false

        true if the tag is an end tag; otherwise, false.

      Returns HtmlTagToken

      The HTML tag token.