Debian Codegraph @

third_party/python/markdown_it_py/markdown_it/common/html_re.py

raw
1 """Regexps to match html elements
2 """
3
4 import re
5
6 attr_name = "[a-zA-Z_:][a-zA-Z0-9:._-]*"
7
8 unquoted = "[^\"'=<>`\\x00-\\x20]+"
9 single_quoted = "'[^']*'"
10 double_quoted = '"[^"]*"'
11
12 attr_value = "(?:" + unquoted + "|" + single_quoted + "|" + double_quoted + ")"
13
14 attribute = "(?:\\s+" + attr_name + "(?:\\s*=\\s*" + attr_value + ")?)"
15
16 open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>"
17
18 close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>"
19 comment = "<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->"
20 processing = "<[?][\\s\\S]*?[?]>"
21 declaration = "<![A-Z]+\\s+[^>]*>"
22 cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
23
24 HTML_TAG_RE = re.compile(
25 "^(?:"
26 + open_tag
27 + "|"
28 + close_tag
29 + "|"
30 + comment
31 + "|"
32 + processing
33 + "|"
34 + declaration
35 + "|"
36 + cdata
37 + ")"
38 )
39 HTML_OPEN_CLOSE_TAG_STR = "^(?:" + open_tag + "|" + close_tag + ")"
40 HTML_OPEN_CLOSE_TAG_RE = re.compile(HTML_OPEN_CLOSE_TAG_STR)