Amar-Aly commited on
Commit
f642e95
·
verified ·
1 Parent(s): f289a89

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/__init__.py +6 -0
  2. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/_compat.py +1 -0
  3. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/_punycode.py +67 -0
  4. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_destination.py +83 -0
  5. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_label.py +44 -0
  6. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_title.py +75 -0
  7. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/__init__.py +28 -0
  8. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/commonmark.py +75 -0
  9. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/default.py +36 -0
  10. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/zero.py +44 -0
  11. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/__init__.py +27 -0
  12. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/blockquote.py +299 -0
  13. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/code.py +36 -0
  14. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/fence.py +101 -0
  15. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/heading.py +69 -0
  16. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/hr.py +56 -0
  17. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/html_block.py +90 -0
  18. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/lheading.py +86 -0
  19. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/list.py +345 -0
  20. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/paragraph.py +66 -0
  21. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/reference.py +235 -0
  22. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/state_block.py +261 -0
  23. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/table.py +250 -0
  24. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/__init__.py +19 -0
  25. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/block.py +13 -0
  26. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/inline.py +10 -0
  27. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/linkify.py +149 -0
  28. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/normalize.py +19 -0
  29. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/replacements.py +127 -0
  30. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/smartquotes.py +202 -0
  31. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/state_core.py +25 -0
  32. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/text_join.py +35 -0
  33. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/__init__.py +31 -0
  34. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/autolink.py +77 -0
  35. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/backticks.py +72 -0
  36. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/balance_pairs.py +138 -0
  37. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/emphasis.py +102 -0
  38. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/entity.py +53 -0
  39. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/escape.py +93 -0
  40. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/fragments_join.py +43 -0
  41. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/html_inline.py +43 -0
  42. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/image.py +148 -0
  43. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/link.py +149 -0
  44. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/linkify.py +62 -0
  45. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/newline.py +44 -0
  46. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/state_inline.py +165 -0
  47. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/strikethrough.py +127 -0
  48. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/text.py +62 -0
  49. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it_py-4.0.0.dist-info/licenses/LICENSE +21 -0
  50. .cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it_py-4.0.0.dist-info/licenses/LICENSE.markdown-it +22 -0
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ """A Python port of Markdown-It"""
2
+
3
+ __all__ = ("MarkdownIt",)
4
+ __version__ = "4.0.0"
5
+
6
+ from .main import MarkdownIt
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/_compat.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from __future__ import annotations
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/_punycode.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2014 Mathias Bynens <https://mathiasbynens.be/>
2
+ # Copyright 2021 Taneli Hukkinen
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ import codecs
24
+ from collections.abc import Callable
25
+ import re
26
+
27
+ REGEX_SEPARATORS = re.compile(r"[\x2E\u3002\uFF0E\uFF61]")
28
+ REGEX_NON_ASCII = re.compile(r"[^\0-\x7E]")
29
+
30
+
31
+ def encode(uni: str) -> str:
32
+ return codecs.encode(uni, encoding="punycode").decode()
33
+
34
+
35
+ def decode(ascii: str) -> str:
36
+ return codecs.decode(ascii, encoding="punycode") # type: ignore
37
+
38
+
39
+ def map_domain(string: str, fn: Callable[[str], str]) -> str:
40
+ parts = string.split("@")
41
+ result = ""
42
+ if len(parts) > 1:
43
+ # In email addresses, only the domain name should be punycoded. Leave
44
+ # the local part (i.e. everything up to `@`) intact.
45
+ result = parts[0] + "@"
46
+ string = parts[1]
47
+ labels = REGEX_SEPARATORS.split(string)
48
+ encoded = ".".join(fn(label) for label in labels)
49
+ return result + encoded
50
+
51
+
52
+ def to_unicode(obj: str) -> str:
53
+ def mapping(obj: str) -> str:
54
+ if obj.startswith("xn--"):
55
+ return decode(obj[4:].lower())
56
+ return obj
57
+
58
+ return map_domain(obj, mapping)
59
+
60
+
61
+ def to_ascii(obj: str) -> str:
62
+ def mapping(obj: str) -> str:
63
+ if REGEX_NON_ASCII.search(obj):
64
+ return "xn--" + encode(obj)
65
+ return obj
66
+
67
+ return map_domain(obj, mapping)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_destination.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Parse link destination
3
+ """
4
+
5
+ from ..common.utils import charCodeAt, unescapeAll
6
+
7
+
8
+ class _Result:
9
+ __slots__ = ("ok", "pos", "str")
10
+
11
+ def __init__(self) -> None:
12
+ self.ok = False
13
+ self.pos = 0
14
+ self.str = ""
15
+
16
+
17
+ def parseLinkDestination(string: str, pos: int, maximum: int) -> _Result:
18
+ start = pos
19
+ result = _Result()
20
+
21
+ if charCodeAt(string, pos) == 0x3C: # /* < */
22
+ pos += 1
23
+ while pos < maximum:
24
+ code = charCodeAt(string, pos)
25
+ if code == 0x0A: # /* \n */)
26
+ return result
27
+ if code == 0x3C: # / * < * /
28
+ return result
29
+ if code == 0x3E: # /* > */) {
30
+ result.pos = pos + 1
31
+ result.str = unescapeAll(string[start + 1 : pos])
32
+ result.ok = True
33
+ return result
34
+
35
+ if code == 0x5C and pos + 1 < maximum: # \
36
+ pos += 2
37
+ continue
38
+
39
+ pos += 1
40
+
41
+ # no closing '>'
42
+ return result
43
+
44
+ # this should be ... } else { ... branch
45
+
46
+ level = 0
47
+ while pos < maximum:
48
+ code = charCodeAt(string, pos)
49
+
50
+ if code is None or code == 0x20:
51
+ break
52
+
53
+ # ascii control characters
54
+ if code < 0x20 or code == 0x7F:
55
+ break
56
+
57
+ if code == 0x5C and pos + 1 < maximum:
58
+ if charCodeAt(string, pos + 1) == 0x20:
59
+ break
60
+ pos += 2
61
+ continue
62
+
63
+ if code == 0x28: # /* ( */)
64
+ level += 1
65
+ if level > 32:
66
+ return result
67
+
68
+ if code == 0x29: # /* ) */)
69
+ if level == 0:
70
+ break
71
+ level -= 1
72
+
73
+ pos += 1
74
+
75
+ if start == pos:
76
+ return result
77
+ if level != 0:
78
+ return result
79
+
80
+ result.str = unescapeAll(string[start:pos])
81
+ result.pos = pos
82
+ result.ok = True
83
+ return result
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_label.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Parse link label
3
+
4
+ this function assumes that first character ("[") already matches
5
+ returns the end of the label
6
+
7
+ """
8
+
9
+ from markdown_it.rules_inline import StateInline
10
+
11
+
12
+ def parseLinkLabel(state: StateInline, start: int, disableNested: bool = False) -> int:
13
+ labelEnd = -1
14
+ oldPos = state.pos
15
+ found = False
16
+
17
+ state.pos = start + 1
18
+ level = 1
19
+
20
+ while state.pos < state.posMax:
21
+ marker = state.src[state.pos]
22
+ if marker == "]":
23
+ level -= 1
24
+ if level == 0:
25
+ found = True
26
+ break
27
+
28
+ prevPos = state.pos
29
+ state.md.inline.skipToken(state)
30
+ if marker == "[":
31
+ if prevPos == state.pos - 1:
32
+ # increase level if we find text `[`,
33
+ # which is not a part of any token
34
+ level += 1
35
+ elif disableNested:
36
+ state.pos = oldPos
37
+ return -1
38
+ if found:
39
+ labelEnd = state.pos
40
+
41
+ # restore old state
42
+ state.pos = oldPos
43
+
44
+ return labelEnd
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/helpers/parse_link_title.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Parse link title"""
2
+
3
+ from ..common.utils import charCodeAt, unescapeAll
4
+
5
+
6
+ class _State:
7
+ __slots__ = ("can_continue", "marker", "ok", "pos", "str")
8
+
9
+ def __init__(self) -> None:
10
+ self.ok = False
11
+ """if `true`, this is a valid link title"""
12
+ self.can_continue = False
13
+ """if `true`, this link can be continued on the next line"""
14
+ self.pos = 0
15
+ """if `ok`, it's the position of the first character after the closing marker"""
16
+ self.str = ""
17
+ """if `ok`, it's the unescaped title"""
18
+ self.marker = 0
19
+ """expected closing marker character code"""
20
+
21
+ def __str__(self) -> str:
22
+ return self.str
23
+
24
+
25
+ def parseLinkTitle(
26
+ string: str, start: int, maximum: int, prev_state: _State | None = None
27
+ ) -> _State:
28
+ """Parse link title within `str` in [start, max] range,
29
+ or continue previous parsing if `prev_state` is defined (equal to result of last execution).
30
+ """
31
+ pos = start
32
+ state = _State()
33
+
34
+ if prev_state is not None:
35
+ # this is a continuation of a previous parseLinkTitle call on the next line,
36
+ # used in reference links only
37
+ state.str = prev_state.str
38
+ state.marker = prev_state.marker
39
+ else:
40
+ if pos >= maximum:
41
+ return state
42
+
43
+ marker = charCodeAt(string, pos)
44
+
45
+ # /* " */ /* ' */ /* ( */
46
+ if marker != 0x22 and marker != 0x27 and marker != 0x28:
47
+ return state
48
+
49
+ start += 1
50
+ pos += 1
51
+
52
+ # if opening marker is "(", switch it to closing marker ")"
53
+ if marker == 0x28:
54
+ marker = 0x29
55
+
56
+ state.marker = marker
57
+
58
+ while pos < maximum:
59
+ code = charCodeAt(string, pos)
60
+ if code == state.marker:
61
+ state.pos = pos + 1
62
+ state.str += unescapeAll(string[start:pos])
63
+ state.ok = True
64
+ return state
65
+ elif code == 0x28 and state.marker == 0x29: # /* ( */ /* ) */
66
+ return state
67
+ elif code == 0x5C and pos + 1 < maximum: # /* \ */
68
+ pos += 1
69
+
70
+ pos += 1
71
+
72
+ # no closing marker found, but this link title may continue on the next line (for references)
73
+ state.can_continue = True
74
+ state.str += unescapeAll(string[start:pos])
75
+ return state
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/__init__.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ("commonmark", "default", "gfm_like", "js_default", "zero")
2
+
3
+ from ..utils import PresetType
4
+ from . import commonmark, default, zero
5
+
6
+ js_default = default
7
+
8
+
9
+ class gfm_like: # noqa: N801
10
+ """GitHub Flavoured Markdown (GFM) like.
11
+
12
+ This adds the linkify, table and strikethrough components to CommmonMark.
13
+
14
+ Note, it lacks task-list items and raw HTML filtering,
15
+ to meet the the full GFM specification
16
+ (see https://github.github.com/gfm/#autolinks-extension-).
17
+ """
18
+
19
+ @staticmethod
20
+ def make() -> PresetType:
21
+ config = commonmark.make()
22
+ config["components"]["core"]["rules"].append("linkify")
23
+ config["components"]["block"]["rules"].append("table")
24
+ config["components"]["inline"]["rules"].extend(["strikethrough", "linkify"])
25
+ config["components"]["inline"]["rules2"].append("strikethrough")
26
+ config["options"]["linkify"] = True
27
+ config["options"]["html"] = True
28
+ return config
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/commonmark.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Commonmark default options.
2
+
3
+ This differs to presets.default,
4
+ primarily in that it allows HTML and does not enable components:
5
+
6
+ - block: table
7
+ - inline: strikethrough
8
+ """
9
+
10
+ from ..utils import PresetType
11
+
12
+
13
+ def make() -> PresetType:
14
+ return {
15
+ "options": {
16
+ "maxNesting": 20, # Internal protection, recursion limit
17
+ "html": True, # Enable HTML tags in source,
18
+ # this is just a shorthand for .enable(["html_inline", "html_block"])
19
+ # used by the linkify rule:
20
+ "linkify": False, # autoconvert URL-like texts to links
21
+ # used by the replacements and smartquotes rules
22
+ # Enable some language-neutral replacements + quotes beautification
23
+ "typographer": False,
24
+ # used by the smartquotes rule:
25
+ # Double + single quotes replacement pairs, when typographer enabled,
26
+ # and smartquotes on. Could be either a String or an Array.
27
+ #
28
+ # For example, you can use '«»„“' for Russian, '„“‚‘' for German,
29
+ # and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
30
+ "quotes": "\u201c\u201d\u2018\u2019", # /* “”‘’ */
31
+ # Renderer specific; these options are used directly in the HTML renderer
32
+ "xhtmlOut": True, # Use '/' to close single tags (<br />)
33
+ "breaks": False, # Convert '\n' in paragraphs into <br>
34
+ "langPrefix": "language-", # CSS language prefix for fenced blocks
35
+ # Highlighter function. Should return escaped HTML,
36
+ # or '' if the source string is not changed and should be escaped externally.
37
+ # If result starts with <pre... internal wrapper is skipped.
38
+ #
39
+ # function (/*str, lang, attrs*/) { return ''; }
40
+ #
41
+ "highlight": None,
42
+ },
43
+ "components": {
44
+ "core": {"rules": ["normalize", "block", "inline", "text_join"]},
45
+ "block": {
46
+ "rules": [
47
+ "blockquote",
48
+ "code",
49
+ "fence",
50
+ "heading",
51
+ "hr",
52
+ "html_block",
53
+ "lheading",
54
+ "list",
55
+ "reference",
56
+ "paragraph",
57
+ ]
58
+ },
59
+ "inline": {
60
+ "rules": [
61
+ "autolink",
62
+ "backticks",
63
+ "emphasis",
64
+ "entity",
65
+ "escape",
66
+ "html_inline",
67
+ "image",
68
+ "link",
69
+ "newline",
70
+ "text",
71
+ ],
72
+ "rules2": ["balance_pairs", "emphasis", "fragments_join"],
73
+ },
74
+ },
75
+ }
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/default.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """markdown-it default options."""
2
+
3
+ from ..utils import PresetType
4
+
5
+
6
+ def make() -> PresetType:
7
+ return {
8
+ "options": {
9
+ "maxNesting": 100, # Internal protection, recursion limit
10
+ "html": False, # Enable HTML tags in source
11
+ # this is just a shorthand for .disable(["html_inline", "html_block"])
12
+ # used by the linkify rule:
13
+ "linkify": False, # autoconvert URL-like texts to links
14
+ # used by the replacements and smartquotes rules:
15
+ # Enable some language-neutral replacements + quotes beautification
16
+ "typographer": False,
17
+ # used by the smartquotes rule:
18
+ # Double + single quotes replacement pairs, when typographer enabled,
19
+ # and smartquotes on. Could be either a String or an Array.
20
+ # For example, you can use '«»„“' for Russian, '„“‚‘' for German,
21
+ # and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
22
+ "quotes": "\u201c\u201d\u2018\u2019", # /* “”‘’ */
23
+ # Renderer specific; these options are used directly in the HTML renderer
24
+ "xhtmlOut": False, # Use '/' to close single tags (<br />)
25
+ "breaks": False, # Convert '\n' in paragraphs into <br>
26
+ "langPrefix": "language-", # CSS language prefix for fenced blocks
27
+ # Highlighter function. Should return escaped HTML,
28
+ # or '' if the source string is not changed and should be escaped externally.
29
+ # If result starts with <pre... internal wrapper is skipped.
30
+ #
31
+ # function (/*str, lang, attrs*/) { return ''; }
32
+ #
33
+ "highlight": None,
34
+ },
35
+ "components": {"core": {}, "block": {}, "inline": {}},
36
+ }
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/presets/zero.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ "Zero" preset, with nothing enabled. Useful for manual configuring of simple
3
+ modes. For example, to parse bold/italic only.
4
+ """
5
+
6
+ from ..utils import PresetType
7
+
8
+
9
+ def make() -> PresetType:
10
+ return {
11
+ "options": {
12
+ "maxNesting": 20, # Internal protection, recursion limit
13
+ "html": False, # Enable HTML tags in source
14
+ # this is just a shorthand for .disable(["html_inline", "html_block"])
15
+ # used by the linkify rule:
16
+ "linkify": False, # autoconvert URL-like texts to links
17
+ # used by the replacements and smartquotes rules:
18
+ # Enable some language-neutral replacements + quotes beautification
19
+ "typographer": False,
20
+ # used by the smartquotes rule:
21
+ # Double + single quotes replacement pairs, when typographer enabled,
22
+ # and smartquotes on. Could be either a String or an Array.
23
+ # For example, you can use '«»„“' for Russian, '„“‚‘' for German,
24
+ # and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
25
+ "quotes": "\u201c\u201d\u2018\u2019", # /* “”‘’ */
26
+ # Renderer specific; these options are used directly in the HTML renderer
27
+ "xhtmlOut": False, # Use '/' to close single tags (<br />)
28
+ "breaks": False, # Convert '\n' in paragraphs into <br>
29
+ "langPrefix": "language-", # CSS language prefix for fenced blocks
30
+ # Highlighter function. Should return escaped HTML,
31
+ # or '' if the source string is not changed and should be escaped externally.
32
+ # If result starts with <pre... internal wrapper is skipped.
33
+ # function (/*str, lang, attrs*/) { return ''; }
34
+ "highlight": None,
35
+ },
36
+ "components": {
37
+ "core": {"rules": ["normalize", "block", "inline", "text_join"]},
38
+ "block": {"rules": ["paragraph"]},
39
+ "inline": {
40
+ "rules": ["text"],
41
+ "rules2": ["balance_pairs", "fragments_join"],
42
+ },
43
+ },
44
+ }
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/__init__.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = (
2
+ "StateBlock",
3
+ "blockquote",
4
+ "code",
5
+ "fence",
6
+ "heading",
7
+ "hr",
8
+ "html_block",
9
+ "lheading",
10
+ "list_block",
11
+ "paragraph",
12
+ "reference",
13
+ "table",
14
+ )
15
+
16
+ from .blockquote import blockquote
17
+ from .code import code
18
+ from .fence import fence
19
+ from .heading import heading
20
+ from .hr import hr
21
+ from .html_block import html_block
22
+ from .lheading import lheading
23
+ from .list import list_block
24
+ from .paragraph import paragraph
25
+ from .reference import reference
26
+ from .state_block import StateBlock
27
+ from .table import table
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/blockquote.py ADDED
@@ -0,0 +1,299 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Block quotes
2
+ from __future__ import annotations
3
+
4
+ import logging
5
+
6
+ from ..common.utils import isStrSpace
7
+ from .state_block import StateBlock
8
+
9
+ LOGGER = logging.getLogger(__name__)
10
+
11
+
12
+ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
13
+ LOGGER.debug(
14
+ "entering blockquote: %s, %s, %s, %s", state, startLine, endLine, silent
15
+ )
16
+
17
+ oldLineMax = state.lineMax
18
+ pos = state.bMarks[startLine] + state.tShift[startLine]
19
+ max = state.eMarks[startLine]
20
+
21
+ if state.is_code_block(startLine):
22
+ return False
23
+
24
+ # check the block quote marker
25
+ try:
26
+ if state.src[pos] != ">":
27
+ return False
28
+ except IndexError:
29
+ return False
30
+ pos += 1
31
+
32
+ # we know that it's going to be a valid blockquote,
33
+ # so no point trying to find the end of it in silent mode
34
+ if silent:
35
+ return True
36
+
37
+ # set offset past spaces and ">"
38
+ initial = offset = state.sCount[startLine] + 1
39
+
40
+ try:
41
+ second_char: str | None = state.src[pos]
42
+ except IndexError:
43
+ second_char = None
44
+
45
+ # skip one optional space after '>'
46
+ if second_char == " ":
47
+ # ' > test '
48
+ # ^ -- position start of line here:
49
+ pos += 1
50
+ initial += 1
51
+ offset += 1
52
+ adjustTab = False
53
+ spaceAfterMarker = True
54
+ elif second_char == "\t":
55
+ spaceAfterMarker = True
56
+
57
+ if (state.bsCount[startLine] + offset) % 4 == 3:
58
+ # ' >\t test '
59
+ # ^ -- position start of line here (tab has width==1)
60
+ pos += 1
61
+ initial += 1
62
+ offset += 1
63
+ adjustTab = False
64
+ else:
65
+ # ' >\t test '
66
+ # ^ -- position start of line here + shift bsCount slightly
67
+ # to make extra space appear
68
+ adjustTab = True
69
+
70
+ else:
71
+ spaceAfterMarker = False
72
+
73
+ oldBMarks = [state.bMarks[startLine]]
74
+ state.bMarks[startLine] = pos
75
+
76
+ while pos < max:
77
+ ch = state.src[pos]
78
+
79
+ if isStrSpace(ch):
80
+ if ch == "\t":
81
+ offset += (
82
+ 4
83
+ - (offset + state.bsCount[startLine] + (1 if adjustTab else 0)) % 4
84
+ )
85
+ else:
86
+ offset += 1
87
+
88
+ else:
89
+ break
90
+
91
+ pos += 1
92
+
93
+ oldBSCount = [state.bsCount[startLine]]
94
+ state.bsCount[startLine] = (
95
+ state.sCount[startLine] + 1 + (1 if spaceAfterMarker else 0)
96
+ )
97
+
98
+ lastLineEmpty = pos >= max
99
+
100
+ oldSCount = [state.sCount[startLine]]
101
+ state.sCount[startLine] = offset - initial
102
+
103
+ oldTShift = [state.tShift[startLine]]
104
+ state.tShift[startLine] = pos - state.bMarks[startLine]
105
+
106
+ terminatorRules = state.md.block.ruler.getRules("blockquote")
107
+
108
+ oldParentType = state.parentType
109
+ state.parentType = "blockquote"
110
+
111
+ # Search the end of the block
112
+ #
113
+ # Block ends with either:
114
+ # 1. an empty line outside:
115
+ # ```
116
+ # > test
117
+ #
118
+ # ```
119
+ # 2. an empty line inside:
120
+ # ```
121
+ # >
122
+ # test
123
+ # ```
124
+ # 3. another tag:
125
+ # ```
126
+ # > test
127
+ # - - -
128
+ # ```
129
+
130
+ # for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
131
+ nextLine = startLine + 1
132
+ while nextLine < endLine:
133
+ # check if it's outdented, i.e. it's inside list item and indented
134
+ # less than said list item:
135
+ #
136
+ # ```
137
+ # 1. anything
138
+ # > current blockquote
139
+ # 2. checking this line
140
+ # ```
141
+ isOutdented = state.sCount[nextLine] < state.blkIndent
142
+
143
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
144
+ max = state.eMarks[nextLine]
145
+
146
+ if pos >= max:
147
+ # Case 1: line is not inside the blockquote, and this line is empty.
148
+ break
149
+
150
+ evaluatesTrue = state.src[pos] == ">" and not isOutdented
151
+ pos += 1
152
+ if evaluatesTrue:
153
+ # This line is inside the blockquote.
154
+
155
+ # set offset past spaces and ">"
156
+ initial = offset = state.sCount[nextLine] + 1
157
+
158
+ try:
159
+ next_char: str | None = state.src[pos]
160
+ except IndexError:
161
+ next_char = None
162
+
163
+ # skip one optional space after '>'
164
+ if next_char == " ":
165
+ # ' > test '
166
+ # ^ -- position start of line here:
167
+ pos += 1
168
+ initial += 1
169
+ offset += 1
170
+ adjustTab = False
171
+ spaceAfterMarker = True
172
+ elif next_char == "\t":
173
+ spaceAfterMarker = True
174
+
175
+ if (state.bsCount[nextLine] + offset) % 4 == 3:
176
+ # ' >\t test '
177
+ # ^ -- position start of line here (tab has width==1)
178
+ pos += 1
179
+ initial += 1
180
+ offset += 1
181
+ adjustTab = False
182
+ else:
183
+ # ' >\t test '
184
+ # ^ -- position start of line here + shift bsCount slightly
185
+ # to make extra space appear
186
+ adjustTab = True
187
+
188
+ else:
189
+ spaceAfterMarker = False
190
+
191
+ oldBMarks.append(state.bMarks[nextLine])
192
+ state.bMarks[nextLine] = pos
193
+
194
+ while pos < max:
195
+ ch = state.src[pos]
196
+
197
+ if isStrSpace(ch):
198
+ if ch == "\t":
199
+ offset += (
200
+ 4
201
+ - (
202
+ offset
203
+ + state.bsCount[nextLine]
204
+ + (1 if adjustTab else 0)
205
+ )
206
+ % 4
207
+ )
208
+ else:
209
+ offset += 1
210
+ else:
211
+ break
212
+
213
+ pos += 1
214
+
215
+ lastLineEmpty = pos >= max
216
+
217
+ oldBSCount.append(state.bsCount[nextLine])
218
+ state.bsCount[nextLine] = (
219
+ state.sCount[nextLine] + 1 + (1 if spaceAfterMarker else 0)
220
+ )
221
+
222
+ oldSCount.append(state.sCount[nextLine])
223
+ state.sCount[nextLine] = offset - initial
224
+
225
+ oldTShift.append(state.tShift[nextLine])
226
+ state.tShift[nextLine] = pos - state.bMarks[nextLine]
227
+
228
+ nextLine += 1
229
+ continue
230
+
231
+ # Case 2: line is not inside the blockquote, and the last line was empty.
232
+ if lastLineEmpty:
233
+ break
234
+
235
+ # Case 3: another tag found.
236
+ terminate = False
237
+
238
+ for terminatorRule in terminatorRules:
239
+ if terminatorRule(state, nextLine, endLine, True):
240
+ terminate = True
241
+ break
242
+
243
+ if terminate:
244
+ # Quirk to enforce "hard termination mode" for paragraphs;
245
+ # normally if you call `tokenize(state, startLine, nextLine)`,
246
+ # paragraphs will look below nextLine for paragraph continuation,
247
+ # but if blockquote is terminated by another tag, they shouldn't
248
+ state.lineMax = nextLine
249
+
250
+ if state.blkIndent != 0:
251
+ # state.blkIndent was non-zero, we now set it to zero,
252
+ # so we need to re-calculate all offsets to appear as
253
+ # if indent wasn't changed
254
+ oldBMarks.append(state.bMarks[nextLine])
255
+ oldBSCount.append(state.bsCount[nextLine])
256
+ oldTShift.append(state.tShift[nextLine])
257
+ oldSCount.append(state.sCount[nextLine])
258
+ state.sCount[nextLine] -= state.blkIndent
259
+
260
+ break
261
+
262
+ oldBMarks.append(state.bMarks[nextLine])
263
+ oldBSCount.append(state.bsCount[nextLine])
264
+ oldTShift.append(state.tShift[nextLine])
265
+ oldSCount.append(state.sCount[nextLine])
266
+
267
+ # A negative indentation means that this is a paragraph continuation
268
+ #
269
+ state.sCount[nextLine] = -1
270
+
271
+ nextLine += 1
272
+
273
+ oldIndent = state.blkIndent
274
+ state.blkIndent = 0
275
+
276
+ token = state.push("blockquote_open", "blockquote", 1)
277
+ token.markup = ">"
278
+ token.map = lines = [startLine, 0]
279
+
280
+ state.md.block.tokenize(state, startLine, nextLine)
281
+
282
+ token = state.push("blockquote_close", "blockquote", -1)
283
+ token.markup = ">"
284
+
285
+ state.lineMax = oldLineMax
286
+ state.parentType = oldParentType
287
+ lines[1] = state.line
288
+
289
+ # Restore original tShift; this might not be necessary since the parser
290
+ # has already been here, but just to make sure we can do that.
291
+ for i, item in enumerate(oldTShift):
292
+ state.bMarks[i + startLine] = oldBMarks[i]
293
+ state.tShift[i + startLine] = item
294
+ state.sCount[i + startLine] = oldSCount[i]
295
+ state.bsCount[i + startLine] = oldBSCount[i]
296
+
297
+ state.blkIndent = oldIndent
298
+
299
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/code.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Code block (4 spaces padded)."""
2
+
3
+ import logging
4
+
5
+ from .state_block import StateBlock
6
+
7
+ LOGGER = logging.getLogger(__name__)
8
+
9
+
10
+ def code(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
11
+ LOGGER.debug("entering code: %s, %s, %s, %s", state, startLine, endLine, silent)
12
+
13
+ if not state.is_code_block(startLine):
14
+ return False
15
+
16
+ last = nextLine = startLine + 1
17
+
18
+ while nextLine < endLine:
19
+ if state.isEmpty(nextLine):
20
+ nextLine += 1
21
+ continue
22
+
23
+ if state.is_code_block(nextLine):
24
+ nextLine += 1
25
+ last = nextLine
26
+ continue
27
+
28
+ break
29
+
30
+ state.line = last
31
+
32
+ token = state.push("code_block", "code", 0)
33
+ token.content = state.getLines(startLine, last, 4 + state.blkIndent, False) + "\n"
34
+ token.map = [startLine, state.line]
35
+
36
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/fence.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # fences (``` lang, ~~~ lang)
2
+ import logging
3
+
4
+ from .state_block import StateBlock
5
+
6
+ LOGGER = logging.getLogger(__name__)
7
+
8
+
9
+ def fence(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
10
+ LOGGER.debug("entering fence: %s, %s, %s, %s", state, startLine, endLine, silent)
11
+
12
+ haveEndMarker = False
13
+ pos = state.bMarks[startLine] + state.tShift[startLine]
14
+ maximum = state.eMarks[startLine]
15
+
16
+ if state.is_code_block(startLine):
17
+ return False
18
+
19
+ if pos + 3 > maximum:
20
+ return False
21
+
22
+ marker = state.src[pos]
23
+
24
+ if marker not in ("~", "`"):
25
+ return False
26
+
27
+ # scan marker length
28
+ mem = pos
29
+ pos = state.skipCharsStr(pos, marker)
30
+
31
+ length = pos - mem
32
+
33
+ if length < 3:
34
+ return False
35
+
36
+ markup = state.src[mem:pos]
37
+ params = state.src[pos:maximum]
38
+
39
+ if marker == "`" and marker in params:
40
+ return False
41
+
42
+ # Since start is found, we can report success here in validation mode
43
+ if silent:
44
+ return True
45
+
46
+ # search end of block
47
+ nextLine = startLine
48
+
49
+ while True:
50
+ nextLine += 1
51
+ if nextLine >= endLine:
52
+ # unclosed block should be autoclosed by end of document.
53
+ # also block seems to be autoclosed by end of parent
54
+ break
55
+
56
+ pos = mem = state.bMarks[nextLine] + state.tShift[nextLine]
57
+ maximum = state.eMarks[nextLine]
58
+
59
+ if pos < maximum and state.sCount[nextLine] < state.blkIndent:
60
+ # non-empty line with negative indent should stop the list:
61
+ # - ```
62
+ # test
63
+ break
64
+
65
+ try:
66
+ if state.src[pos] != marker:
67
+ continue
68
+ except IndexError:
69
+ break
70
+
71
+ if state.is_code_block(nextLine):
72
+ continue
73
+
74
+ pos = state.skipCharsStr(pos, marker)
75
+
76
+ # closing code fence must be at least as long as the opening one
77
+ if pos - mem < length:
78
+ continue
79
+
80
+ # make sure tail has spaces only
81
+ pos = state.skipSpaces(pos)
82
+
83
+ if pos < maximum:
84
+ continue
85
+
86
+ haveEndMarker = True
87
+ # found!
88
+ break
89
+
90
+ # If a fence has heading spaces, they should be removed from its inner block
91
+ length = state.sCount[startLine]
92
+
93
+ state.line = nextLine + (1 if haveEndMarker else 0)
94
+
95
+ token = state.push("fence", "code", 0)
96
+ token.info = params
97
+ token.content = state.getLines(startLine + 1, nextLine, length, True)
98
+ token.markup = markup
99
+ token.map = [startLine, state.line]
100
+
101
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/heading.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Atex heading (#, ##, ...)"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+
7
+ from ..common.utils import isStrSpace
8
+ from .state_block import StateBlock
9
+
10
+ LOGGER = logging.getLogger(__name__)
11
+
12
+
13
+ def heading(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
14
+ LOGGER.debug("entering heading: %s, %s, %s, %s", state, startLine, endLine, silent)
15
+
16
+ pos = state.bMarks[startLine] + state.tShift[startLine]
17
+ maximum = state.eMarks[startLine]
18
+
19
+ if state.is_code_block(startLine):
20
+ return False
21
+
22
+ ch: str | None = state.src[pos]
23
+
24
+ if ch != "#" or pos >= maximum:
25
+ return False
26
+
27
+ # count heading level
28
+ level = 1
29
+ pos += 1
30
+ try:
31
+ ch = state.src[pos]
32
+ except IndexError:
33
+ ch = None
34
+ while ch == "#" and pos < maximum and level <= 6:
35
+ level += 1
36
+ pos += 1
37
+ try:
38
+ ch = state.src[pos]
39
+ except IndexError:
40
+ ch = None
41
+
42
+ if level > 6 or (pos < maximum and not isStrSpace(ch)):
43
+ return False
44
+
45
+ if silent:
46
+ return True
47
+
48
+ # Let's cut tails like ' ### ' from the end of string
49
+
50
+ maximum = state.skipSpacesBack(maximum, pos)
51
+ tmp = state.skipCharsStrBack(maximum, "#", pos)
52
+ if tmp > pos and isStrSpace(state.src[tmp - 1]):
53
+ maximum = tmp
54
+
55
+ state.line = startLine + 1
56
+
57
+ token = state.push("heading_open", "h" + str(level), 1)
58
+ token.markup = "########"[:level]
59
+ token.map = [startLine, state.line]
60
+
61
+ token = state.push("inline", "", 0)
62
+ token.content = state.src[pos:maximum].strip()
63
+ token.map = [startLine, state.line]
64
+ token.children = []
65
+
66
+ token = state.push("heading_close", "h" + str(level), -1)
67
+ token.markup = "########"[:level]
68
+
69
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/hr.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Horizontal rule
2
+
3
+ At least 3 of these characters on a line * - _
4
+ """
5
+
6
+ import logging
7
+
8
+ from ..common.utils import isStrSpace
9
+ from .state_block import StateBlock
10
+
11
+ LOGGER = logging.getLogger(__name__)
12
+
13
+
14
+ def hr(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
15
+ LOGGER.debug("entering hr: %s, %s, %s, %s", state, startLine, endLine, silent)
16
+
17
+ pos = state.bMarks[startLine] + state.tShift[startLine]
18
+ maximum = state.eMarks[startLine]
19
+
20
+ if state.is_code_block(startLine):
21
+ return False
22
+
23
+ try:
24
+ marker = state.src[pos]
25
+ except IndexError:
26
+ return False
27
+ pos += 1
28
+
29
+ # Check hr marker
30
+ if marker not in ("*", "-", "_"):
31
+ return False
32
+
33
+ # markers can be mixed with spaces, but there should be at least 3 of them
34
+
35
+ cnt = 1
36
+ while pos < maximum:
37
+ ch = state.src[pos]
38
+ pos += 1
39
+ if ch != marker and not isStrSpace(ch):
40
+ return False
41
+ if ch == marker:
42
+ cnt += 1
43
+
44
+ if cnt < 3:
45
+ return False
46
+
47
+ if silent:
48
+ return True
49
+
50
+ state.line = startLine + 1
51
+
52
+ token = state.push("hr", "hr", 0)
53
+ token.map = [startLine, state.line]
54
+ token.markup = marker * (cnt + 1)
55
+
56
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/html_block.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HTML block
2
+ from __future__ import annotations
3
+
4
+ import logging
5
+ import re
6
+
7
+ from ..common.html_blocks import block_names
8
+ from ..common.html_re import HTML_OPEN_CLOSE_TAG_STR
9
+ from .state_block import StateBlock
10
+
11
+ LOGGER = logging.getLogger(__name__)
12
+
13
+ # An array of opening and corresponding closing sequences for html tags,
14
+ # last argument defines whether it can terminate a paragraph or not
15
+ HTML_SEQUENCES: list[tuple[re.Pattern[str], re.Pattern[str], bool]] = [
16
+ (
17
+ re.compile(r"^<(script|pre|style|textarea)(?=(\s|>|$))", re.IGNORECASE),
18
+ re.compile(r"<\/(script|pre|style|textarea)>", re.IGNORECASE),
19
+ True,
20
+ ),
21
+ (re.compile(r"^<!--"), re.compile(r"-->"), True),
22
+ (re.compile(r"^<\?"), re.compile(r"\?>"), True),
23
+ (re.compile(r"^<![A-Z]"), re.compile(r">"), True),
24
+ (re.compile(r"^<!\[CDATA\["), re.compile(r"\]\]>"), True),
25
+ (
26
+ re.compile("^</?(" + "|".join(block_names) + ")(?=(\\s|/?>|$))", re.IGNORECASE),
27
+ re.compile(r"^$"),
28
+ True,
29
+ ),
30
+ (re.compile(HTML_OPEN_CLOSE_TAG_STR + "\\s*$"), re.compile(r"^$"), False),
31
+ ]
32
+
33
+
34
+ def html_block(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
35
+ LOGGER.debug(
36
+ "entering html_block: %s, %s, %s, %s", state, startLine, endLine, silent
37
+ )
38
+ pos = state.bMarks[startLine] + state.tShift[startLine]
39
+ maximum = state.eMarks[startLine]
40
+
41
+ if state.is_code_block(startLine):
42
+ return False
43
+
44
+ if not state.md.options.get("html", None):
45
+ return False
46
+
47
+ if state.src[pos] != "<":
48
+ return False
49
+
50
+ lineText = state.src[pos:maximum]
51
+
52
+ html_seq = None
53
+ for HTML_SEQUENCE in HTML_SEQUENCES:
54
+ if HTML_SEQUENCE[0].search(lineText):
55
+ html_seq = HTML_SEQUENCE
56
+ break
57
+
58
+ if not html_seq:
59
+ return False
60
+
61
+ if silent:
62
+ # true if this sequence can be a terminator, false otherwise
63
+ return html_seq[2]
64
+
65
+ nextLine = startLine + 1
66
+
67
+ # If we are here - we detected HTML block.
68
+ # Let's roll down till block end.
69
+ if not html_seq[1].search(lineText):
70
+ while nextLine < endLine:
71
+ if state.sCount[nextLine] < state.blkIndent:
72
+ break
73
+
74
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
75
+ maximum = state.eMarks[nextLine]
76
+ lineText = state.src[pos:maximum]
77
+
78
+ if html_seq[1].search(lineText):
79
+ if len(lineText) != 0:
80
+ nextLine += 1
81
+ break
82
+ nextLine += 1
83
+
84
+ state.line = nextLine
85
+
86
+ token = state.push("html_block", "", 0)
87
+ token.map = [startLine, nextLine]
88
+ token.content = state.getLines(startLine, nextLine, state.blkIndent, True)
89
+
90
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/lheading.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # lheading (---, ==)
2
+ import logging
3
+
4
+ from .state_block import StateBlock
5
+
6
+ LOGGER = logging.getLogger(__name__)
7
+
8
+
9
+ def lheading(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
10
+ LOGGER.debug("entering lheading: %s, %s, %s, %s", state, startLine, endLine, silent)
11
+
12
+ level = None
13
+ nextLine = startLine + 1
14
+ ruler = state.md.block.ruler
15
+ terminatorRules = ruler.getRules("paragraph")
16
+
17
+ if state.is_code_block(startLine):
18
+ return False
19
+
20
+ oldParentType = state.parentType
21
+ state.parentType = "paragraph" # use paragraph to match terminatorRules
22
+
23
+ # jump line-by-line until empty one or EOF
24
+ while nextLine < endLine and not state.isEmpty(nextLine):
25
+ # this would be a code block normally, but after paragraph
26
+ # it's considered a lazy continuation regardless of what's there
27
+ if state.sCount[nextLine] - state.blkIndent > 3:
28
+ nextLine += 1
29
+ continue
30
+
31
+ # Check for underline in setext header
32
+ if state.sCount[nextLine] >= state.blkIndent:
33
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
34
+ maximum = state.eMarks[nextLine]
35
+
36
+ if pos < maximum:
37
+ marker = state.src[pos]
38
+
39
+ if marker in ("-", "="):
40
+ pos = state.skipCharsStr(pos, marker)
41
+ pos = state.skipSpaces(pos)
42
+
43
+ # /* = */
44
+ if pos >= maximum:
45
+ level = 1 if marker == "=" else 2
46
+ break
47
+
48
+ # quirk for blockquotes, this line should already be checked by that rule
49
+ if state.sCount[nextLine] < 0:
50
+ nextLine += 1
51
+ continue
52
+
53
+ # Some tags can terminate paragraph without empty line.
54
+ terminate = False
55
+ for terminatorRule in terminatorRules:
56
+ if terminatorRule(state, nextLine, endLine, True):
57
+ terminate = True
58
+ break
59
+ if terminate:
60
+ break
61
+
62
+ nextLine += 1
63
+
64
+ if not level:
65
+ # Didn't find valid underline
66
+ return False
67
+
68
+ content = state.getLines(startLine, nextLine, state.blkIndent, False).strip()
69
+
70
+ state.line = nextLine + 1
71
+
72
+ token = state.push("heading_open", "h" + str(level), 1)
73
+ token.markup = marker
74
+ token.map = [startLine, state.line]
75
+
76
+ token = state.push("inline", "", 0)
77
+ token.content = content
78
+ token.map = [startLine, state.line - 1]
79
+ token.children = []
80
+
81
+ token = state.push("heading_close", "h" + str(level), -1)
82
+ token.markup = marker
83
+
84
+ state.parentType = oldParentType
85
+
86
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/list.py ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Lists
2
+ import logging
3
+
4
+ from ..common.utils import isStrSpace
5
+ from .state_block import StateBlock
6
+
7
+ LOGGER = logging.getLogger(__name__)
8
+
9
+
10
+ # Search `[-+*][\n ]`, returns next pos after marker on success
11
+ # or -1 on fail.
12
+ def skipBulletListMarker(state: StateBlock, startLine: int) -> int:
13
+ pos = state.bMarks[startLine] + state.tShift[startLine]
14
+ maximum = state.eMarks[startLine]
15
+
16
+ try:
17
+ marker = state.src[pos]
18
+ except IndexError:
19
+ return -1
20
+ pos += 1
21
+
22
+ if marker not in ("*", "-", "+"):
23
+ return -1
24
+
25
+ if pos < maximum:
26
+ ch = state.src[pos]
27
+
28
+ if not isStrSpace(ch):
29
+ # " -test " - is not a list item
30
+ return -1
31
+
32
+ return pos
33
+
34
+
35
+ # Search `\d+[.)][\n ]`, returns next pos after marker on success
36
+ # or -1 on fail.
37
+ def skipOrderedListMarker(state: StateBlock, startLine: int) -> int:
38
+ start = state.bMarks[startLine] + state.tShift[startLine]
39
+ pos = start
40
+ maximum = state.eMarks[startLine]
41
+
42
+ # List marker should have at least 2 chars (digit + dot)
43
+ if pos + 1 >= maximum:
44
+ return -1
45
+
46
+ ch = state.src[pos]
47
+ pos += 1
48
+
49
+ ch_ord = ord(ch)
50
+ # /* 0 */ /* 9 */
51
+ if ch_ord < 0x30 or ch_ord > 0x39:
52
+ return -1
53
+
54
+ while True:
55
+ # EOL -> fail
56
+ if pos >= maximum:
57
+ return -1
58
+
59
+ ch = state.src[pos]
60
+ pos += 1
61
+
62
+ # /* 0 */ /* 9 */
63
+ ch_ord = ord(ch)
64
+ if ch_ord >= 0x30 and ch_ord <= 0x39:
65
+ # List marker should have no more than 9 digits
66
+ # (prevents integer overflow in browsers)
67
+ if pos - start >= 10:
68
+ return -1
69
+
70
+ continue
71
+
72
+ # found valid marker
73
+ if ch in (")", "."):
74
+ break
75
+
76
+ return -1
77
+
78
+ if pos < maximum:
79
+ ch = state.src[pos]
80
+
81
+ if not isStrSpace(ch):
82
+ # " 1.test " - is not a list item
83
+ return -1
84
+
85
+ return pos
86
+
87
+
88
+ def markTightParagraphs(state: StateBlock, idx: int) -> None:
89
+ level = state.level + 2
90
+
91
+ i = idx + 2
92
+ length = len(state.tokens) - 2
93
+ while i < length:
94
+ if state.tokens[i].level == level and state.tokens[i].type == "paragraph_open":
95
+ state.tokens[i + 2].hidden = True
96
+ state.tokens[i].hidden = True
97
+ i += 2
98
+ i += 1
99
+
100
+
101
+ def list_block(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
102
+ LOGGER.debug("entering list: %s, %s, %s, %s", state, startLine, endLine, silent)
103
+
104
+ isTerminatingParagraph = False
105
+ tight = True
106
+
107
+ if state.is_code_block(startLine):
108
+ return False
109
+
110
+ # Special case:
111
+ # - item 1
112
+ # - item 2
113
+ # - item 3
114
+ # - item 4
115
+ # - this one is a paragraph continuation
116
+ if (
117
+ state.listIndent >= 0
118
+ and state.sCount[startLine] - state.listIndent >= 4
119
+ and state.sCount[startLine] < state.blkIndent
120
+ ):
121
+ return False
122
+
123
+ # limit conditions when list can interrupt
124
+ # a paragraph (validation mode only)
125
+ # Next list item should still terminate previous list item
126
+ #
127
+ # This code can fail if plugins use blkIndent as well as lists,
128
+ # but I hope the spec gets fixed long before that happens.
129
+ #
130
+ if (
131
+ silent
132
+ and state.parentType == "paragraph"
133
+ and state.sCount[startLine] >= state.blkIndent
134
+ ):
135
+ isTerminatingParagraph = True
136
+
137
+ # Detect list type and position after marker
138
+ posAfterMarker = skipOrderedListMarker(state, startLine)
139
+ if posAfterMarker >= 0:
140
+ isOrdered = True
141
+ start = state.bMarks[startLine] + state.tShift[startLine]
142
+ markerValue = int(state.src[start : posAfterMarker - 1])
143
+
144
+ # If we're starting a new ordered list right after
145
+ # a paragraph, it should start with 1.
146
+ if isTerminatingParagraph and markerValue != 1:
147
+ return False
148
+ else:
149
+ posAfterMarker = skipBulletListMarker(state, startLine)
150
+ if posAfterMarker >= 0:
151
+ isOrdered = False
152
+ else:
153
+ return False
154
+
155
+ # If we're starting a new unordered list right after
156
+ # a paragraph, first line should not be empty.
157
+ if (
158
+ isTerminatingParagraph
159
+ and state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]
160
+ ):
161
+ return False
162
+
163
+ # We should terminate list on style change. Remember first one to compare.
164
+ markerChar = state.src[posAfterMarker - 1]
165
+
166
+ # For validation mode we can terminate immediately
167
+ if silent:
168
+ return True
169
+
170
+ # Start list
171
+ listTokIdx = len(state.tokens)
172
+
173
+ if isOrdered:
174
+ token = state.push("ordered_list_open", "ol", 1)
175
+ if markerValue != 1:
176
+ token.attrs = {"start": markerValue}
177
+
178
+ else:
179
+ token = state.push("bullet_list_open", "ul", 1)
180
+
181
+ token.map = listLines = [startLine, 0]
182
+ token.markup = markerChar
183
+
184
+ #
185
+ # Iterate list items
186
+ #
187
+
188
+ nextLine = startLine
189
+ prevEmptyEnd = False
190
+ terminatorRules = state.md.block.ruler.getRules("list")
191
+
192
+ oldParentType = state.parentType
193
+ state.parentType = "list"
194
+
195
+ while nextLine < endLine:
196
+ pos = posAfterMarker
197
+ maximum = state.eMarks[nextLine]
198
+
199
+ initial = offset = (
200
+ state.sCount[nextLine]
201
+ + posAfterMarker
202
+ - (state.bMarks[startLine] + state.tShift[startLine])
203
+ )
204
+
205
+ while pos < maximum:
206
+ ch = state.src[pos]
207
+
208
+ if ch == "\t":
209
+ offset += 4 - (offset + state.bsCount[nextLine]) % 4
210
+ elif ch == " ":
211
+ offset += 1
212
+ else:
213
+ break
214
+
215
+ pos += 1
216
+
217
+ contentStart = pos
218
+
219
+ # trimming space in "- \n 3" case, indent is 1 here
220
+ indentAfterMarker = 1 if contentStart >= maximum else offset - initial
221
+
222
+ # If we have more than 4 spaces, the indent is 1
223
+ # (the rest is just indented code block)
224
+ if indentAfterMarker > 4:
225
+ indentAfterMarker = 1
226
+
227
+ # " - test"
228
+ # ^^^^^ - calculating total length of this thing
229
+ indent = initial + indentAfterMarker
230
+
231
+ # Run subparser & write tokens
232
+ token = state.push("list_item_open", "li", 1)
233
+ token.markup = markerChar
234
+ token.map = itemLines = [startLine, 0]
235
+ if isOrdered:
236
+ token.info = state.src[start : posAfterMarker - 1]
237
+
238
+ # change current state, then restore it after parser subcall
239
+ oldTight = state.tight
240
+ oldTShift = state.tShift[startLine]
241
+ oldSCount = state.sCount[startLine]
242
+
243
+ # - example list
244
+ # ^ listIndent position will be here
245
+ # ^ blkIndent position will be here
246
+ #
247
+ oldListIndent = state.listIndent
248
+ state.listIndent = state.blkIndent
249
+ state.blkIndent = indent
250
+
251
+ state.tight = True
252
+ state.tShift[startLine] = contentStart - state.bMarks[startLine]
253
+ state.sCount[startLine] = offset
254
+
255
+ if contentStart >= maximum and state.isEmpty(startLine + 1):
256
+ # workaround for this case
257
+ # (list item is empty, list terminates before "foo"):
258
+ # ~~~~~~~~
259
+ # -
260
+ #
261
+ # foo
262
+ # ~~~~~~~~
263
+ state.line = min(state.line + 2, endLine)
264
+ else:
265
+ # NOTE in list.js this was:
266
+ # state.md.block.tokenize(state, startLine, endLine, True)
267
+ # but tokeniz does not take the final parameter
268
+ state.md.block.tokenize(state, startLine, endLine)
269
+
270
+ # If any of list item is tight, mark list as tight
271
+ if (not state.tight) or prevEmptyEnd:
272
+ tight = False
273
+
274
+ # Item become loose if finish with empty line,
275
+ # but we should filter last element, because it means list finish
276
+ prevEmptyEnd = (state.line - startLine) > 1 and state.isEmpty(state.line - 1)
277
+
278
+ state.blkIndent = state.listIndent
279
+ state.listIndent = oldListIndent
280
+ state.tShift[startLine] = oldTShift
281
+ state.sCount[startLine] = oldSCount
282
+ state.tight = oldTight
283
+
284
+ token = state.push("list_item_close", "li", -1)
285
+ token.markup = markerChar
286
+
287
+ nextLine = startLine = state.line
288
+ itemLines[1] = nextLine
289
+
290
+ if nextLine >= endLine:
291
+ break
292
+
293
+ contentStart = state.bMarks[startLine]
294
+
295
+ #
296
+ # Try to check if list is terminated or continued.
297
+ #
298
+ if state.sCount[nextLine] < state.blkIndent:
299
+ break
300
+
301
+ if state.is_code_block(startLine):
302
+ break
303
+
304
+ # fail if terminating block found
305
+ terminate = False
306
+ for terminatorRule in terminatorRules:
307
+ if terminatorRule(state, nextLine, endLine, True):
308
+ terminate = True
309
+ break
310
+
311
+ if terminate:
312
+ break
313
+
314
+ # fail if list has another type
315
+ if isOrdered:
316
+ posAfterMarker = skipOrderedListMarker(state, nextLine)
317
+ if posAfterMarker < 0:
318
+ break
319
+ start = state.bMarks[nextLine] + state.tShift[nextLine]
320
+ else:
321
+ posAfterMarker = skipBulletListMarker(state, nextLine)
322
+ if posAfterMarker < 0:
323
+ break
324
+
325
+ if markerChar != state.src[posAfterMarker - 1]:
326
+ break
327
+
328
+ # Finalize list
329
+ if isOrdered:
330
+ token = state.push("ordered_list_close", "ol", -1)
331
+ else:
332
+ token = state.push("bullet_list_close", "ul", -1)
333
+
334
+ token.markup = markerChar
335
+
336
+ listLines[1] = nextLine
337
+ state.line = nextLine
338
+
339
+ state.parentType = oldParentType
340
+
341
+ # mark paragraphs tight if needed
342
+ if tight:
343
+ markTightParagraphs(state, listTokIdx)
344
+
345
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/paragraph.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Paragraph."""
2
+
3
+ import logging
4
+
5
+ from .state_block import StateBlock
6
+
7
+ LOGGER = logging.getLogger(__name__)
8
+
9
+
10
+ def paragraph(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
11
+ LOGGER.debug(
12
+ "entering paragraph: %s, %s, %s, %s", state, startLine, endLine, silent
13
+ )
14
+
15
+ nextLine = startLine + 1
16
+ ruler = state.md.block.ruler
17
+ terminatorRules = ruler.getRules("paragraph")
18
+ endLine = state.lineMax
19
+
20
+ oldParentType = state.parentType
21
+ state.parentType = "paragraph"
22
+
23
+ # jump line-by-line until empty one or EOF
24
+ while nextLine < endLine:
25
+ if state.isEmpty(nextLine):
26
+ break
27
+ # this would be a code block normally, but after paragraph
28
+ # it's considered a lazy continuation regardless of what's there
29
+ if state.sCount[nextLine] - state.blkIndent > 3:
30
+ nextLine += 1
31
+ continue
32
+
33
+ # quirk for blockquotes, this line should already be checked by that rule
34
+ if state.sCount[nextLine] < 0:
35
+ nextLine += 1
36
+ continue
37
+
38
+ # Some tags can terminate paragraph without empty line.
39
+ terminate = False
40
+ for terminatorRule in terminatorRules:
41
+ if terminatorRule(state, nextLine, endLine, True):
42
+ terminate = True
43
+ break
44
+
45
+ if terminate:
46
+ break
47
+
48
+ nextLine += 1
49
+
50
+ content = state.getLines(startLine, nextLine, state.blkIndent, False).strip()
51
+
52
+ state.line = nextLine
53
+
54
+ token = state.push("paragraph_open", "p", 1)
55
+ token.map = [startLine, state.line]
56
+
57
+ token = state.push("inline", "", 0)
58
+ token.content = content
59
+ token.map = [startLine, state.line]
60
+ token.children = []
61
+
62
+ token = state.push("paragraph_close", "p", -1)
63
+
64
+ state.parentType = oldParentType
65
+
66
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/reference.py ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
+ from ..common.utils import charCodeAt, isSpace, normalizeReference
4
+ from .state_block import StateBlock
5
+
6
+ LOGGER = logging.getLogger(__name__)
7
+
8
+
9
+ def reference(state: StateBlock, startLine: int, _endLine: int, silent: bool) -> bool:
10
+ LOGGER.debug(
11
+ "entering reference: %s, %s, %s, %s", state, startLine, _endLine, silent
12
+ )
13
+
14
+ pos = state.bMarks[startLine] + state.tShift[startLine]
15
+ maximum = state.eMarks[startLine]
16
+ nextLine = startLine + 1
17
+
18
+ if state.is_code_block(startLine):
19
+ return False
20
+
21
+ if state.src[pos] != "[":
22
+ return False
23
+
24
+ string = state.src[pos : maximum + 1]
25
+
26
+ # string = state.getLines(startLine, nextLine, state.blkIndent, False).strip()
27
+ maximum = len(string)
28
+
29
+ labelEnd = None
30
+ pos = 1
31
+ while pos < maximum:
32
+ ch = charCodeAt(string, pos)
33
+ if ch == 0x5B: # /* [ */
34
+ return False
35
+ elif ch == 0x5D: # /* ] */
36
+ labelEnd = pos
37
+ break
38
+ elif ch == 0x0A: # /* \n */
39
+ if (lineContent := getNextLine(state, nextLine)) is not None:
40
+ string += lineContent
41
+ maximum = len(string)
42
+ nextLine += 1
43
+ elif ch == 0x5C: # /* \ */
44
+ pos += 1
45
+ if (
46
+ pos < maximum
47
+ and charCodeAt(string, pos) == 0x0A
48
+ and (lineContent := getNextLine(state, nextLine)) is not None
49
+ ):
50
+ string += lineContent
51
+ maximum = len(string)
52
+ nextLine += 1
53
+ pos += 1
54
+
55
+ if (
56
+ labelEnd is None or labelEnd < 0 or charCodeAt(string, labelEnd + 1) != 0x3A
57
+ ): # /* : */
58
+ return False
59
+
60
+ # [label]: destination 'title'
61
+ # ^^^ skip optional whitespace here
62
+ pos = labelEnd + 2
63
+ while pos < maximum:
64
+ ch = charCodeAt(string, pos)
65
+ if ch == 0x0A:
66
+ if (lineContent := getNextLine(state, nextLine)) is not None:
67
+ string += lineContent
68
+ maximum = len(string)
69
+ nextLine += 1
70
+ elif isSpace(ch):
71
+ pass
72
+ else:
73
+ break
74
+ pos += 1
75
+
76
+ # [label]: destination 'title'
77
+ # ^^^^^^^^^^^ parse this
78
+ destRes = state.md.helpers.parseLinkDestination(string, pos, maximum)
79
+ if not destRes.ok:
80
+ return False
81
+
82
+ href = state.md.normalizeLink(destRes.str)
83
+ if not state.md.validateLink(href):
84
+ return False
85
+
86
+ pos = destRes.pos
87
+
88
+ # save cursor state, we could require to rollback later
89
+ destEndPos = pos
90
+ destEndLineNo = nextLine
91
+
92
+ # [label]: destination 'title'
93
+ # ^^^ skipping those spaces
94
+ start = pos
95
+ while pos < maximum:
96
+ ch = charCodeAt(string, pos)
97
+ if ch == 0x0A:
98
+ if (lineContent := getNextLine(state, nextLine)) is not None:
99
+ string += lineContent
100
+ maximum = len(string)
101
+ nextLine += 1
102
+ elif isSpace(ch):
103
+ pass
104
+ else:
105
+ break
106
+ pos += 1
107
+
108
+ # [label]: destination 'title'
109
+ # ^^^^^^^ parse this
110
+ titleRes = state.md.helpers.parseLinkTitle(string, pos, maximum, None)
111
+ while titleRes.can_continue:
112
+ if (lineContent := getNextLine(state, nextLine)) is None:
113
+ break
114
+ string += lineContent
115
+ pos = maximum
116
+ maximum = len(string)
117
+ nextLine += 1
118
+ titleRes = state.md.helpers.parseLinkTitle(string, pos, maximum, titleRes)
119
+
120
+ if pos < maximum and start != pos and titleRes.ok:
121
+ title = titleRes.str
122
+ pos = titleRes.pos
123
+ else:
124
+ title = ""
125
+ pos = destEndPos
126
+ nextLine = destEndLineNo
127
+
128
+ # skip trailing spaces until the rest of the line
129
+ while pos < maximum:
130
+ ch = charCodeAt(string, pos)
131
+ if not isSpace(ch):
132
+ break
133
+ pos += 1
134
+
135
+ if pos < maximum and charCodeAt(string, pos) != 0x0A and title:
136
+ # garbage at the end of the line after title,
137
+ # but it could still be a valid reference if we roll back
138
+ title = ""
139
+ pos = destEndPos
140
+ nextLine = destEndLineNo
141
+ while pos < maximum:
142
+ ch = charCodeAt(string, pos)
143
+ if not isSpace(ch):
144
+ break
145
+ pos += 1
146
+
147
+ if pos < maximum and charCodeAt(string, pos) != 0x0A:
148
+ # garbage at the end of the line
149
+ return False
150
+
151
+ label = normalizeReference(string[1:labelEnd])
152
+ if not label:
153
+ # CommonMark 0.20 disallows empty labels
154
+ return False
155
+
156
+ # Reference can not terminate anything. This check is for safety only.
157
+ if silent:
158
+ return True
159
+
160
+ if "references" not in state.env:
161
+ state.env["references"] = {}
162
+
163
+ state.line = nextLine
164
+
165
+ # note, this is not part of markdown-it JS, but is useful for renderers
166
+ if state.md.options.get("inline_definitions", False):
167
+ token = state.push("definition", "", 0)
168
+ token.meta = {
169
+ "id": label,
170
+ "title": title,
171
+ "url": href,
172
+ "label": string[1:labelEnd],
173
+ }
174
+ token.map = [startLine, state.line]
175
+
176
+ if label not in state.env["references"]:
177
+ state.env["references"][label] = {
178
+ "title": title,
179
+ "href": href,
180
+ "map": [startLine, state.line],
181
+ }
182
+ else:
183
+ state.env.setdefault("duplicate_refs", []).append(
184
+ {
185
+ "title": title,
186
+ "href": href,
187
+ "label": label,
188
+ "map": [startLine, state.line],
189
+ }
190
+ )
191
+
192
+ return True
193
+
194
+
195
+ def getNextLine(state: StateBlock, nextLine: int) -> None | str:
196
+ endLine = state.lineMax
197
+
198
+ if nextLine >= endLine or state.isEmpty(nextLine):
199
+ # empty line or end of input
200
+ return None
201
+
202
+ isContinuation = False
203
+
204
+ # this would be a code block normally, but after paragraph
205
+ # it's considered a lazy continuation regardless of what's there
206
+ if state.is_code_block(nextLine):
207
+ isContinuation = True
208
+
209
+ # quirk for blockquotes, this line should already be checked by that rule
210
+ if state.sCount[nextLine] < 0:
211
+ isContinuation = True
212
+
213
+ if not isContinuation:
214
+ terminatorRules = state.md.block.ruler.getRules("reference")
215
+ oldParentType = state.parentType
216
+ state.parentType = "reference"
217
+
218
+ # Some tags can terminate paragraph without empty line.
219
+ terminate = False
220
+ for terminatorRule in terminatorRules:
221
+ if terminatorRule(state, nextLine, endLine, True):
222
+ terminate = True
223
+ break
224
+
225
+ state.parentType = oldParentType
226
+
227
+ if terminate:
228
+ # terminated by another block
229
+ return None
230
+
231
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
232
+ maximum = state.eMarks[nextLine]
233
+
234
+ # max + 1 explicitly includes the newline
235
+ return state.src[pos : maximum + 1]
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/state_block.py ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Literal
4
+
5
+ from ..common.utils import isStrSpace
6
+ from ..ruler import StateBase
7
+ from ..token import Token
8
+ from ..utils import EnvType
9
+
10
+ if TYPE_CHECKING:
11
+ from markdown_it.main import MarkdownIt
12
+
13
+
14
+ class StateBlock(StateBase):
15
+ def __init__(
16
+ self, src: str, md: MarkdownIt, env: EnvType, tokens: list[Token]
17
+ ) -> None:
18
+ self.src = src
19
+
20
+ # link to parser instance
21
+ self.md = md
22
+
23
+ self.env = env
24
+
25
+ #
26
+ # Internal state variables
27
+ #
28
+
29
+ self.tokens = tokens
30
+
31
+ self.bMarks: list[int] = [] # line begin offsets for fast jumps
32
+ self.eMarks: list[int] = [] # line end offsets for fast jumps
33
+ # offsets of the first non-space characters (tabs not expanded)
34
+ self.tShift: list[int] = []
35
+ self.sCount: list[int] = [] # indents for each line (tabs expanded)
36
+
37
+ # An amount of virtual spaces (tabs expanded) between beginning
38
+ # of each line (bMarks) and real beginning of that line.
39
+ #
40
+ # It exists only as a hack because blockquotes override bMarks
41
+ # losing information in the process.
42
+ #
43
+ # It's used only when expanding tabs, you can think about it as
44
+ # an initial tab length, e.g. bsCount=21 applied to string `\t123`
45
+ # means first tab should be expanded to 4-21%4 === 3 spaces.
46
+ #
47
+ self.bsCount: list[int] = []
48
+
49
+ # block parser variables
50
+ self.blkIndent = 0 # required block content indent (for example, if we are
51
+ # inside a list, it would be positioned after list marker)
52
+ self.line = 0 # line index in src
53
+ self.lineMax = 0 # lines count
54
+ self.tight = False # loose/tight mode for lists
55
+ self.ddIndent = -1 # indent of the current dd block (-1 if there isn't any)
56
+ self.listIndent = -1 # indent of the current list block (-1 if there isn't any)
57
+
58
+ # can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
59
+ # used in lists to determine if they interrupt a paragraph
60
+ self.parentType = "root"
61
+
62
+ self.level = 0
63
+
64
+ # renderer
65
+ self.result = ""
66
+
67
+ # Create caches
68
+ # Generate markers.
69
+ indent_found = False
70
+
71
+ start = pos = indent = offset = 0
72
+ length = len(self.src)
73
+
74
+ for pos, character in enumerate(self.src):
75
+ if not indent_found:
76
+ if isStrSpace(character):
77
+ indent += 1
78
+
79
+ if character == "\t":
80
+ offset += 4 - offset % 4
81
+ else:
82
+ offset += 1
83
+ continue
84
+ else:
85
+ indent_found = True
86
+
87
+ if character == "\n" or pos == length - 1:
88
+ if character != "\n":
89
+ pos += 1
90
+ self.bMarks.append(start)
91
+ self.eMarks.append(pos)
92
+ self.tShift.append(indent)
93
+ self.sCount.append(offset)
94
+ self.bsCount.append(0)
95
+
96
+ indent_found = False
97
+ indent = 0
98
+ offset = 0
99
+ start = pos + 1
100
+
101
+ # Push fake entry to simplify cache bounds checks
102
+ self.bMarks.append(length)
103
+ self.eMarks.append(length)
104
+ self.tShift.append(0)
105
+ self.sCount.append(0)
106
+ self.bsCount.append(0)
107
+
108
+ self.lineMax = len(self.bMarks) - 1 # don't count last fake line
109
+
110
+ # pre-check if code blocks are enabled, to speed up is_code_block method
111
+ self._code_enabled = "code" in self.md["block"].ruler.get_active_rules()
112
+
113
+ def __repr__(self) -> str:
114
+ return (
115
+ f"{self.__class__.__name__}"
116
+ f"(line={self.line},level={self.level},tokens={len(self.tokens)})"
117
+ )
118
+
119
+ def push(self, ttype: str, tag: str, nesting: Literal[-1, 0, 1]) -> Token:
120
+ """Push new token to "stream"."""
121
+ token = Token(ttype, tag, nesting)
122
+ token.block = True
123
+ if nesting < 0:
124
+ self.level -= 1 # closing tag
125
+ token.level = self.level
126
+ if nesting > 0:
127
+ self.level += 1 # opening tag
128
+ self.tokens.append(token)
129
+ return token
130
+
131
+ def isEmpty(self, line: int) -> bool:
132
+ """."""
133
+ return (self.bMarks[line] + self.tShift[line]) >= self.eMarks[line]
134
+
135
+ def skipEmptyLines(self, from_pos: int) -> int:
136
+ """."""
137
+ while from_pos < self.lineMax:
138
+ try:
139
+ if (self.bMarks[from_pos] + self.tShift[from_pos]) < self.eMarks[
140
+ from_pos
141
+ ]:
142
+ break
143
+ except IndexError:
144
+ pass
145
+ from_pos += 1
146
+ return from_pos
147
+
148
+ def skipSpaces(self, pos: int) -> int:
149
+ """Skip spaces from given position."""
150
+ while True:
151
+ try:
152
+ current = self.src[pos]
153
+ except IndexError:
154
+ break
155
+ if not isStrSpace(current):
156
+ break
157
+ pos += 1
158
+ return pos
159
+
160
+ def skipSpacesBack(self, pos: int, minimum: int) -> int:
161
+ """Skip spaces from given position in reverse."""
162
+ if pos <= minimum:
163
+ return pos
164
+ while pos > minimum:
165
+ pos -= 1
166
+ if not isStrSpace(self.src[pos]):
167
+ return pos + 1
168
+ return pos
169
+
170
+ def skipChars(self, pos: int, code: int) -> int:
171
+ """Skip character code from given position."""
172
+ while True:
173
+ try:
174
+ current = self.srcCharCode[pos]
175
+ except IndexError:
176
+ break
177
+ if current != code:
178
+ break
179
+ pos += 1
180
+ return pos
181
+
182
+ def skipCharsStr(self, pos: int, ch: str) -> int:
183
+ """Skip character string from given position."""
184
+ while True:
185
+ try:
186
+ current = self.src[pos]
187
+ except IndexError:
188
+ break
189
+ if current != ch:
190
+ break
191
+ pos += 1
192
+ return pos
193
+
194
+ def skipCharsBack(self, pos: int, code: int, minimum: int) -> int:
195
+ """Skip character code reverse from given position - 1."""
196
+ if pos <= minimum:
197
+ return pos
198
+ while pos > minimum:
199
+ pos -= 1
200
+ if code != self.srcCharCode[pos]:
201
+ return pos + 1
202
+ return pos
203
+
204
+ def skipCharsStrBack(self, pos: int, ch: str, minimum: int) -> int:
205
+ """Skip character string reverse from given position - 1."""
206
+ if pos <= minimum:
207
+ return pos
208
+ while pos > minimum:
209
+ pos -= 1
210
+ if ch != self.src[pos]:
211
+ return pos + 1
212
+ return pos
213
+
214
+ def getLines(self, begin: int, end: int, indent: int, keepLastLF: bool) -> str:
215
+ """Cut lines range from source."""
216
+ line = begin
217
+ if begin >= end:
218
+ return ""
219
+
220
+ queue = [""] * (end - begin)
221
+
222
+ i = 1
223
+ while line < end:
224
+ lineIndent = 0
225
+ lineStart = first = self.bMarks[line]
226
+ last = (
227
+ self.eMarks[line] + 1
228
+ if line + 1 < end or keepLastLF
229
+ else self.eMarks[line]
230
+ )
231
+
232
+ while (first < last) and (lineIndent < indent):
233
+ ch = self.src[first]
234
+ if isStrSpace(ch):
235
+ if ch == "\t":
236
+ lineIndent += 4 - (lineIndent + self.bsCount[line]) % 4
237
+ else:
238
+ lineIndent += 1
239
+ elif first - lineStart < self.tShift[line]:
240
+ lineIndent += 1
241
+ else:
242
+ break
243
+ first += 1
244
+
245
+ if lineIndent > indent:
246
+ # partially expanding tabs in code blocks, e.g '\t\tfoobar'
247
+ # with indent=2 becomes ' \tfoobar'
248
+ queue[i - 1] = (" " * (lineIndent - indent)) + self.src[first:last]
249
+ else:
250
+ queue[i - 1] = self.src[first:last]
251
+
252
+ line += 1
253
+ i += 1
254
+
255
+ return "".join(queue)
256
+
257
+ def is_code_block(self, line: int) -> bool:
258
+ """Check if line is a code block,
259
+ i.e. the code block rule is enabled and text is indented by more than 3 spaces.
260
+ """
261
+ return self._code_enabled and (self.sCount[line] - self.blkIndent) >= 4
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_block/table.py ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GFM table, https://github.github.com/gfm/#tables-extension-
2
+ from __future__ import annotations
3
+
4
+ import re
5
+
6
+ from ..common.utils import charStrAt, isStrSpace
7
+ from .state_block import StateBlock
8
+
9
+ headerLineRe = re.compile(r"^:?-+:?$")
10
+ enclosingPipesRe = re.compile(r"^\||\|$")
11
+
12
+ # Limit the amount of empty autocompleted cells in a table,
13
+ # see https://github.com/markdown-it/markdown-it/issues/1000,
14
+ # Both pulldown-cmark and commonmark-hs limit the number of cells this way to ~200k.
15
+ # We set it to 65k, which can expand user input by a factor of x370
16
+ # (256x256 square is 1.8kB expanded into 650kB).
17
+ MAX_AUTOCOMPLETED_CELLS = 0x10000
18
+
19
+
20
+ def getLine(state: StateBlock, line: int) -> str:
21
+ pos = state.bMarks[line] + state.tShift[line]
22
+ maximum = state.eMarks[line]
23
+
24
+ # return state.src.substr(pos, max - pos)
25
+ return state.src[pos:maximum]
26
+
27
+
28
+ def escapedSplit(string: str) -> list[str]:
29
+ result: list[str] = []
30
+ pos = 0
31
+ max = len(string)
32
+ isEscaped = False
33
+ lastPos = 0
34
+ current = ""
35
+ ch = charStrAt(string, pos)
36
+
37
+ while pos < max:
38
+ if ch == "|":
39
+ if not isEscaped:
40
+ # pipe separating cells, '|'
41
+ result.append(current + string[lastPos:pos])
42
+ current = ""
43
+ lastPos = pos + 1
44
+ else:
45
+ # escaped pipe, '\|'
46
+ current += string[lastPos : pos - 1]
47
+ lastPos = pos
48
+
49
+ isEscaped = ch == "\\"
50
+ pos += 1
51
+
52
+ ch = charStrAt(string, pos)
53
+
54
+ result.append(current + string[lastPos:])
55
+
56
+ return result
57
+
58
+
59
+ def table(state: StateBlock, startLine: int, endLine: int, silent: bool) -> bool:
60
+ tbodyLines = None
61
+
62
+ # should have at least two lines
63
+ if startLine + 2 > endLine:
64
+ return False
65
+
66
+ nextLine = startLine + 1
67
+
68
+ if state.sCount[nextLine] < state.blkIndent:
69
+ return False
70
+
71
+ if state.is_code_block(nextLine):
72
+ return False
73
+
74
+ # first character of the second line should be '|', '-', ':',
75
+ # and no other characters are allowed but spaces;
76
+ # basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
77
+
78
+ pos = state.bMarks[nextLine] + state.tShift[nextLine]
79
+ if pos >= state.eMarks[nextLine]:
80
+ return False
81
+ first_ch = state.src[pos]
82
+ pos += 1
83
+ if first_ch not in ("|", "-", ":"):
84
+ return False
85
+
86
+ if pos >= state.eMarks[nextLine]:
87
+ return False
88
+ second_ch = state.src[pos]
89
+ pos += 1
90
+ if second_ch not in ("|", "-", ":") and not isStrSpace(second_ch):
91
+ return False
92
+
93
+ # if first character is '-', then second character must not be a space
94
+ # (due to parsing ambiguity with list)
95
+ if first_ch == "-" and isStrSpace(second_ch):
96
+ return False
97
+
98
+ while pos < state.eMarks[nextLine]:
99
+ ch = state.src[pos]
100
+
101
+ if ch not in ("|", "-", ":") and not isStrSpace(ch):
102
+ return False
103
+
104
+ pos += 1
105
+
106
+ lineText = getLine(state, startLine + 1)
107
+
108
+ columns = lineText.split("|")
109
+ aligns = []
110
+ for i in range(len(columns)):
111
+ t = columns[i].strip()
112
+ if not t:
113
+ # allow empty columns before and after table, but not in between columns;
114
+ # e.g. allow ` |---| `, disallow ` ---||--- `
115
+ if i == 0 or i == len(columns) - 1:
116
+ continue
117
+ else:
118
+ return False
119
+
120
+ if not headerLineRe.search(t):
121
+ return False
122
+ if charStrAt(t, len(t) - 1) == ":":
123
+ aligns.append("center" if charStrAt(t, 0) == ":" else "right")
124
+ elif charStrAt(t, 0) == ":":
125
+ aligns.append("left")
126
+ else:
127
+ aligns.append("")
128
+
129
+ lineText = getLine(state, startLine).strip()
130
+ if "|" not in lineText:
131
+ return False
132
+ if state.is_code_block(startLine):
133
+ return False
134
+ columns = escapedSplit(lineText)
135
+ if columns and columns[0] == "":
136
+ columns.pop(0)
137
+ if columns and columns[-1] == "":
138
+ columns.pop()
139
+
140
+ # header row will define an amount of columns in the entire table,
141
+ # and align row should be exactly the same (the rest of the rows can differ)
142
+ columnCount = len(columns)
143
+ if columnCount == 0 or columnCount != len(aligns):
144
+ return False
145
+
146
+ if silent:
147
+ return True
148
+
149
+ oldParentType = state.parentType
150
+ state.parentType = "table"
151
+
152
+ # use 'blockquote' lists for termination because it's
153
+ # the most similar to tables
154
+ terminatorRules = state.md.block.ruler.getRules("blockquote")
155
+
156
+ token = state.push("table_open", "table", 1)
157
+ token.map = tableLines = [startLine, 0]
158
+
159
+ token = state.push("thead_open", "thead", 1)
160
+ token.map = [startLine, startLine + 1]
161
+
162
+ token = state.push("tr_open", "tr", 1)
163
+ token.map = [startLine, startLine + 1]
164
+
165
+ for i in range(len(columns)):
166
+ token = state.push("th_open", "th", 1)
167
+ if aligns[i]:
168
+ token.attrs = {"style": "text-align:" + aligns[i]}
169
+
170
+ token = state.push("inline", "", 0)
171
+ # note in markdown-it this map was removed in v12.0.0 however, we keep it,
172
+ # since it is helpful to propagate to children tokens
173
+ token.map = [startLine, startLine + 1]
174
+ token.content = columns[i].strip()
175
+ token.children = []
176
+
177
+ token = state.push("th_close", "th", -1)
178
+
179
+ token = state.push("tr_close", "tr", -1)
180
+ token = state.push("thead_close", "thead", -1)
181
+
182
+ autocompleted_cells = 0
183
+ nextLine = startLine + 2
184
+ while nextLine < endLine:
185
+ if state.sCount[nextLine] < state.blkIndent:
186
+ break
187
+
188
+ terminate = False
189
+ for i in range(len(terminatorRules)):
190
+ if terminatorRules[i](state, nextLine, endLine, True):
191
+ terminate = True
192
+ break
193
+
194
+ if terminate:
195
+ break
196
+ lineText = getLine(state, nextLine).strip()
197
+ if not lineText:
198
+ break
199
+ if state.is_code_block(nextLine):
200
+ break
201
+ columns = escapedSplit(lineText)
202
+ if columns and columns[0] == "":
203
+ columns.pop(0)
204
+ if columns and columns[-1] == "":
205
+ columns.pop()
206
+
207
+ # note: autocomplete count can be negative if user specifies more columns than header,
208
+ # but that does not affect intended use (which is limiting expansion)
209
+ autocompleted_cells += columnCount - len(columns)
210
+ if autocompleted_cells > MAX_AUTOCOMPLETED_CELLS:
211
+ break
212
+
213
+ if nextLine == startLine + 2:
214
+ token = state.push("tbody_open", "tbody", 1)
215
+ token.map = tbodyLines = [startLine + 2, 0]
216
+
217
+ token = state.push("tr_open", "tr", 1)
218
+ token.map = [nextLine, nextLine + 1]
219
+
220
+ for i in range(columnCount):
221
+ token = state.push("td_open", "td", 1)
222
+ if aligns[i]:
223
+ token.attrs = {"style": "text-align:" + aligns[i]}
224
+
225
+ token = state.push("inline", "", 0)
226
+ # note in markdown-it this map was removed in v12.0.0 however, we keep it,
227
+ # since it is helpful to propagate to children tokens
228
+ token.map = [nextLine, nextLine + 1]
229
+ try:
230
+ token.content = columns[i].strip() if columns[i] else ""
231
+ except IndexError:
232
+ token.content = ""
233
+ token.children = []
234
+
235
+ token = state.push("td_close", "td", -1)
236
+
237
+ token = state.push("tr_close", "tr", -1)
238
+
239
+ nextLine += 1
240
+
241
+ if tbodyLines:
242
+ token = state.push("tbody_close", "tbody", -1)
243
+ tbodyLines[1] = nextLine
244
+
245
+ token = state.push("table_close", "table", -1)
246
+
247
+ tableLines[1] = nextLine
248
+ state.parentType = oldParentType
249
+ state.line = nextLine
250
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/__init__.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = (
2
+ "StateCore",
3
+ "block",
4
+ "inline",
5
+ "linkify",
6
+ "normalize",
7
+ "replace",
8
+ "smartquotes",
9
+ "text_join",
10
+ )
11
+
12
+ from .block import block
13
+ from .inline import inline
14
+ from .linkify import linkify
15
+ from .normalize import normalize
16
+ from .replacements import replace
17
+ from .smartquotes import smartquotes
18
+ from .state_core import StateCore
19
+ from .text_join import text_join
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/block.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ..token import Token
2
+ from .state_core import StateCore
3
+
4
+
5
+ def block(state: StateCore) -> None:
6
+ if state.inlineMode:
7
+ token = Token("inline", "", 0)
8
+ token.content = state.src
9
+ token.map = [0, 1]
10
+ token.children = []
11
+ state.tokens.append(token)
12
+ else:
13
+ state.md.block.parse(state.src, state.md, state.env, state.tokens)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/inline.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from .state_core import StateCore
2
+
3
+
4
+ def inline(state: StateCore) -> None:
5
+ """Parse inlines"""
6
+ for token in state.tokens:
7
+ if token.type == "inline":
8
+ if token.children is None:
9
+ token.children = []
10
+ state.md.inline.parse(token.content, state.md, state.env, token.children)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/linkify.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from typing import Protocol
5
+
6
+ from ..common.utils import arrayReplaceAt, isLinkClose, isLinkOpen
7
+ from ..token import Token
8
+ from .state_core import StateCore
9
+
10
+ HTTP_RE = re.compile(r"^http://")
11
+ MAILTO_RE = re.compile(r"^mailto:")
12
+ TEST_MAILTO_RE = re.compile(r"^mailto:", flags=re.IGNORECASE)
13
+
14
+
15
+ def linkify(state: StateCore) -> None:
16
+ """Rule for identifying plain-text links."""
17
+ if not state.md.options.linkify:
18
+ return
19
+
20
+ if not state.md.linkify:
21
+ raise ModuleNotFoundError("Linkify enabled but not installed.")
22
+
23
+ for inline_token in state.tokens:
24
+ if inline_token.type != "inline" or not state.md.linkify.pretest(
25
+ inline_token.content
26
+ ):
27
+ continue
28
+
29
+ tokens = inline_token.children
30
+
31
+ htmlLinkLevel = 0
32
+
33
+ # We scan from the end, to keep position when new tags added.
34
+ # Use reversed logic in links start/end match
35
+ assert tokens is not None
36
+ i = len(tokens)
37
+ while i >= 1:
38
+ i -= 1
39
+ assert isinstance(tokens, list)
40
+ currentToken = tokens[i]
41
+
42
+ # Skip content of markdown links
43
+ if currentToken.type == "link_close":
44
+ i -= 1
45
+ while (
46
+ tokens[i].level != currentToken.level
47
+ and tokens[i].type != "link_open"
48
+ ):
49
+ i -= 1
50
+ continue
51
+
52
+ # Skip content of html tag links
53
+ if currentToken.type == "html_inline":
54
+ if isLinkOpen(currentToken.content) and htmlLinkLevel > 0:
55
+ htmlLinkLevel -= 1
56
+ if isLinkClose(currentToken.content):
57
+ htmlLinkLevel += 1
58
+ if htmlLinkLevel > 0:
59
+ continue
60
+
61
+ if currentToken.type == "text" and state.md.linkify.test(
62
+ currentToken.content
63
+ ):
64
+ text = currentToken.content
65
+ links: list[_LinkType] = state.md.linkify.match(text) or []
66
+
67
+ # Now split string to nodes
68
+ nodes = []
69
+ level = currentToken.level
70
+ lastPos = 0
71
+
72
+ # forbid escape sequence at the start of the string,
73
+ # this avoids http\://example.com/ from being linkified as
74
+ # http:<a href="//example.com/">//example.com/</a>
75
+ if (
76
+ links
77
+ and links[0].index == 0
78
+ and i > 0
79
+ and tokens[i - 1].type == "text_special"
80
+ ):
81
+ links = links[1:]
82
+
83
+ for link in links:
84
+ url = link.url
85
+ fullUrl = state.md.normalizeLink(url)
86
+ if not state.md.validateLink(fullUrl):
87
+ continue
88
+
89
+ urlText = link.text
90
+
91
+ # Linkifier might send raw hostnames like "example.com", where url
92
+ # starts with domain name. So we prepend http:// in those cases,
93
+ # and remove it afterwards.
94
+ if not link.schema:
95
+ urlText = HTTP_RE.sub(
96
+ "", state.md.normalizeLinkText("http://" + urlText)
97
+ )
98
+ elif link.schema == "mailto:" and TEST_MAILTO_RE.search(urlText):
99
+ urlText = MAILTO_RE.sub(
100
+ "", state.md.normalizeLinkText("mailto:" + urlText)
101
+ )
102
+ else:
103
+ urlText = state.md.normalizeLinkText(urlText)
104
+
105
+ pos = link.index
106
+
107
+ if pos > lastPos:
108
+ token = Token("text", "", 0)
109
+ token.content = text[lastPos:pos]
110
+ token.level = level
111
+ nodes.append(token)
112
+
113
+ token = Token("link_open", "a", 1)
114
+ token.attrs = {"href": fullUrl}
115
+ token.level = level
116
+ level += 1
117
+ token.markup = "linkify"
118
+ token.info = "auto"
119
+ nodes.append(token)
120
+
121
+ token = Token("text", "", 0)
122
+ token.content = urlText
123
+ token.level = level
124
+ nodes.append(token)
125
+
126
+ token = Token("link_close", "a", -1)
127
+ level -= 1
128
+ token.level = level
129
+ token.markup = "linkify"
130
+ token.info = "auto"
131
+ nodes.append(token)
132
+
133
+ lastPos = link.last_index
134
+
135
+ if lastPos < len(text):
136
+ token = Token("text", "", 0)
137
+ token.content = text[lastPos:]
138
+ token.level = level
139
+ nodes.append(token)
140
+
141
+ inline_token.children = tokens = arrayReplaceAt(tokens, i, nodes)
142
+
143
+
144
+ class _LinkType(Protocol):
145
+ url: str
146
+ text: str
147
+ index: int
148
+ last_index: int
149
+ schema: str | None
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/normalize.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Normalize input string."""
2
+
3
+ import re
4
+
5
+ from .state_core import StateCore
6
+
7
+ # https://spec.commonmark.org/0.29/#line-ending
8
+ NEWLINES_RE = re.compile(r"\r\n?|\n")
9
+ NULL_RE = re.compile(r"\0")
10
+
11
+
12
+ def normalize(state: StateCore) -> None:
13
+ # Normalize newlines
14
+ string = NEWLINES_RE.sub("\n", state.src)
15
+
16
+ # Replace NULL characters
17
+ string = NULL_RE.sub("\ufffd", string)
18
+
19
+ state.src = string
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/replacements.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Simple typographic replacements
2
+
3
+ * ``(c)``, ``(C)`` → ©
4
+ * ``(tm)``, ``(TM)`` → ™
5
+ * ``(r)``, ``(R)`` → ®
6
+ * ``+-`` → ±
7
+ * ``...`` → …
8
+ * ``?....`` → ?..
9
+ * ``!....`` → !..
10
+ * ``????????`` → ???
11
+ * ``!!!!!`` → !!!
12
+ * ``,,,`` → ,
13
+ * ``--`` → &ndash
14
+ * ``---`` → &mdash
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import logging
20
+ import re
21
+
22
+ from ..token import Token
23
+ from .state_core import StateCore
24
+
25
+ LOGGER = logging.getLogger(__name__)
26
+
27
+ # TODO:
28
+ # - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
29
+ # - multiplication 2 x 4 -> 2 × 4
30
+
31
+ RARE_RE = re.compile(r"\+-|\.\.|\?\?\?\?|!!!!|,,|--")
32
+
33
+ # Workaround for phantomjs - need regex without /g flag,
34
+ # or root check will fail every second time
35
+ # SCOPED_ABBR_TEST_RE = r"\((c|tm|r)\)"
36
+
37
+ SCOPED_ABBR_RE = re.compile(r"\((c|tm|r)\)", flags=re.IGNORECASE)
38
+
39
+ PLUS_MINUS_RE = re.compile(r"\+-")
40
+
41
+ ELLIPSIS_RE = re.compile(r"\.{2,}")
42
+
43
+ ELLIPSIS_QUESTION_EXCLAMATION_RE = re.compile(r"([?!])…")
44
+
45
+ QUESTION_EXCLAMATION_RE = re.compile(r"([?!]){4,}")
46
+
47
+ COMMA_RE = re.compile(r",{2,}")
48
+
49
+ EM_DASH_RE = re.compile(r"(^|[^-])---(?=[^-]|$)", flags=re.MULTILINE)
50
+
51
+ EN_DASH_RE = re.compile(r"(^|\s)--(?=\s|$)", flags=re.MULTILINE)
52
+
53
+ EN_DASH_INDENT_RE = re.compile(r"(^|[^-\s])--(?=[^-\s]|$)", flags=re.MULTILINE)
54
+
55
+
56
+ SCOPED_ABBR = {"c": "©", "r": "®", "tm": "™"}
57
+
58
+
59
+ def replaceFn(match: re.Match[str]) -> str:
60
+ return SCOPED_ABBR[match.group(1).lower()]
61
+
62
+
63
+ def replace_scoped(inlineTokens: list[Token]) -> None:
64
+ inside_autolink = 0
65
+
66
+ for token in inlineTokens:
67
+ if token.type == "text" and not inside_autolink:
68
+ token.content = SCOPED_ABBR_RE.sub(replaceFn, token.content)
69
+
70
+ if token.type == "link_open" and token.info == "auto":
71
+ inside_autolink -= 1
72
+
73
+ if token.type == "link_close" and token.info == "auto":
74
+ inside_autolink += 1
75
+
76
+
77
+ def replace_rare(inlineTokens: list[Token]) -> None:
78
+ inside_autolink = 0
79
+
80
+ for token in inlineTokens:
81
+ if (
82
+ token.type == "text"
83
+ and (not inside_autolink)
84
+ and RARE_RE.search(token.content)
85
+ ):
86
+ # +- -> ±
87
+ token.content = PLUS_MINUS_RE.sub("±", token.content)
88
+
89
+ # .., ..., ....... -> …
90
+ token.content = ELLIPSIS_RE.sub("…", token.content)
91
+
92
+ # but ?..... & !..... -> ?.. & !..
93
+ token.content = ELLIPSIS_QUESTION_EXCLAMATION_RE.sub("\\1..", token.content)
94
+ token.content = QUESTION_EXCLAMATION_RE.sub("\\1\\1\\1", token.content)
95
+
96
+ # ,, ,,, ,,,, -> ,
97
+ token.content = COMMA_RE.sub(",", token.content)
98
+
99
+ # em-dash
100
+ token.content = EM_DASH_RE.sub("\\1\u2014", token.content)
101
+
102
+ # en-dash
103
+ token.content = EN_DASH_RE.sub("\\1\u2013", token.content)
104
+ token.content = EN_DASH_INDENT_RE.sub("\\1\u2013", token.content)
105
+
106
+ if token.type == "link_open" and token.info == "auto":
107
+ inside_autolink -= 1
108
+
109
+ if token.type == "link_close" and token.info == "auto":
110
+ inside_autolink += 1
111
+
112
+
113
+ def replace(state: StateCore) -> None:
114
+ if not state.md.options.typographer:
115
+ return
116
+
117
+ for token in state.tokens:
118
+ if token.type != "inline":
119
+ continue
120
+ if token.children is None:
121
+ continue
122
+
123
+ if SCOPED_ABBR_RE.search(token.content):
124
+ replace_scoped(token.children)
125
+
126
+ if RARE_RE.search(token.content):
127
+ replace_rare(token.children)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/smartquotes.py ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Convert straight quotation marks to typographic ones"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import Any
7
+
8
+ from ..common.utils import charCodeAt, isMdAsciiPunct, isPunctChar, isWhiteSpace
9
+ from ..token import Token
10
+ from .state_core import StateCore
11
+
12
+ QUOTE_TEST_RE = re.compile(r"['\"]")
13
+ QUOTE_RE = re.compile(r"['\"]")
14
+ APOSTROPHE = "\u2019" # ’
15
+
16
+
17
+ def replaceAt(string: str, index: int, ch: str) -> str:
18
+ # When the index is negative, the behavior is different from the js version.
19
+ # But basically, the index will not be negative.
20
+ assert index >= 0
21
+ return string[:index] + ch + string[index + 1 :]
22
+
23
+
24
+ def process_inlines(tokens: list[Token], state: StateCore) -> None:
25
+ stack: list[dict[str, Any]] = []
26
+
27
+ for i, token in enumerate(tokens):
28
+ thisLevel = token.level
29
+
30
+ j = 0
31
+ for j in range(len(stack))[::-1]:
32
+ if stack[j]["level"] <= thisLevel:
33
+ break
34
+ else:
35
+ # When the loop is terminated without a "break".
36
+ # Subtract 1 to get the same index as the js version.
37
+ j -= 1
38
+
39
+ stack = stack[: j + 1]
40
+
41
+ if token.type != "text":
42
+ continue
43
+
44
+ text = token.content
45
+ pos = 0
46
+ maximum = len(text)
47
+
48
+ while pos < maximum:
49
+ goto_outer = False
50
+ lastIndex = pos
51
+ t = QUOTE_RE.search(text[lastIndex:])
52
+ if not t:
53
+ break
54
+
55
+ canOpen = canClose = True
56
+ pos = t.start(0) + lastIndex + 1
57
+ isSingle = t.group(0) == "'"
58
+
59
+ # Find previous character,
60
+ # default to space if it's the beginning of the line
61
+ lastChar: None | int = 0x20
62
+
63
+ if t.start(0) + lastIndex - 1 >= 0:
64
+ lastChar = charCodeAt(text, t.start(0) + lastIndex - 1)
65
+ else:
66
+ for j in range(i)[::-1]:
67
+ if tokens[j].type == "softbreak" or tokens[j].type == "hardbreak":
68
+ break
69
+ # should skip all tokens except 'text', 'html_inline' or 'code_inline'
70
+ if not tokens[j].content:
71
+ continue
72
+
73
+ lastChar = charCodeAt(tokens[j].content, len(tokens[j].content) - 1)
74
+ break
75
+
76
+ # Find next character,
77
+ # default to space if it's the end of the line
78
+ nextChar: None | int = 0x20
79
+
80
+ if pos < maximum:
81
+ nextChar = charCodeAt(text, pos)
82
+ else:
83
+ for j in range(i + 1, len(tokens)):
84
+ # nextChar defaults to 0x20
85
+ if tokens[j].type == "softbreak" or tokens[j].type == "hardbreak":
86
+ break
87
+ # should skip all tokens except 'text', 'html_inline' or 'code_inline'
88
+ if not tokens[j].content:
89
+ continue
90
+
91
+ nextChar = charCodeAt(tokens[j].content, 0)
92
+ break
93
+
94
+ isLastPunctChar = lastChar is not None and (
95
+ isMdAsciiPunct(lastChar) or isPunctChar(chr(lastChar))
96
+ )
97
+ isNextPunctChar = nextChar is not None and (
98
+ isMdAsciiPunct(nextChar) or isPunctChar(chr(nextChar))
99
+ )
100
+
101
+ isLastWhiteSpace = lastChar is not None and isWhiteSpace(lastChar)
102
+ isNextWhiteSpace = nextChar is not None and isWhiteSpace(nextChar)
103
+
104
+ if isNextWhiteSpace: # noqa: SIM114
105
+ canOpen = False
106
+ elif isNextPunctChar and not (isLastWhiteSpace or isLastPunctChar):
107
+ canOpen = False
108
+
109
+ if isLastWhiteSpace: # noqa: SIM114
110
+ canClose = False
111
+ elif isLastPunctChar and not (isNextWhiteSpace or isNextPunctChar):
112
+ canClose = False
113
+
114
+ if nextChar == 0x22 and t.group(0) == '"': # 0x22: " # noqa: SIM102
115
+ if (
116
+ lastChar is not None and lastChar >= 0x30 and lastChar <= 0x39
117
+ ): # 0x30: 0, 0x39: 9
118
+ # special case: 1"" - count first quote as an inch
119
+ canClose = canOpen = False
120
+
121
+ if canOpen and canClose:
122
+ # Replace quotes in the middle of punctuation sequence, but not
123
+ # in the middle of the words, i.e.:
124
+ #
125
+ # 1. foo " bar " baz - not replaced
126
+ # 2. foo-"-bar-"-baz - replaced
127
+ # 3. foo"bar"baz - not replaced
128
+ canOpen = isLastPunctChar
129
+ canClose = isNextPunctChar
130
+
131
+ if not canOpen and not canClose:
132
+ # middle of word
133
+ if isSingle:
134
+ token.content = replaceAt(
135
+ token.content, t.start(0) + lastIndex, APOSTROPHE
136
+ )
137
+ continue
138
+
139
+ if canClose:
140
+ # this could be a closing quote, rewind the stack to get a match
141
+ for j in range(len(stack))[::-1]:
142
+ item = stack[j]
143
+ if stack[j]["level"] < thisLevel:
144
+ break
145
+ if item["single"] == isSingle and stack[j]["level"] == thisLevel:
146
+ item = stack[j]
147
+
148
+ if isSingle:
149
+ openQuote = state.md.options.quotes[2]
150
+ closeQuote = state.md.options.quotes[3]
151
+ else:
152
+ openQuote = state.md.options.quotes[0]
153
+ closeQuote = state.md.options.quotes[1]
154
+
155
+ # replace token.content *before* tokens[item.token].content,
156
+ # because, if they are pointing at the same token, replaceAt
157
+ # could mess up indices when quote length != 1
158
+ token.content = replaceAt(
159
+ token.content, t.start(0) + lastIndex, closeQuote
160
+ )
161
+ tokens[item["token"]].content = replaceAt(
162
+ tokens[item["token"]].content, item["pos"], openQuote
163
+ )
164
+
165
+ pos += len(closeQuote) - 1
166
+ if item["token"] == i:
167
+ pos += len(openQuote) - 1
168
+
169
+ text = token.content
170
+ maximum = len(text)
171
+
172
+ stack = stack[:j]
173
+ goto_outer = True
174
+ break
175
+ if goto_outer:
176
+ goto_outer = False
177
+ continue
178
+
179
+ if canOpen:
180
+ stack.append(
181
+ {
182
+ "token": i,
183
+ "pos": t.start(0) + lastIndex,
184
+ "single": isSingle,
185
+ "level": thisLevel,
186
+ }
187
+ )
188
+ elif canClose and isSingle:
189
+ token.content = replaceAt(
190
+ token.content, t.start(0) + lastIndex, APOSTROPHE
191
+ )
192
+
193
+
194
+ def smartquotes(state: StateCore) -> None:
195
+ if not state.md.options.typographer:
196
+ return
197
+
198
+ for token in state.tokens:
199
+ if token.type != "inline" or not QUOTE_RE.search(token.content):
200
+ continue
201
+ if token.children is not None:
202
+ process_inlines(token.children, state)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/state_core.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from ..ruler import StateBase
6
+ from ..token import Token
7
+ from ..utils import EnvType
8
+
9
+ if TYPE_CHECKING:
10
+ from markdown_it import MarkdownIt
11
+
12
+
13
+ class StateCore(StateBase):
14
+ def __init__(
15
+ self,
16
+ src: str,
17
+ md: MarkdownIt,
18
+ env: EnvType,
19
+ tokens: list[Token] | None = None,
20
+ ) -> None:
21
+ self.src = src
22
+ self.md = md # link to parser instance
23
+ self.env = env
24
+ self.tokens: list[Token] = tokens or []
25
+ self.inlineMode = False
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_core/text_join.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Join raw text tokens with the rest of the text
2
+
3
+ This is set as a separate rule to provide an opportunity for plugins
4
+ to run text replacements after text join, but before escape join.
5
+
6
+ For example, `\\:)` shouldn't be replaced with an emoji.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from ..token import Token
12
+ from .state_core import StateCore
13
+
14
+
15
+ def text_join(state: StateCore) -> None:
16
+ """Join raw text for escape sequences (`text_special`) tokens with the rest of the text"""
17
+
18
+ for inline_token in state.tokens[:]:
19
+ if inline_token.type != "inline":
20
+ continue
21
+
22
+ # convert text_special to text and join all adjacent text nodes
23
+ new_tokens: list[Token] = []
24
+ for child_token in inline_token.children or []:
25
+ if child_token.type == "text_special":
26
+ child_token.type = "text"
27
+ if (
28
+ child_token.type == "text"
29
+ and new_tokens
30
+ and new_tokens[-1].type == "text"
31
+ ):
32
+ new_tokens[-1].content += child_token.content
33
+ else:
34
+ new_tokens.append(child_token)
35
+ inline_token.children = new_tokens
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/__init__.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = (
2
+ "StateInline",
3
+ "autolink",
4
+ "backtick",
5
+ "emphasis",
6
+ "entity",
7
+ "escape",
8
+ "fragments_join",
9
+ "html_inline",
10
+ "image",
11
+ "link",
12
+ "link_pairs",
13
+ "linkify",
14
+ "newline",
15
+ "strikethrough",
16
+ "text",
17
+ )
18
+ from . import emphasis, strikethrough
19
+ from .autolink import autolink
20
+ from .backticks import backtick
21
+ from .balance_pairs import link_pairs
22
+ from .entity import entity
23
+ from .escape import escape
24
+ from .fragments_join import fragments_join
25
+ from .html_inline import html_inline
26
+ from .image import image
27
+ from .link import link
28
+ from .linkify import linkify
29
+ from .newline import newline
30
+ from .state_inline import StateInline
31
+ from .text import text
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/autolink.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process autolinks '<protocol:...>'
2
+ import re
3
+
4
+ from .state_inline import StateInline
5
+
6
+ EMAIL_RE = re.compile(
7
+ r"^([a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$"
8
+ )
9
+ AUTOLINK_RE = re.compile(r"^([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)$")
10
+
11
+
12
+ def autolink(state: StateInline, silent: bool) -> bool:
13
+ pos = state.pos
14
+
15
+ if state.src[pos] != "<":
16
+ return False
17
+
18
+ start = state.pos
19
+ maximum = state.posMax
20
+
21
+ while True:
22
+ pos += 1
23
+ if pos >= maximum:
24
+ return False
25
+
26
+ ch = state.src[pos]
27
+
28
+ if ch == "<":
29
+ return False
30
+ if ch == ">":
31
+ break
32
+
33
+ url = state.src[start + 1 : pos]
34
+
35
+ if AUTOLINK_RE.search(url) is not None:
36
+ fullUrl = state.md.normalizeLink(url)
37
+ if not state.md.validateLink(fullUrl):
38
+ return False
39
+
40
+ if not silent:
41
+ token = state.push("link_open", "a", 1)
42
+ token.attrs = {"href": fullUrl}
43
+ token.markup = "autolink"
44
+ token.info = "auto"
45
+
46
+ token = state.push("text", "", 0)
47
+ token.content = state.md.normalizeLinkText(url)
48
+
49
+ token = state.push("link_close", "a", -1)
50
+ token.markup = "autolink"
51
+ token.info = "auto"
52
+
53
+ state.pos += len(url) + 2
54
+ return True
55
+
56
+ if EMAIL_RE.search(url) is not None:
57
+ fullUrl = state.md.normalizeLink("mailto:" + url)
58
+ if not state.md.validateLink(fullUrl):
59
+ return False
60
+
61
+ if not silent:
62
+ token = state.push("link_open", "a", 1)
63
+ token.attrs = {"href": fullUrl}
64
+ token.markup = "autolink"
65
+ token.info = "auto"
66
+
67
+ token = state.push("text", "", 0)
68
+ token.content = state.md.normalizeLinkText(url)
69
+
70
+ token = state.push("link_close", "a", -1)
71
+ token.markup = "autolink"
72
+ token.info = "auto"
73
+
74
+ state.pos += len(url) + 2
75
+ return True
76
+
77
+ return False
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/backticks.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Parse backticks
2
+ import re
3
+
4
+ from .state_inline import StateInline
5
+
6
+ regex = re.compile("^ (.+) $")
7
+
8
+
9
+ def backtick(state: StateInline, silent: bool) -> bool:
10
+ pos = state.pos
11
+
12
+ if state.src[pos] != "`":
13
+ return False
14
+
15
+ start = pos
16
+ pos += 1
17
+ maximum = state.posMax
18
+
19
+ # scan marker length
20
+ while pos < maximum and (state.src[pos] == "`"):
21
+ pos += 1
22
+
23
+ marker = state.src[start:pos]
24
+ openerLength = len(marker)
25
+
26
+ if state.backticksScanned and state.backticks.get(openerLength, 0) <= start:
27
+ if not silent:
28
+ state.pending += marker
29
+ state.pos += openerLength
30
+ return True
31
+
32
+ matchStart = matchEnd = pos
33
+
34
+ # Nothing found in the cache, scan until the end of the line (or until marker is found)
35
+ while True:
36
+ try:
37
+ matchStart = state.src.index("`", matchEnd)
38
+ except ValueError:
39
+ break
40
+ matchEnd = matchStart + 1
41
+
42
+ # scan marker length
43
+ while matchEnd < maximum and (state.src[matchEnd] == "`"):
44
+ matchEnd += 1
45
+
46
+ closerLength = matchEnd - matchStart
47
+
48
+ if closerLength == openerLength:
49
+ # Found matching closer length.
50
+ if not silent:
51
+ token = state.push("code_inline", "code", 0)
52
+ token.markup = marker
53
+ token.content = state.src[pos:matchStart].replace("\n", " ")
54
+ if (
55
+ token.content.startswith(" ")
56
+ and token.content.endswith(" ")
57
+ and len(token.content.strip()) > 0
58
+ ):
59
+ token.content = token.content[1:-1]
60
+ state.pos = matchEnd
61
+ return True
62
+
63
+ # Some different length found, put it in cache as upper limit of where closer can be found
64
+ state.backticks[closerLength] = matchStart
65
+
66
+ # Scanned through the end, didn't find anything
67
+ state.backticksScanned = True
68
+
69
+ if not silent:
70
+ state.pending += marker
71
+ state.pos += openerLength
72
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/balance_pairs.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Balance paired characters (*, _, etc) in inline tokens."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .state_inline import Delimiter, StateInline
6
+
7
+
8
+ def processDelimiters(state: StateInline, delimiters: list[Delimiter]) -> None:
9
+ """For each opening emphasis-like marker find a matching closing one."""
10
+ if not delimiters:
11
+ return
12
+
13
+ openersBottom = {}
14
+ maximum = len(delimiters)
15
+
16
+ # headerIdx is the first delimiter of the current (where closer is) delimiter run
17
+ headerIdx = 0
18
+ lastTokenIdx = -2 # needs any value lower than -1
19
+ jumps: list[int] = []
20
+ closerIdx = 0
21
+ while closerIdx < maximum:
22
+ closer = delimiters[closerIdx]
23
+
24
+ jumps.append(0)
25
+
26
+ # markers belong to same delimiter run if:
27
+ # - they have adjacent tokens
28
+ # - AND markers are the same
29
+ #
30
+ if (
31
+ delimiters[headerIdx].marker != closer.marker
32
+ or lastTokenIdx != closer.token - 1
33
+ ):
34
+ headerIdx = closerIdx
35
+ lastTokenIdx = closer.token
36
+
37
+ # Length is only used for emphasis-specific "rule of 3",
38
+ # if it's not defined (in strikethrough or 3rd party plugins),
39
+ # we can default it to 0 to disable those checks.
40
+ #
41
+ closer.length = closer.length or 0
42
+
43
+ if not closer.close:
44
+ closerIdx += 1
45
+ continue
46
+
47
+ # Previously calculated lower bounds (previous fails)
48
+ # for each marker, each delimiter length modulo 3,
49
+ # and for whether this closer can be an opener;
50
+ # https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
51
+ if closer.marker not in openersBottom:
52
+ openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1]
53
+
54
+ minOpenerIdx = openersBottom[closer.marker][
55
+ (3 if closer.open else 0) + (closer.length % 3)
56
+ ]
57
+
58
+ openerIdx = headerIdx - jumps[headerIdx] - 1
59
+
60
+ newMinOpenerIdx = openerIdx
61
+
62
+ while openerIdx > minOpenerIdx:
63
+ opener = delimiters[openerIdx]
64
+
65
+ if opener.marker != closer.marker:
66
+ openerIdx -= jumps[openerIdx] + 1
67
+ continue
68
+
69
+ if opener.open and opener.end < 0:
70
+ isOddMatch = False
71
+
72
+ # from spec:
73
+ #
74
+ # If one of the delimiters can both open and close emphasis, then the
75
+ # sum of the lengths of the delimiter runs containing the opening and
76
+ # closing delimiters must not be a multiple of 3 unless both lengths
77
+ # are multiples of 3.
78
+ #
79
+ if (
80
+ (opener.close or closer.open)
81
+ and ((opener.length + closer.length) % 3 == 0)
82
+ and (opener.length % 3 != 0 or closer.length % 3 != 0)
83
+ ):
84
+ isOddMatch = True
85
+
86
+ if not isOddMatch:
87
+ # If previous delimiter cannot be an opener, we can safely skip
88
+ # the entire sequence in future checks. This is required to make
89
+ # sure algorithm has linear complexity (see *_*_*_*_*_... case).
90
+ #
91
+ if openerIdx > 0 and not delimiters[openerIdx - 1].open:
92
+ lastJump = jumps[openerIdx - 1] + 1
93
+ else:
94
+ lastJump = 0
95
+
96
+ jumps[closerIdx] = closerIdx - openerIdx + lastJump
97
+ jumps[openerIdx] = lastJump
98
+
99
+ closer.open = False
100
+ opener.end = closerIdx
101
+ opener.close = False
102
+ newMinOpenerIdx = -1
103
+
104
+ # treat next token as start of run,
105
+ # it optimizes skips in **<...>**a**<...>** pathological case
106
+ lastTokenIdx = -2
107
+
108
+ break
109
+
110
+ openerIdx -= jumps[openerIdx] + 1
111
+
112
+ if newMinOpenerIdx != -1:
113
+ # If match for this delimiter run failed, we want to set lower bound for
114
+ # future lookups. This is required to make sure algorithm has linear
115
+ # complexity.
116
+ #
117
+ # See details here:
118
+ # https:#github.com/commonmark/cmark/issues/178#issuecomment-270417442
119
+ #
120
+ openersBottom[closer.marker][
121
+ (3 if closer.open else 0) + ((closer.length or 0) % 3)
122
+ ] = newMinOpenerIdx
123
+
124
+ closerIdx += 1
125
+
126
+
127
+ def link_pairs(state: StateInline) -> None:
128
+ tokens_meta = state.tokens_meta
129
+ maximum = len(state.tokens_meta)
130
+
131
+ processDelimiters(state, state.delimiters)
132
+
133
+ curr = 0
134
+ while curr < maximum:
135
+ curr_meta = tokens_meta[curr]
136
+ if curr_meta and "delimiters" in curr_meta:
137
+ processDelimiters(state, curr_meta["delimiters"])
138
+ curr += 1
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/emphasis.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process *this* and _that_
2
+ #
3
+ from __future__ import annotations
4
+
5
+ from .state_inline import Delimiter, StateInline
6
+
7
+
8
+ def tokenize(state: StateInline, silent: bool) -> bool:
9
+ """Insert each marker as a separate text token, and add it to delimiter list"""
10
+ start = state.pos
11
+ marker = state.src[start]
12
+
13
+ if silent:
14
+ return False
15
+
16
+ if marker not in ("_", "*"):
17
+ return False
18
+
19
+ scanned = state.scanDelims(state.pos, marker == "*")
20
+
21
+ for _ in range(scanned.length):
22
+ token = state.push("text", "", 0)
23
+ token.content = marker
24
+ state.delimiters.append(
25
+ Delimiter(
26
+ marker=ord(marker),
27
+ length=scanned.length,
28
+ token=len(state.tokens) - 1,
29
+ end=-1,
30
+ open=scanned.can_open,
31
+ close=scanned.can_close,
32
+ )
33
+ )
34
+
35
+ state.pos += scanned.length
36
+
37
+ return True
38
+
39
+
40
+ def _postProcess(state: StateInline, delimiters: list[Delimiter]) -> None:
41
+ i = len(delimiters) - 1
42
+ while i >= 0:
43
+ startDelim = delimiters[i]
44
+
45
+ # /* _ */ /* * */
46
+ if startDelim.marker != 0x5F and startDelim.marker != 0x2A:
47
+ i -= 1
48
+ continue
49
+
50
+ # Process only opening markers
51
+ if startDelim.end == -1:
52
+ i -= 1
53
+ continue
54
+
55
+ endDelim = delimiters[startDelim.end]
56
+
57
+ # If the previous delimiter has the same marker and is adjacent to this one,
58
+ # merge those into one strong delimiter.
59
+ #
60
+ # `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
61
+ #
62
+ isStrong = (
63
+ i > 0
64
+ and delimiters[i - 1].end == startDelim.end + 1
65
+ # check that first two markers match and adjacent
66
+ and delimiters[i - 1].marker == startDelim.marker
67
+ and delimiters[i - 1].token == startDelim.token - 1
68
+ # check that last two markers are adjacent (we can safely assume they match)
69
+ and delimiters[startDelim.end + 1].token == endDelim.token + 1
70
+ )
71
+
72
+ ch = chr(startDelim.marker)
73
+
74
+ token = state.tokens[startDelim.token]
75
+ token.type = "strong_open" if isStrong else "em_open"
76
+ token.tag = "strong" if isStrong else "em"
77
+ token.nesting = 1
78
+ token.markup = ch + ch if isStrong else ch
79
+ token.content = ""
80
+
81
+ token = state.tokens[endDelim.token]
82
+ token.type = "strong_close" if isStrong else "em_close"
83
+ token.tag = "strong" if isStrong else "em"
84
+ token.nesting = -1
85
+ token.markup = ch + ch if isStrong else ch
86
+ token.content = ""
87
+
88
+ if isStrong:
89
+ state.tokens[delimiters[i - 1].token].content = ""
90
+ state.tokens[delimiters[startDelim.end + 1].token].content = ""
91
+ i -= 1
92
+
93
+ i -= 1
94
+
95
+
96
+ def postProcess(state: StateInline) -> None:
97
+ """Walk through delimiter list and replace text tokens with tags."""
98
+ _postProcess(state, state.delimiters)
99
+
100
+ for token in state.tokens_meta:
101
+ if token and "delimiters" in token:
102
+ _postProcess(state, token["delimiters"])
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/entity.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process html entity - &#123;, &#xAF;, &quot;, ...
2
+ import re
3
+
4
+ from ..common.entities import entities
5
+ from ..common.utils import fromCodePoint, isValidEntityCode
6
+ from .state_inline import StateInline
7
+
8
+ DIGITAL_RE = re.compile(r"^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));", re.IGNORECASE)
9
+ NAMED_RE = re.compile(r"^&([a-z][a-z0-9]{1,31});", re.IGNORECASE)
10
+
11
+
12
+ def entity(state: StateInline, silent: bool) -> bool:
13
+ pos = state.pos
14
+ maximum = state.posMax
15
+
16
+ if state.src[pos] != "&":
17
+ return False
18
+
19
+ if pos + 1 >= maximum:
20
+ return False
21
+
22
+ if state.src[pos + 1] == "#":
23
+ if match := DIGITAL_RE.search(state.src[pos:]):
24
+ if not silent:
25
+ match1 = match.group(1)
26
+ code = (
27
+ int(match1[1:], 16) if match1[0].lower() == "x" else int(match1, 10)
28
+ )
29
+
30
+ token = state.push("text_special", "", 0)
31
+ token.content = (
32
+ fromCodePoint(code)
33
+ if isValidEntityCode(code)
34
+ else fromCodePoint(0xFFFD)
35
+ )
36
+ token.markup = match.group(0)
37
+ token.info = "entity"
38
+
39
+ state.pos += len(match.group(0))
40
+ return True
41
+
42
+ else:
43
+ if (match := NAMED_RE.search(state.src[pos:])) and match.group(1) in entities:
44
+ if not silent:
45
+ token = state.push("text_special", "", 0)
46
+ token.content = entities[match.group(1)]
47
+ token.markup = match.group(0)
48
+ token.info = "entity"
49
+
50
+ state.pos += len(match.group(0))
51
+ return True
52
+
53
+ return False
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/escape.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Process escaped chars and hardbreaks
3
+ """
4
+
5
+ from ..common.utils import isStrSpace
6
+ from .state_inline import StateInline
7
+
8
+
9
+ def escape(state: StateInline, silent: bool) -> bool:
10
+ """Process escaped chars and hardbreaks."""
11
+ pos = state.pos
12
+ maximum = state.posMax
13
+
14
+ if state.src[pos] != "\\":
15
+ return False
16
+
17
+ pos += 1
18
+
19
+ # '\' at the end of the inline block
20
+ if pos >= maximum:
21
+ return False
22
+
23
+ ch1 = state.src[pos]
24
+ ch1_ord = ord(ch1)
25
+ if ch1 == "\n":
26
+ if not silent:
27
+ state.push("hardbreak", "br", 0)
28
+ pos += 1
29
+ # skip leading whitespaces from next line
30
+ while pos < maximum:
31
+ ch = state.src[pos]
32
+ if not isStrSpace(ch):
33
+ break
34
+ pos += 1
35
+
36
+ state.pos = pos
37
+ return True
38
+
39
+ escapedStr = state.src[pos]
40
+
41
+ if ch1_ord >= 0xD800 and ch1_ord <= 0xDBFF and pos + 1 < maximum:
42
+ ch2 = state.src[pos + 1]
43
+ ch2_ord = ord(ch2)
44
+ if ch2_ord >= 0xDC00 and ch2_ord <= 0xDFFF:
45
+ escapedStr += ch2
46
+ pos += 1
47
+
48
+ origStr = "\\" + escapedStr
49
+
50
+ if not silent:
51
+ token = state.push("text_special", "", 0)
52
+ token.content = escapedStr if ch1 in _ESCAPED else origStr
53
+ token.markup = origStr
54
+ token.info = "escape"
55
+
56
+ state.pos = pos + 1
57
+ return True
58
+
59
+
60
+ _ESCAPED = {
61
+ "!",
62
+ '"',
63
+ "#",
64
+ "$",
65
+ "%",
66
+ "&",
67
+ "'",
68
+ "(",
69
+ ")",
70
+ "*",
71
+ "+",
72
+ ",",
73
+ "-",
74
+ ".",
75
+ "/",
76
+ ":",
77
+ ";",
78
+ "<",
79
+ "=",
80
+ ">",
81
+ "?",
82
+ "@",
83
+ "[",
84
+ "\\",
85
+ "]",
86
+ "^",
87
+ "_",
88
+ "`",
89
+ "{",
90
+ "|",
91
+ "}",
92
+ "~",
93
+ }
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/fragments_join.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .state_inline import StateInline
2
+
3
+
4
+ def fragments_join(state: StateInline) -> None:
5
+ """
6
+ Clean up tokens after emphasis and strikethrough postprocessing:
7
+ merge adjacent text nodes into one and re-calculate all token levels
8
+
9
+ This is necessary because initially emphasis delimiter markers (``*, _, ~``)
10
+ are treated as their own separate text tokens. Then emphasis rule either
11
+ leaves them as text (needed to merge with adjacent text) or turns them
12
+ into opening/closing tags (which messes up levels inside).
13
+ """
14
+ level = 0
15
+ maximum = len(state.tokens)
16
+
17
+ curr = last = 0
18
+ while curr < maximum:
19
+ # re-calculate levels after emphasis/strikethrough turns some text nodes
20
+ # into opening/closing tags
21
+ if state.tokens[curr].nesting < 0:
22
+ level -= 1 # closing tag
23
+ state.tokens[curr].level = level
24
+ if state.tokens[curr].nesting > 0:
25
+ level += 1 # opening tag
26
+
27
+ if (
28
+ state.tokens[curr].type == "text"
29
+ and curr + 1 < maximum
30
+ and state.tokens[curr + 1].type == "text"
31
+ ):
32
+ # collapse two adjacent text nodes
33
+ state.tokens[curr + 1].content = (
34
+ state.tokens[curr].content + state.tokens[curr + 1].content
35
+ )
36
+ else:
37
+ if curr != last:
38
+ state.tokens[last] = state.tokens[curr]
39
+ last += 1
40
+ curr += 1
41
+
42
+ if curr != last:
43
+ del state.tokens[last:]
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/html_inline.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process html tags
2
+ from ..common.html_re import HTML_TAG_RE
3
+ from ..common.utils import isLinkClose, isLinkOpen
4
+ from .state_inline import StateInline
5
+
6
+
7
+ def isLetter(ch: int) -> bool:
8
+ lc = ch | 0x20 # to lower case
9
+ # /* a */ and /* z */
10
+ return (lc >= 0x61) and (lc <= 0x7A)
11
+
12
+
13
+ def html_inline(state: StateInline, silent: bool) -> bool:
14
+ pos = state.pos
15
+
16
+ if not state.md.options.get("html", None):
17
+ return False
18
+
19
+ # Check start
20
+ maximum = state.posMax
21
+ if state.src[pos] != "<" or pos + 2 >= maximum:
22
+ return False
23
+
24
+ # Quick fail on second char
25
+ ch = state.src[pos + 1]
26
+ if ch not in ("!", "?", "/") and not isLetter(ord(ch)): # /* / */
27
+ return False
28
+
29
+ match = HTML_TAG_RE.search(state.src[pos:])
30
+ if not match:
31
+ return False
32
+
33
+ if not silent:
34
+ token = state.push("html_inline", "", 0)
35
+ token.content = state.src[pos : pos + len(match.group(0))]
36
+
37
+ if isLinkOpen(token.content):
38
+ state.linkLevel += 1
39
+ if isLinkClose(token.content):
40
+ state.linkLevel -= 1
41
+
42
+ state.pos += len(match.group(0))
43
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/image.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process ![image](<src> "title")
2
+ from __future__ import annotations
3
+
4
+ from ..common.utils import isStrSpace, normalizeReference
5
+ from ..token import Token
6
+ from .state_inline import StateInline
7
+
8
+
9
+ def image(state: StateInline, silent: bool) -> bool:
10
+ label = None
11
+ href = ""
12
+ oldPos = state.pos
13
+ max = state.posMax
14
+
15
+ if state.src[state.pos] != "!":
16
+ return False
17
+
18
+ if state.pos + 1 < state.posMax and state.src[state.pos + 1] != "[":
19
+ return False
20
+
21
+ labelStart = state.pos + 2
22
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, False)
23
+
24
+ # parser failed to find ']', so it's not a valid link
25
+ if labelEnd < 0:
26
+ return False
27
+
28
+ pos = labelEnd + 1
29
+
30
+ if pos < max and state.src[pos] == "(":
31
+ #
32
+ # Inline link
33
+ #
34
+
35
+ # [link]( <href> "title" )
36
+ # ^^ skipping these spaces
37
+ pos += 1
38
+ while pos < max:
39
+ ch = state.src[pos]
40
+ if not isStrSpace(ch) and ch != "\n":
41
+ break
42
+ pos += 1
43
+
44
+ if pos >= max:
45
+ return False
46
+
47
+ # [link]( <href> "title" )
48
+ # ^^^^^^ parsing link destination
49
+ start = pos
50
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax)
51
+ if res.ok:
52
+ href = state.md.normalizeLink(res.str)
53
+ if state.md.validateLink(href):
54
+ pos = res.pos
55
+ else:
56
+ href = ""
57
+
58
+ # [link]( <href> "title" )
59
+ # ^^ skipping these spaces
60
+ start = pos
61
+ while pos < max:
62
+ ch = state.src[pos]
63
+ if not isStrSpace(ch) and ch != "\n":
64
+ break
65
+ pos += 1
66
+
67
+ # [link]( <href> "title" )
68
+ # ^^^^^^^ parsing link title
69
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax, None)
70
+ if pos < max and start != pos and res.ok:
71
+ title = res.str
72
+ pos = res.pos
73
+
74
+ # [link]( <href> "title" )
75
+ # ^^ skipping these spaces
76
+ while pos < max:
77
+ ch = state.src[pos]
78
+ if not isStrSpace(ch) and ch != "\n":
79
+ break
80
+ pos += 1
81
+ else:
82
+ title = ""
83
+
84
+ if pos >= max or state.src[pos] != ")":
85
+ state.pos = oldPos
86
+ return False
87
+
88
+ pos += 1
89
+
90
+ else:
91
+ #
92
+ # Link reference
93
+ #
94
+ if "references" not in state.env:
95
+ return False
96
+
97
+ # /* [ */
98
+ if pos < max and state.src[pos] == "[":
99
+ start = pos + 1
100
+ pos = state.md.helpers.parseLinkLabel(state, pos)
101
+ if pos >= 0:
102
+ label = state.src[start:pos]
103
+ pos += 1
104
+ else:
105
+ pos = labelEnd + 1
106
+ else:
107
+ pos = labelEnd + 1
108
+
109
+ # covers label == '' and label == undefined
110
+ # (collapsed reference link and shortcut reference link respectively)
111
+ if not label:
112
+ label = state.src[labelStart:labelEnd]
113
+
114
+ label = normalizeReference(label)
115
+
116
+ ref = state.env["references"].get(label, None)
117
+ if not ref:
118
+ state.pos = oldPos
119
+ return False
120
+
121
+ href = ref["href"]
122
+ title = ref["title"]
123
+
124
+ #
125
+ # We found the end of the link, and know for a fact it's a valid link
126
+ # so all that's left to do is to call tokenizer.
127
+ #
128
+ if not silent:
129
+ content = state.src[labelStart:labelEnd]
130
+
131
+ tokens: list[Token] = []
132
+ state.md.inline.parse(content, state.md, state.env, tokens)
133
+
134
+ token = state.push("image", "img", 0)
135
+ token.attrs = {"src": href, "alt": ""}
136
+ token.children = tokens or None
137
+ token.content = content
138
+
139
+ if title:
140
+ token.attrSet("title", title)
141
+
142
+ # note, this is not part of markdown-it JS, but is useful for renderers
143
+ if label and state.md.options.get("store_labels", False):
144
+ token.meta["label"] = label
145
+
146
+ state.pos = pos
147
+ state.posMax = max
148
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/link.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Process [link](<to> "stuff")
2
+
3
+ from ..common.utils import isStrSpace, normalizeReference
4
+ from .state_inline import StateInline
5
+
6
+
7
+ def link(state: StateInline, silent: bool) -> bool:
8
+ href = ""
9
+ title = ""
10
+ label = None
11
+ oldPos = state.pos
12
+ maximum = state.posMax
13
+ start = state.pos
14
+ parseReference = True
15
+
16
+ if state.src[state.pos] != "[":
17
+ return False
18
+
19
+ labelStart = state.pos + 1
20
+ labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, True)
21
+
22
+ # parser failed to find ']', so it's not a valid link
23
+ if labelEnd < 0:
24
+ return False
25
+
26
+ pos = labelEnd + 1
27
+
28
+ if pos < maximum and state.src[pos] == "(":
29
+ #
30
+ # Inline link
31
+ #
32
+
33
+ # might have found a valid shortcut link, disable reference parsing
34
+ parseReference = False
35
+
36
+ # [link]( <href> "title" )
37
+ # ^^ skipping these spaces
38
+ pos += 1
39
+ while pos < maximum:
40
+ ch = state.src[pos]
41
+ if not isStrSpace(ch) and ch != "\n":
42
+ break
43
+ pos += 1
44
+
45
+ if pos >= maximum:
46
+ return False
47
+
48
+ # [link]( <href> "title" )
49
+ # ^^^^^^ parsing link destination
50
+ start = pos
51
+ res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax)
52
+ if res.ok:
53
+ href = state.md.normalizeLink(res.str)
54
+ if state.md.validateLink(href):
55
+ pos = res.pos
56
+ else:
57
+ href = ""
58
+
59
+ # [link]( <href> "title" )
60
+ # ^^ skipping these spaces
61
+ start = pos
62
+ while pos < maximum:
63
+ ch = state.src[pos]
64
+ if not isStrSpace(ch) and ch != "\n":
65
+ break
66
+ pos += 1
67
+
68
+ # [link]( <href> "title" )
69
+ # ^^^^^^^ parsing link title
70
+ res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax)
71
+ if pos < maximum and start != pos and res.ok:
72
+ title = res.str
73
+ pos = res.pos
74
+
75
+ # [link]( <href> "title" )
76
+ # ^^ skipping these spaces
77
+ while pos < maximum:
78
+ ch = state.src[pos]
79
+ if not isStrSpace(ch) and ch != "\n":
80
+ break
81
+ pos += 1
82
+
83
+ if pos >= maximum or state.src[pos] != ")":
84
+ # parsing a valid shortcut link failed, fallback to reference
85
+ parseReference = True
86
+
87
+ pos += 1
88
+
89
+ if parseReference:
90
+ #
91
+ # Link reference
92
+ #
93
+ if "references" not in state.env:
94
+ return False
95
+
96
+ if pos < maximum and state.src[pos] == "[":
97
+ start = pos + 1
98
+ pos = state.md.helpers.parseLinkLabel(state, pos)
99
+ if pos >= 0:
100
+ label = state.src[start:pos]
101
+ pos += 1
102
+ else:
103
+ pos = labelEnd + 1
104
+
105
+ else:
106
+ pos = labelEnd + 1
107
+
108
+ # covers label == '' and label == undefined
109
+ # (collapsed reference link and shortcut reference link respectively)
110
+ if not label:
111
+ label = state.src[labelStart:labelEnd]
112
+
113
+ label = normalizeReference(label)
114
+
115
+ ref = state.env["references"].get(label, None)
116
+ if not ref:
117
+ state.pos = oldPos
118
+ return False
119
+
120
+ href = ref["href"]
121
+ title = ref["title"]
122
+
123
+ #
124
+ # We found the end of the link, and know for a fact it's a valid link
125
+ # so all that's left to do is to call tokenizer.
126
+ #
127
+ if not silent:
128
+ state.pos = labelStart
129
+ state.posMax = labelEnd
130
+
131
+ token = state.push("link_open", "a", 1)
132
+ token.attrs = {"href": href}
133
+
134
+ if title:
135
+ token.attrSet("title", title)
136
+
137
+ # note, this is not part of markdown-it JS, but is useful for renderers
138
+ if label and state.md.options.get("store_labels", False):
139
+ token.meta["label"] = label
140
+
141
+ state.linkLevel += 1
142
+ state.md.inline.tokenize(state)
143
+ state.linkLevel -= 1
144
+
145
+ token = state.push("link_close", "a", -1)
146
+
147
+ state.pos = pos
148
+ state.posMax = maximum
149
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/linkify.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Process links like https://example.org/"""
2
+
3
+ import re
4
+
5
+ from .state_inline import StateInline
6
+
7
+ # RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
8
+ SCHEME_RE = re.compile(r"(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$", re.IGNORECASE)
9
+
10
+
11
+ def linkify(state: StateInline, silent: bool) -> bool:
12
+ """Rule for identifying plain-text links."""
13
+ if not state.md.options.linkify:
14
+ return False
15
+ if state.linkLevel > 0:
16
+ return False
17
+ if not state.md.linkify:
18
+ raise ModuleNotFoundError("Linkify enabled but not installed.")
19
+
20
+ pos = state.pos
21
+ maximum = state.posMax
22
+
23
+ if (
24
+ (pos + 3) > maximum
25
+ or state.src[pos] != ":"
26
+ or state.src[pos + 1] != "/"
27
+ or state.src[pos + 2] != "/"
28
+ ):
29
+ return False
30
+
31
+ if not (match := SCHEME_RE.search(state.pending)):
32
+ return False
33
+
34
+ proto = match.group(1)
35
+ if not (link := state.md.linkify.match_at_start(state.src[pos - len(proto) :])):
36
+ return False
37
+ url: str = link.url
38
+
39
+ # disallow '*' at the end of the link (conflicts with emphasis)
40
+ url = url.rstrip("*")
41
+
42
+ full_url = state.md.normalizeLink(url)
43
+ if not state.md.validateLink(full_url):
44
+ return False
45
+
46
+ if not silent:
47
+ state.pending = state.pending[: -len(proto)]
48
+
49
+ token = state.push("link_open", "a", 1)
50
+ token.attrs = {"href": full_url}
51
+ token.markup = "linkify"
52
+ token.info = "auto"
53
+
54
+ token = state.push("text", "", 0)
55
+ token.content = state.md.normalizeLinkText(url)
56
+
57
+ token = state.push("link_close", "a", -1)
58
+ token.markup = "linkify"
59
+ token.info = "auto"
60
+
61
+ state.pos += len(url) - len(proto)
62
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/newline.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Proceess '\n'."""
2
+
3
+ from ..common.utils import charStrAt, isStrSpace
4
+ from .state_inline import StateInline
5
+
6
+
7
+ def newline(state: StateInline, silent: bool) -> bool:
8
+ pos = state.pos
9
+
10
+ if state.src[pos] != "\n":
11
+ return False
12
+
13
+ pmax = len(state.pending) - 1
14
+ maximum = state.posMax
15
+
16
+ # ' \n' -> hardbreak
17
+ # Lookup in pending chars is bad practice! Don't copy to other rules!
18
+ # Pending string is stored in concat mode, indexed lookups will cause
19
+ # conversion to flat mode.
20
+ if not silent:
21
+ if pmax >= 0 and charStrAt(state.pending, pmax) == " ":
22
+ if pmax >= 1 and charStrAt(state.pending, pmax - 1) == " ":
23
+ # Find whitespaces tail of pending chars.
24
+ ws = pmax - 1
25
+ while ws >= 1 and charStrAt(state.pending, ws - 1) == " ":
26
+ ws -= 1
27
+ state.pending = state.pending[:ws]
28
+
29
+ state.push("hardbreak", "br", 0)
30
+ else:
31
+ state.pending = state.pending[:-1]
32
+ state.push("softbreak", "br", 0)
33
+
34
+ else:
35
+ state.push("softbreak", "br", 0)
36
+
37
+ pos += 1
38
+
39
+ # skip heading spaces for next line
40
+ while pos < maximum and isStrSpace(state.src[pos]):
41
+ pos += 1
42
+
43
+ state.pos = pos
44
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/state_inline.py ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from collections import namedtuple
4
+ from dataclasses import dataclass
5
+ from typing import TYPE_CHECKING, Any, Literal
6
+
7
+ from ..common.utils import isMdAsciiPunct, isPunctChar, isWhiteSpace
8
+ from ..ruler import StateBase
9
+ from ..token import Token
10
+ from ..utils import EnvType
11
+
12
+ if TYPE_CHECKING:
13
+ from markdown_it import MarkdownIt
14
+
15
+
16
+ @dataclass(slots=True)
17
+ class Delimiter:
18
+ # Char code of the starting marker (number).
19
+ marker: int
20
+
21
+ # Total length of these series of delimiters.
22
+ length: int
23
+
24
+ # A position of the token this delimiter corresponds to.
25
+ token: int
26
+
27
+ # If this delimiter is matched as a valid opener, `end` will be
28
+ # equal to its position, otherwise it's `-1`.
29
+ end: int
30
+
31
+ # Boolean flags that determine if this delimiter could open or close
32
+ # an emphasis.
33
+ open: bool
34
+ close: bool
35
+
36
+ level: bool | None = None
37
+
38
+
39
+ Scanned = namedtuple("Scanned", ["can_open", "can_close", "length"])
40
+
41
+
42
+ class StateInline(StateBase):
43
+ def __init__(
44
+ self, src: str, md: MarkdownIt, env: EnvType, outTokens: list[Token]
45
+ ) -> None:
46
+ self.src = src
47
+ self.env = env
48
+ self.md = md
49
+ self.tokens = outTokens
50
+ self.tokens_meta: list[dict[str, Any] | None] = [None] * len(outTokens)
51
+
52
+ self.pos = 0
53
+ self.posMax = len(self.src)
54
+ self.level = 0
55
+ self.pending = ""
56
+ self.pendingLevel = 0
57
+
58
+ # Stores { start: end } pairs. Useful for backtrack
59
+ # optimization of pairs parse (emphasis, strikes).
60
+ self.cache: dict[int, int] = {}
61
+
62
+ # List of emphasis-like delimiters for current tag
63
+ self.delimiters: list[Delimiter] = []
64
+
65
+ # Stack of delimiter lists for upper level tags
66
+ self._prev_delimiters: list[list[Delimiter]] = []
67
+
68
+ # backticklength => last seen position
69
+ self.backticks: dict[int, int] = {}
70
+ self.backticksScanned = False
71
+
72
+ # Counter used to disable inline linkify-it execution
73
+ # inside <a> and markdown links
74
+ self.linkLevel = 0
75
+
76
+ def __repr__(self) -> str:
77
+ return (
78
+ f"{self.__class__.__name__}"
79
+ f"(pos=[{self.pos} of {self.posMax}], token={len(self.tokens)})"
80
+ )
81
+
82
+ def pushPending(self) -> Token:
83
+ token = Token("text", "", 0)
84
+ token.content = self.pending
85
+ token.level = self.pendingLevel
86
+ self.tokens.append(token)
87
+ self.pending = ""
88
+ return token
89
+
90
+ def push(self, ttype: str, tag: str, nesting: Literal[-1, 0, 1]) -> Token:
91
+ """Push new token to "stream".
92
+ If pending text exists - flush it as text token
93
+ """
94
+ if self.pending:
95
+ self.pushPending()
96
+
97
+ token = Token(ttype, tag, nesting)
98
+ token_meta = None
99
+
100
+ if nesting < 0:
101
+ # closing tag
102
+ self.level -= 1
103
+ self.delimiters = self._prev_delimiters.pop()
104
+
105
+ token.level = self.level
106
+
107
+ if nesting > 0:
108
+ # opening tag
109
+ self.level += 1
110
+ self._prev_delimiters.append(self.delimiters)
111
+ self.delimiters = []
112
+ token_meta = {"delimiters": self.delimiters}
113
+
114
+ self.pendingLevel = self.level
115
+ self.tokens.append(token)
116
+ self.tokens_meta.append(token_meta)
117
+ return token
118
+
119
+ def scanDelims(self, start: int, canSplitWord: bool) -> Scanned:
120
+ """
121
+ Scan a sequence of emphasis-like markers, and determine whether
122
+ it can start an emphasis sequence or end an emphasis sequence.
123
+
124
+ - start - position to scan from (it should point at a valid marker);
125
+ - canSplitWord - determine if these markers can be found inside a word
126
+
127
+ """
128
+ pos = start
129
+ maximum = self.posMax
130
+ marker = self.src[start]
131
+
132
+ # treat beginning of the line as a whitespace
133
+ lastChar = self.src[start - 1] if start > 0 else " "
134
+
135
+ while pos < maximum and self.src[pos] == marker:
136
+ pos += 1
137
+
138
+ count = pos - start
139
+
140
+ # treat end of the line as a whitespace
141
+ nextChar = self.src[pos] if pos < maximum else " "
142
+
143
+ isLastPunctChar = isMdAsciiPunct(ord(lastChar)) or isPunctChar(lastChar)
144
+ isNextPunctChar = isMdAsciiPunct(ord(nextChar)) or isPunctChar(nextChar)
145
+
146
+ isLastWhiteSpace = isWhiteSpace(ord(lastChar))
147
+ isNextWhiteSpace = isWhiteSpace(ord(nextChar))
148
+
149
+ left_flanking = not (
150
+ isNextWhiteSpace
151
+ or (isNextPunctChar and not (isLastWhiteSpace or isLastPunctChar))
152
+ )
153
+ right_flanking = not (
154
+ isLastWhiteSpace
155
+ or (isLastPunctChar and not (isNextWhiteSpace or isNextPunctChar))
156
+ )
157
+
158
+ can_open = left_flanking and (
159
+ canSplitWord or (not right_flanking) or isLastPunctChar
160
+ )
161
+ can_close = right_flanking and (
162
+ canSplitWord or (not left_flanking) or isNextPunctChar
163
+ )
164
+
165
+ return Scanned(can_open, can_close, count)
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/strikethrough.py ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ~~strike through~~
2
+ from __future__ import annotations
3
+
4
+ from .state_inline import Delimiter, StateInline
5
+
6
+
7
+ def tokenize(state: StateInline, silent: bool) -> bool:
8
+ """Insert each marker as a separate text token, and add it to delimiter list"""
9
+ start = state.pos
10
+ ch = state.src[start]
11
+
12
+ if silent:
13
+ return False
14
+
15
+ if ch != "~":
16
+ return False
17
+
18
+ scanned = state.scanDelims(state.pos, True)
19
+ length = scanned.length
20
+
21
+ if length < 2:
22
+ return False
23
+
24
+ if length % 2:
25
+ token = state.push("text", "", 0)
26
+ token.content = ch
27
+ length -= 1
28
+
29
+ i = 0
30
+ while i < length:
31
+ token = state.push("text", "", 0)
32
+ token.content = ch + ch
33
+ state.delimiters.append(
34
+ Delimiter(
35
+ marker=ord(ch),
36
+ length=0, # disable "rule of 3" length checks meant for emphasis
37
+ token=len(state.tokens) - 1,
38
+ end=-1,
39
+ open=scanned.can_open,
40
+ close=scanned.can_close,
41
+ )
42
+ )
43
+
44
+ i += 2
45
+
46
+ state.pos += scanned.length
47
+
48
+ return True
49
+
50
+
51
+ def _postProcess(state: StateInline, delimiters: list[Delimiter]) -> None:
52
+ loneMarkers = []
53
+ maximum = len(delimiters)
54
+
55
+ i = 0
56
+ while i < maximum:
57
+ startDelim = delimiters[i]
58
+
59
+ if startDelim.marker != 0x7E: # /* ~ */
60
+ i += 1
61
+ continue
62
+
63
+ if startDelim.end == -1:
64
+ i += 1
65
+ continue
66
+
67
+ endDelim = delimiters[startDelim.end]
68
+
69
+ token = state.tokens[startDelim.token]
70
+ token.type = "s_open"
71
+ token.tag = "s"
72
+ token.nesting = 1
73
+ token.markup = "~~"
74
+ token.content = ""
75
+
76
+ token = state.tokens[endDelim.token]
77
+ token.type = "s_close"
78
+ token.tag = "s"
79
+ token.nesting = -1
80
+ token.markup = "~~"
81
+ token.content = ""
82
+
83
+ if (
84
+ state.tokens[endDelim.token - 1].type == "text"
85
+ and state.tokens[endDelim.token - 1].content == "~"
86
+ ):
87
+ loneMarkers.append(endDelim.token - 1)
88
+
89
+ i += 1
90
+
91
+ # If a marker sequence has an odd number of characters, it's split
92
+ # like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
93
+ # start of the sequence.
94
+ #
95
+ # So, we have to move all those markers after subsequent s_close tags.
96
+ #
97
+ while loneMarkers:
98
+ i = loneMarkers.pop()
99
+ j = i + 1
100
+
101
+ while (j < len(state.tokens)) and (state.tokens[j].type == "s_close"):
102
+ j += 1
103
+
104
+ j -= 1
105
+
106
+ if i != j:
107
+ token = state.tokens[j]
108
+ state.tokens[j] = state.tokens[i]
109
+ state.tokens[i] = token
110
+
111
+
112
+ def postProcess(state: StateInline) -> None:
113
+ """Walk through delimiter list and replace text tokens with tags."""
114
+ tokens_meta = state.tokens_meta
115
+ maximum = len(state.tokens_meta)
116
+ _postProcess(state, state.delimiters)
117
+
118
+ curr = 0
119
+ while curr < maximum:
120
+ try:
121
+ curr_meta = tokens_meta[curr]
122
+ except IndexError:
123
+ pass
124
+ else:
125
+ if curr_meta and "delimiters" in curr_meta:
126
+ _postProcess(state, curr_meta["delimiters"])
127
+ curr += 1
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it/rules_inline/text.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import functools
2
+ import re
3
+
4
+ # Skip text characters for text token, place those to pending buffer
5
+ # and increment current pos
6
+ from .state_inline import StateInline
7
+
8
+ # Rule to skip pure text
9
+ # '{}$%@~+=:' reserved for extensions
10
+
11
+ # !!!! Don't confuse with "Markdown ASCII Punctuation" chars
12
+ # http://spec.commonmark.org/0.15/#ascii-punctuation-character
13
+
14
+
15
+ _TerminatorChars = {
16
+ "\n",
17
+ "!",
18
+ "#",
19
+ "$",
20
+ "%",
21
+ "&",
22
+ "*",
23
+ "+",
24
+ "-",
25
+ ":",
26
+ "<",
27
+ "=",
28
+ ">",
29
+ "@",
30
+ "[",
31
+ "\\",
32
+ "]",
33
+ "^",
34
+ "_",
35
+ "`",
36
+ "{",
37
+ "}",
38
+ "~",
39
+ }
40
+
41
+
42
+ @functools.cache
43
+ def _terminator_char_regex() -> re.Pattern[str]:
44
+ return re.compile("[" + re.escape("".join(_TerminatorChars)) + "]")
45
+
46
+
47
+ def text(state: StateInline, silent: bool) -> bool:
48
+ pos = state.pos
49
+ posMax = state.posMax
50
+
51
+ terminator_char = _terminator_char_regex().search(state.src, pos)
52
+ pos = terminator_char.start() if terminator_char else posMax
53
+
54
+ if pos == state.pos:
55
+ return False
56
+
57
+ if not silent:
58
+ state.pending += state.src[state.pos : pos]
59
+
60
+ state.pos = pos
61
+
62
+ return True
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it_py-4.0.0.dist-info/licenses/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 ExecutableBookProject
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
.cache/uv/archive-v0/stEFd4LKHEV6adioKT2Qf/markdown_it_py-4.0.0.dist-info/licenses/LICENSE.markdown-it ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.