mistune 3.3.0__tar.gz → 3.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. {mistune-3.3.0 → mistune-3.3.2}/PKG-INFO +1 -1
  2. {mistune-3.3.0 → mistune-3.3.2}/docs/changes.rst +16 -0
  3. {mistune-3.3.0 → mistune-3.3.2}/pyproject.toml +1 -1
  4. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/__init__.py +1 -1
  5. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/include.py +1 -0
  6. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/inline_parser.py +2 -0
  7. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/list_parser.py +4 -4
  8. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/abbr.py +42 -8
  9. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/PKG-INFO +1 -1
  10. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/abbr.txt +20 -0
  11. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_include.py +4 -4
  12. {mistune-3.3.0 → mistune-3.3.2}/LICENSE +0 -0
  13. {mistune-3.3.0 → mistune-3.3.2}/MANIFEST.in +0 -0
  14. {mistune-3.3.0 → mistune-3.3.2}/README.rst +0 -0
  15. {mistune-3.3.0 → mistune-3.3.2}/benchmark/bench.py +0 -0
  16. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/atx.txt +0 -0
  17. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/auto_links.txt +0 -0
  18. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/blockcode.txt +0 -0
  19. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/blockhtml.txt +0 -0
  20. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/blockquote.txt +0 -0
  21. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/emphasis.txt +0 -0
  22. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/fenced.txt +0 -0
  23. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/insane_ol.txt +0 -0
  24. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/insane_ul.txt +0 -0
  25. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/normal_ol.txt +0 -0
  26. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/normal_ul.txt +0 -0
  27. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/paragraph.txt +0 -0
  28. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/ref_links.txt +0 -0
  29. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/setext.txt +0 -0
  30. {mistune-3.3.0 → mistune-3.3.2}/benchmark/cases/std_links.txt +0 -0
  31. {mistune-3.3.0 → mistune-3.3.2}/docs/Makefile +0 -0
  32. {mistune-3.3.0 → mistune-3.3.2}/docs/_static/dark-icon.svg +0 -0
  33. {mistune-3.3.0 → mistune-3.3.2}/docs/_static/light-icon.svg +0 -0
  34. {mistune-3.3.0 → mistune-3.3.2}/docs/_static/logo-black.svg +0 -0
  35. {mistune-3.3.0 → mistune-3.3.2}/docs/_static/logo-white.svg +0 -0
  36. {mistune-3.3.0 → mistune-3.3.2}/docs/_templates/partials/extra-foot.html +0 -0
  37. {mistune-3.3.0 → mistune-3.3.2}/docs/_templates/partials/globaltoc-above.html +0 -0
  38. {mistune-3.3.0 → mistune-3.3.2}/docs/advanced.rst +0 -0
  39. {mistune-3.3.0 → mistune-3.3.2}/docs/api.rst +0 -0
  40. {mistune-3.3.0 → mistune-3.3.2}/docs/cli.rst +0 -0
  41. {mistune-3.3.0 → mistune-3.3.2}/docs/community.rst +0 -0
  42. {mistune-3.3.0 → mistune-3.3.2}/docs/conf.py +0 -0
  43. {mistune-3.3.0 → mistune-3.3.2}/docs/directives.rst +0 -0
  44. {mistune-3.3.0 → mistune-3.3.2}/docs/guide.rst +0 -0
  45. {mistune-3.3.0 → mistune-3.3.2}/docs/index.rst +0 -0
  46. {mistune-3.3.0 → mistune-3.3.2}/docs/plugins.rst +0 -0
  47. {mistune-3.3.0 → mistune-3.3.2}/docs/renderers.rst +0 -0
  48. {mistune-3.3.0 → mistune-3.3.2}/docs/upgrade.rst +0 -0
  49. {mistune-3.3.0 → mistune-3.3.2}/setup.cfg +0 -0
  50. {mistune-3.3.0 → mistune-3.3.2}/setup.py +0 -0
  51. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/__main__.py +0 -0
  52. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/block_parser.py +0 -0
  53. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/core.py +0 -0
  54. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/__init__.py +0 -0
  55. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/_base.py +0 -0
  56. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/_fenced.py +0 -0
  57. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/_rst.py +0 -0
  58. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/admonition.py +0 -0
  59. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/image.py +0 -0
  60. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/directives/toc.py +0 -0
  61. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/helpers.py +0 -0
  62. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/markdown.py +0 -0
  63. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/__init__.py +0 -0
  64. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/def_list.py +0 -0
  65. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/footnotes.py +0 -0
  66. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/formatting.py +0 -0
  67. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/math.py +0 -0
  68. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/ruby.py +0 -0
  69. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/speedup.py +0 -0
  70. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/spoiler.py +0 -0
  71. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/table.py +0 -0
  72. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/task_lists.py +0 -0
  73. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/plugins/url.py +0 -0
  74. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/py.typed +0 -0
  75. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/renderers/__init__.py +0 -0
  76. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/renderers/_list.py +0 -0
  77. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/renderers/html.py +0 -0
  78. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/renderers/markdown.py +0 -0
  79. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/renderers/rst.py +0 -0
  80. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/toc.py +0 -0
  81. {mistune-3.3.0 → mistune-3.3.2}/src/mistune/util.py +0 -0
  82. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/SOURCES.txt +0 -0
  83. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/dependency_links.txt +0 -0
  84. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/entry_points.txt +0 -0
  85. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/requires.txt +0 -0
  86. {mistune-3.3.0 → mistune-3.3.2}/src/mistune.egg-info/top_level.txt +0 -0
  87. {mistune-3.3.0 → mistune-3.3.2}/tests/__init__.py +0 -0
  88. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/__init__.py +0 -0
  89. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/cli.txt +0 -0
  90. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/commonmark.json +0 -0
  91. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/def_list.txt +0 -0
  92. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/fenced_admonition.txt +0 -0
  93. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/fenced_figure.txt +0 -0
  94. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/fenced_image.txt +0 -0
  95. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/fenced_toc.txt +0 -0
  96. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/fix-commonmark.txt +0 -0
  97. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/footnotes.txt +0 -0
  98. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/hook_toc.txt +0 -0
  99. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/include/hello.md +0 -0
  100. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/include/hello.txt +0 -0
  101. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/include/text.html +0 -0
  102. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/include/text.md +0 -0
  103. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/insert.txt +0 -0
  104. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/mark.txt +0 -0
  105. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/math.txt +0 -0
  106. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/renderer_markdown.txt +0 -0
  107. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/renderer_rst.txt +0 -0
  108. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/rst_admonition.txt +0 -0
  109. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/rst_toc.txt +0 -0
  110. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/ruby.txt +0 -0
  111. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/spoiler.txt +0 -0
  112. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/strikethrough.txt +0 -0
  113. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/subscript.txt +0 -0
  114. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/superscript.txt +0 -0
  115. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/table.txt +0 -0
  116. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/task_lists.txt +0 -0
  117. {mistune-3.3.0 → mistune-3.3.2}/tests/fixtures/url.txt +0 -0
  118. {mistune-3.3.0 → mistune-3.3.2}/tests/test_cli.py +0 -0
  119. {mistune-3.3.0 → mistune-3.3.2}/tests/test_commonmark.py +0 -0
  120. {mistune-3.3.0 → mistune-3.3.2}/tests/test_directives.py +0 -0
  121. {mistune-3.3.0 → mistune-3.3.2}/tests/test_hooks.py +0 -0
  122. {mistune-3.3.0 → mistune-3.3.2}/tests/test_misc.py +0 -0
  123. {mistune-3.3.0 → mistune-3.3.2}/tests/test_plugins.py +0 -0
  124. {mistune-3.3.0 → mistune-3.3.2}/tests/test_renderers.py +0 -0
  125. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_formatting.py +0 -0
  126. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_image.py +0 -0
  127. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_inline.py +0 -0
  128. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_math.py +0 -0
  129. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_ref_links.py +0 -0
  130. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_toc.py +0 -0
  131. {mistune-3.3.0 → mistune-3.3.2}/tests/test_security_urls.py +0 -0
  132. {mistune-3.3.0 → mistune-3.3.2}/tests/test_syntax.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mistune
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: A sane and fast Markdown parser with useful plugins and renderers
5
5
  Author-email: Hsiaoming Yang <me@lepture.com>
