# Path: wikitextparser/_config.py
# def _plant_trie(strings: _Iterable[str]) -> dict:
# def _pattern(trie: dict) -> str:
# def regex_pattern(words: _Iterable[str]) -> bytes:
# _HTML_TAG_NAME = regex_pattern(_valid_html_tag_names) + br'\b'


from functools import partial
from typing import Callable, Dict, Optional
from regex import DOTALL, REVERSE, compile as regex_compile, IGNORECASE
from ._config import (
    _HTML_TAG_NAME, _bare_external_link_schemes, _parsable_tag_extensions,
    _parser_functions, _unparsable_tag_extensions, regex_pattern)
        # Invalid attribute. Todo: could the / be removed? see
        # https://stackoverflow.com/a/3558200/2705757
        + rb'|(?>[^>/]++|/(?!\s*+>))++'
    rb')*+(?<attr_insert>)')
ATTRS_MATCH = regex_compile(
    # Leading space is not required at the start of the attribute string.
    ATTRS_PATTERN.replace(b'++', b'*+', 1),
).match
# VOID_ELEMENTS = (
#     'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
#     'link', 'meta', 'param', 'source', 'track', 'wbr'
# )
# RAW_TEXT_ELEMENTS = ('script', 'style')
# ESCAPABLE_RAW_TEXT_ELEMENTS = ('textarea', 'title')
# Detecting foreign elements in MathML and SVG namespaces is not implemented
# yet. See
# https://developer.mozilla.org/en/docs/Web/SVG/Namespaces_Crash_Course
# for an overview.
# note that end tags do not accept attributes, but MW currently cleans up and
# ignores such attributes
END_TAG_PATTERN = rb'(?<end_tag></{name}(?:>|[' + SPACE_CHARS + rb'][^>]*+>))'
START_TAG_PATTERN = ( # noqa
    rb'(?<start_tag>'
        rb'<{name}' + ATTRS_PATTERN +
        rb'[' + SPACE_CHARS + rb']*+'
        rb'(?:(?<self_closing>/[' + SPACE_CHARS + b']*+>)|>)'
    rb')')
HTML_START_TAG_FINDITER = regex_compile(
    START_TAG_PATTERN.replace(b'{name}', _HTML_TAG_NAME, 1)).finditer
HTML_END_TAG_FINDITER = regex_compile(

# Path: wikitextparser/_config.py
# def _plant_trie(strings: _Iterable[str]) -> dict:
# def _pattern(trie: dict) -> str:
# def regex_pattern(words: _Iterable[str]) -> bytes:
# _HTML_TAG_NAME = regex_pattern(_valid_html_tag_names) + br'\b'


# Path: wikitextparser/_spans.py
from functools import partial
from typing import Callable, Dict, Optional
from regex import DOTALL, REVERSE, compile as regex_compile, IGNORECASE
from ._config import (
    _HTML_TAG_NAME, _bare_external_link_schemes, _parsable_tag_extensions,
    _parser_functions, _unparsable_tag_extensions, regex_pattern)

        # Invalid attribute. Todo: could the / be removed? see
        # https://stackoverflow.com/a/3558200/2705757
        + rb'|(?>[^>/]++|/(?!\s*+>))++'
    rb')*+(?<attr_insert>)')
ATTRS_MATCH = regex_compile(
    # Leading space is not required at the start of the attribute string.
    ATTRS_PATTERN.replace(b'++', b'*+', 1),
).match
# VOID_ELEMENTS = (
#     'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
#     'link', 'meta', 'param', 'source', 'track', 'wbr'
# )
# RAW_TEXT_ELEMENTS = ('script', 'style')
# ESCAPABLE_RAW_TEXT_ELEMENTS = ('textarea', 'title')
# Detecting foreign elements in MathML and SVG namespaces is not implemented
# yet. See
# https://developer.mozilla.org/en/docs/Web/SVG/Namespaces_Crash_Course
# for an overview.
# note that end tags do not accept attributes, but MW currently cleans up and
# ignores such attributes
END_TAG_PATTERN = rb'(?<end_tag></{name}(?:>|[' + SPACE_CHARS + rb'][^>]*+>))'
START_TAG_PATTERN = ( # noqa
    rb'(?<start_tag>'
        rb'<{name}' + ATTRS_PATTERN +
        rb'[' + SPACE_CHARS + rb']*+'
        rb'(?:(?<self_closing>/[' + SPACE_CHARS + b']*+>)|>)'
    rb')')
HTML_START_TAG_FINDITER = regex_compile(
    START_TAG_PATTERN.replace(b'{name}', _HTML_TAG_NAME, 1)).finditer
HTML_END_TAG_FINDITER = regex_compile(

    END_TAG_PATTERN.replace(b'{name}', _HTML_TAG_NAME, 1)).finditer