namedTagDefinition top-level constant

String const namedTagDefinition

A String pattern to match a named tag like <table> or </table>.

Implementation

const namedTagDefinition =
    // Opening tag begins.
    '<'

    // Tag name.
    '[a-z][a-z0-9-]*'

    // Attribute begins, see
    // https://spec.commonmark.org/0.30/#attribute.
    r'(?:\s+'

    // Attribute name, see
    // https://spec.commonmark.org/0.30/#attribute-name.
    '[a-z_:][a-z0-9._:-]*'

    //
    '(?:'
    // Attribute value specification, see
    // https://spec.commonmark.org/0.30/#attribute-value-specification.
    r'\s*=\s*'

    // Attribute value, see
    // https://spec.commonmark.org/0.30/#unquoted-attribute-value.
    r'''(?:[^\s"'=<>`]+?|'[^']*?'|"[^"]*?")'''

    // Attribute ends.
    ')?)*'

    // Opening tag ends.
    r'\s*/?>'

    // Or
    '|'

    // Closing tag, see
    // https://spec.commonmark.org/0.30/#closing-tag.
    r'</[a-z][a-z0-9-]*\s*>';