6
6
  License: BSD-3-Clause
@@ -3,6 +3,22 @@ Changelog
3
3
 
4
4
  Here is the full history of mistune v3.
5
5
 
6
+ Version 3.3.2
7
+ -------------
8
+
9
+ **Released on Jun 23, 2026**
10
+
11
+ * Fix Python 3.8 import compatibility in the inline parser.
12
+ * Fix mypy compatibility for list parsing on Python 3.8 and 3.9+.
13
+
14
+ Version 3.3.1
15
+ -------------
16
+
17
+ **Released on Jun 22, 2026**
18
+
19
+ * Fix ``abbr`` plugin compatibility with escaped inline text.
20
+ * Normalize included Markdown line endings before parsing directives.
21
+
6
22
  Version 3.3.0
7
23
  -------------
8
24
 
@@ -44,7 +44,7 @@ build-backend = "setuptools.build_meta"
44
44
 
45
45
  [dependency-groups]
46
46
  dev = [
47
- "mypy<1.19",
47
+ "mypy",
48
48
  "pytest",
49
49
  "pytest-cov",
50
50
  "ruff",
@@ -97,5 +97,5 @@ __all__ = [
97
97
  "markdown",
98
98
  ]
99
99
 
100
- __version__ = "3.3.0"
100
+ __version__ = "3.3.2"
101
101
  __homepage__ = "https://mistune.lepture.com/"
@@ -72,6 +72,7 @@ class Include(DirectivePlugin):
72
72
 
73
73
  ext = os.path.splitext(dest)[1]
74
74
  if ext in {".md", ".markdown", ".mkd"}:
75
+ content = content.replace("\r\n", "\n").replace("\r", "\n")
75
76
  new_state = state.child_state(content)
76
77
  previous_file = new_state.env.get("__file__")
77
78
  new_state.env["__file__"] = dest
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import re
2
4
  from dataclasses import dataclass
3
5
  from typing import (
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import re
6
6
  from dataclasses import dataclass
7
- from typing import TYPE_CHECKING, Any, Iterable, Optional, Match, Pattern
7
+ from typing import TYPE_CHECKING, Any, Iterable, Optional, Match, Pattern, cast
8
8
  from .util import strip_end
9
9
 
10
10
  if TYPE_CHECKING:
@@ -96,12 +96,12 @@ def parse_list(block: "BlockParser", m: Match[str], state: "BlockState") -> int:
96
96
  while item_or_none:
97
97
  item_or_none = _parse_list_item(block, bullet, item_or_none, token, state, rules)
98
98
 
99
- end_pos = token.pop("_end_pos", None)
99
+ end_pos = cast(Optional[int], token.pop("_end_pos", None))
100
100
  _transform_tight_list(token)
101
101
  if end_pos:
102
- index = token.pop("_tok_index")
102
+ index = cast(int, token.pop("_tok_index"))
103
103
  state.tokens.insert(index, token)
104
- return end_pos # type: ignore[no-any-return]
104
+ return end_pos
105
105
 
106
106
  state.append_token(token)
107
107
  return state.cursor
@@ -1,6 +1,6 @@
1
1
  import re
2
2
  import types
3
- from typing import TYPE_CHECKING, Match
3
+ from typing import TYPE_CHECKING, List, Match, Tuple
4
4
 
5
5
  from ..helpers import PREVENT_BACKSLASH
6
6
  from ..util import escape
@@ -12,6 +12,7 @@ if TYPE_CHECKING:
12
12
  from ..markdown import Markdown
13
13
 
14
14
  __all__ = ["abbr"]
15
+ TextSegment = Tuple[str, bool]
15
16
 
16
17
  # https://michelf.ca/projects/php-markdown/extra/#abbr
17
18
  REF_ABBR = (
@@ -33,16 +34,50 @@ def parse_ref_abbr(block: "BlockParser", m: Match[str], state: "BlockState") ->
33
34
  return m.end() + 1
34
35
 
35
36
 
36
- def process_text(inline: "InlineParser", text: str, state: "InlineState") -> None:
37
+ def _append_text(
38
+ inline: "InlineParser",
39
+ text: str,
40
+ state: "InlineState",
41
+ parse_emphasis: bool,
42
+ ) -> None:
43
+ type(inline).process_text(inline, text, state, parse_emphasis=parse_emphasis)
44
+
45
+
46
+ def _append_text_segments(
47
+ inline: "InlineParser",
48
+ segments: List[TextSegment],
49
+ state: "InlineState",
50
+ start: int,
51
+ end: int,
52
+ ) -> None:
53
+ offset = 0
54
+ for value, parse_emphasis in segments:
55
+ next_offset = offset + len(value)
56
+ if start < next_offset and end > offset:
57
+ part_start = max(start - offset, 0)
58
+ part_end = min(end - offset, len(value))
59
+ _append_text(inline, value[part_start:part_end], state, parse_emphasis)
60
+ offset = next_offset
61
+
62
+
63
+ def process_text(
64
+ inline: "InlineParser",
65
+ text: str,
66
+ state: "InlineState",
67
+ parse_emphasis: bool = True,
68
+ ) -> None:
37
69
  ref = state.env.get("ref_abbrs")
38
70
  if not ref:
39
- return state.append_token({"type": "text", "raw": text})
71
+ return _append_text(inline, text, state, parse_emphasis)
40
72
 
73
+ segments: List[TextSegment] = []
41
74
  if state.tokens:
42
75
  last = state.tokens[-1]
43
76
  if last["type"] == "text":
44
77
  state.tokens.pop()
45
- text = last["raw"] + text
78
+ segments.append((last["raw"], last.get("_emphasis", True)))
79
+ segments.append((text, parse_emphasis))
80
+ text = "".join(value for value, _ in segments)
46
81
 
47
82
  abbrs_re = state.env.get("abbrs_re")
48
83
  if not abbrs_re:
@@ -57,8 +92,7 @@ def process_text(inline: "InlineParser", text: str, state: "InlineState") -> Non
57
92
 
58
93
  end_pos = m.start()
59
94
  if end_pos > pos:
60
- hole = text[pos:end_pos]
61
- state.append_token({"type": "text", "raw": hole})
95
+ _append_text_segments(inline, segments, state, pos, end_pos)
62
96
 
63
97
  label = m.group(0)
64
98
  state.append_token(
@@ -68,9 +102,9 @@ def process_text(inline: "InlineParser", text: str, state: "InlineState") -> Non
68
102
 
69
103
  if pos == 0:
70
104
  # special case, just pure text
71
- state.append_token({"type": "text", "raw": text})
105
+ _append_text_segments(inline, segments, state, 0, len(text))
72
106
  elif pos < len(text):
73
- state.append_token({"type": "text", "raw": text[pos:]})
107
+ _append_text_segments(inline, segments, state, pos, len(text))
74
108
 
75
109
 
76
110
  def render_abbr(renderer: "BaseRenderer", text: str, title: str) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mistune
3
- Version: 3.3.0
3
+ Version: 3.3.2
4
4
  Summary: A sane and fast Markdown parser with useful plugins and renderers
5
5
  Author-email: Hsiaoming Yang <me@lepture.com>
6
6
  License: BSD-3-Clause
@@ -8,6 +8,12 @@ HTML
8
8
  <p>HTML</p>
9
9
  ````````````````````````````````
10
10
 
11
+ ```````````````````````````````` example
12
+ \*a*
13
+ .
14
+ <p>*a*</p>
15
+ ````````````````````````````````
16
+
11
17
  ```````````````````````````````` example
12
18
  HTML
13
19
  *[HTML]: Hyper Text Markup Language
@@ -64,6 +70,20 @@ HTML is an abbreviation but nobody knows what it stands for.
64
70
  <p><abbr>HTML</abbr> is an abbreviation but nobody knows what it stands for.</p>
65
71
  ````````````````````````````````
66
72
 
73
+ ```````````````````````````````` example
74
+ \*HTML
75
+ *[HTML]: Hyper Text Markup Language
76
+ .
77
+ <p>*<abbr title="Hyper Text Markup Language">HTML</abbr></p>
78
+ ````````````````````````````````
79
+
80
+ ```````````````````````````````` example
81
+ \*a*
82
+ *[HTML]: Hyper Text Markup Language
83
+ .
84
+ <p>*a*</p>
85
+ ````````````````````````````````
86
+
67
87
  ```````````````````````````````` example
68
88
  Foo.* looks like a regular expression.
69
89
  *[Foo.*]: Just foo
@@ -58,10 +58,10 @@ class TestIncludeSecurity(TestCase):
58
58
  with tempfile.TemporaryDirectory() as tmpdir:
59
59
  a = os.path.join(tmpdir, "a.md")
60
60
  b = os.path.join(tmpdir, "b.md")
61
- with open(a, "w") as f:
62
- f.write(".. include:: b.md\n")
63
- with open(b, "w") as f:
64
- f.write(".. include:: a.md\n")
61
+ with open(a, "wb") as f:
62
+ f.write(b".. include:: b.md\r\n")
63
+ with open(b, "wb") as f:
64
+ f.write(b".. include:: a.md\r\n")
65
65
 
66
66
  md = create_markdown(plugins=[RSTDirective([Include()])])
67
67
  html = md.read(a)[0]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes