mdformat-mkdocs 5.2.0b0__tar.gz → 5.2.0b2__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 (27) hide show
  1. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/PKG-INFO +19 -1
  2. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/README.md +17 -0
  3. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/__init__.py +1 -1
  4. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/plugin.py +29 -5
  5. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/pyproject.toml +10 -2
  6. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/LICENSE +0 -0
  7. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_helpers.py +0 -0
  8. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_normalize_list.py +0 -0
  9. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_postprocess_inline.py +0 -0
  10. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_synced/__init__.py +0 -0
  11. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_synced/admon_factories/README.md +0 -0
  12. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_synced/admon_factories/__init__.py +0 -0
  13. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/_synced/admon_factories/_whitespace_admon_factories.py +0 -0
  14. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/__init__.py +0 -0
  15. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_material_admon.py +0 -0
  16. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_material_content_tabs.py +0 -0
  17. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_material_deflist.py +0 -0
  18. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_mkdocstrings_autorefs.py +0 -0
  19. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_mkdocstrings_crossreference.py +0 -0
  20. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_mkdocstrings_injection.py +0 -0
  21. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_pymd_abbreviations.py +0 -0
  22. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_pymd_admon.py +0 -0
  23. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_pymd_arithmatex.py +0 -0
  24. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_pymd_captions.py +0 -0
  25. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_pymd_snippet.py +0 -0
  26. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/mdit_plugins/_python_markdown_attr_list.py +0 -0
  27. {mdformat_mkdocs-5.2.0b0 → mdformat_mkdocs-5.2.0b2}/mdformat_mkdocs/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdformat_mkdocs
3
- Version: 5.2.0b0
3
+ Version: 5.2.0b2
4
4
  Summary: An mdformat plugin for mkdocs and Material for MkDocs
5
5
  Keywords: markdown,markdown-it,mdformat,mdformat_plugin_template
6
6
  Author: kyleking
@@ -32,6 +32,7 @@ Requires-Dist: mdformat-hooks>=0.1.0 ; extra == 'recommended-mdsf'
32
32
  Requires-Dist: mdformat-simple-breaks>=0.0.1 ; extra == 'recommended-mdsf'
33
33
  Requires-Dist: mdformat-wikilink>=0.2.0 ; extra == 'recommended-mdsf'
34
34
  Requires-Dist: beartype>=0.21.0 ; extra == 'test'
35
+ Requires-Dist: hypothesis>=6.100.0 ; extra == 'test'
35
36
  Requires-Dist: pytest>=9.0.1 ; extra == 'test'
36
37
  Requires-Dist: pytest-beartype>=0.2.0 ; extra == 'test'
37
38
  Requires-Dist: pytest-cov>=7.0.0 ; extra == 'test'
@@ -79,6 +80,23 @@ Supports:
79
80
  - [Python Markdown "Snippets"\*](https://facelessuser.github.io/pymdown-extensions/extensions/snippets)
80
81
  - \*Note: the markup (HTML) renders the plain text without implementing the snippet logic. I'm open to contributions if anyone needs full support for snippets
81
82
 
83
+ ### Features with Implicit Support
84
+
85
+ The following MkDocs/Material/PyMdown syntax passes through mdformat-mkdocs unchanged — it is not modified or corrupted, but it is also not actively normalized:
86
+
87
+ - [PyMdown Keys](https://facelessuser.github.io/pymdown-extensions/extensions/keys/) — `++ctrl+alt+del++` (not a markdown construct, preserved as-is)
88
+ - [PyMdown Critic Markup](https://facelessuser.github.io/pymdown-extensions/extensions/critic/) — `{--deleted--}`, `{++added++}`, `{~~old~>new~~}`, `{==highlight==}`, `{>>comment<<}`
89
+ - [PyMdown Highlight](https://facelessuser.github.io/pymdown-extensions/extensions/mark/) — `==marked text==`
90
+ - [PyMdown Caret / Tilde](https://facelessuser.github.io/pymdown-extensions/extensions/caret/) — `H^2^O`, `CH~3~OH`
91
+ - [PyMdown Emoji](https://facelessuser.github.io/pymdown-extensions/extensions/emoji/) — `:smile:`, `:material-icon:`
92
+ - [PyMdown InlineHilite](https://facelessuser.github.io/pymdown-extensions/extensions/inlinehilite/) — language hints inside backtick spans (`:::python code`) are never modified
93
+ - [PyMdown SmartSymbols](https://facelessuser.github.io/pymdown-extensions/extensions/smartsymbols/) — `(c)`, `(tm)`, `--`, `-->` are plain ASCII in source and not touched
94
+ - [PyMdown MagicLink](https://facelessuser.github.io/pymdown-extensions/extensions/magiclink/) — `@username`, `#123` are plain text and pass through
95
+ - [Material Grids](https://squidfunk.github.io/mkdocs-material/reference/grids/) — `<div class="grid cards" markdown>` is an HTML block; content is preserved but markdown inside is not reformatted
96
+ - [Mermaid / Superfences](https://squidfunk.github.io/mkdocs-material/reference/diagrams/) — diagram code inside fenced blocks is never modified
97
+
98
+ **Note on [PyMdown ProgressBar](https://facelessuser.github.io/pymdown-extensions/extensions/progressbar/)**: The syntax `[=50% "50%"]` resembles an undefined link reference and will be escaped to `\[=50% "50%"\]` by default. Use `--ignore-missing-references` to preserve it, or avoid this extension if you use mdformat without that flag.
99
+
82
100
  See the example test files, [./tests/pre-commit-test.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/pre-commit-test.md) and [./tests/format/fixtures.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/format/fixtures.md)
83
101
 
84
102
  ## `mdformat` Usage
@@ -32,6 +32,23 @@ Supports:
32
32
  - [Python Markdown "Snippets"\*](https://facelessuser.github.io/pymdown-extensions/extensions/snippets)
33
33
  - \*Note: the markup (HTML) renders the plain text without implementing the snippet logic. I'm open to contributions if anyone needs full support for snippets
34
34
 
35
+ ### Features with Implicit Support
36
+
37
+ The following MkDocs/Material/PyMdown syntax passes through mdformat-mkdocs unchanged — it is not modified or corrupted, but it is also not actively normalized:
38
+
39
+ - [PyMdown Keys](https://facelessuser.github.io/pymdown-extensions/extensions/keys/) — `++ctrl+alt+del++` (not a markdown construct, preserved as-is)
40
+ - [PyMdown Critic Markup](https://facelessuser.github.io/pymdown-extensions/extensions/critic/) — `{--deleted--}`, `{++added++}`, `{~~old~>new~~}`, `{==highlight==}`, `{>>comment<<}`
41
+ - [PyMdown Highlight](https://facelessuser.github.io/pymdown-extensions/extensions/mark/) — `==marked text==`
42
+ - [PyMdown Caret / Tilde](https://facelessuser.github.io/pymdown-extensions/extensions/caret/) — `H^2^O`, `CH~3~OH`
43
+ - [PyMdown Emoji](https://facelessuser.github.io/pymdown-extensions/extensions/emoji/) — `:smile:`, `:material-icon:`
44
+ - [PyMdown InlineHilite](https://facelessuser.github.io/pymdown-extensions/extensions/inlinehilite/) — language hints inside backtick spans (`:::python code`) are never modified
45
+ - [PyMdown SmartSymbols](https://facelessuser.github.io/pymdown-extensions/extensions/smartsymbols/) — `(c)`, `(tm)`, `--`, `-->` are plain ASCII in source and not touched
46
+ - [PyMdown MagicLink](https://facelessuser.github.io/pymdown-extensions/extensions/magiclink/) — `@username`, `#123` are plain text and pass through
47
+ - [Material Grids](https://squidfunk.github.io/mkdocs-material/reference/grids/) — `<div class="grid cards" markdown>` is an HTML block; content is preserved but markdown inside is not reformatted
48
+ - [Mermaid / Superfences](https://squidfunk.github.io/mkdocs-material/reference/diagrams/) — diagram code inside fenced blocks is never modified
49
+
50
+ **Note on [PyMdown ProgressBar](https://facelessuser.github.io/pymdown-extensions/extensions/progressbar/)**: The syntax `[=50% "50%"]` resembles an undefined link reference and will be escaped to `\[=50% "50%"\]` by default. Use `--ignore-missing-references` to preserve it, or avoid this extension if you use mdformat without that flag.
51
+
35
52
  See the example test files, [./tests/pre-commit-test.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/pre-commit-test.md) and [./tests/format/fixtures.md](https://raw.githubusercontent.com/KyleKing/mdformat-mkdocs/main/tests/format/fixtures.md)
36
53
 
37
54
  ## `mdformat` Usage
@@ -1,7 +1,7 @@
1
1
  # ruff: noqa: RUF067
2
2
  """An mdformat plugin for `mkdocs`."""
3
3
 
4
- __version__ = "5.2.0b0"
4
+ __version__ = "5.2.0b2"
5
5
 
6
6
  __plugin_name__ = "mkdocs"
7
7
 
@@ -194,27 +194,51 @@ def _render_inline_content(node: RenderTreeNode, context: RenderContext) -> str:
194
194
 
195
195
 
196
196
  _ESCAPED_LINK_SPACED_URL = re.compile(r"\\\[([^\]]*)\\\]\(([^)]*[ ][^)]*)\)")
197
+ _PERCENT_ENCODED_URL_LINK = re.compile(r"\[([^\]]*)\]\(([^)]*%20[^)]*)\)")
198
+ _ANGLE_BRACKET_SPACED_URL_SOURCE = re.compile(r"\]\(<([^>]* [^>]*)>\)")
197
199
 
198
200
 
199
201
  def _fix_links_with_spaced_urls(
200
202
  text: str,
201
- node: RenderTreeNode, # noqa: ARG001
203
+ node: RenderTreeNode,
202
204
  context: RenderContext, # noqa: ARG001
203
205
  ) -> str:
204
- """Rewrite escaped links with space-containing URLs to angle-bracket syntax.
206
+ r"""Rewrite links with space-containing URLs to angle-bracket syntax.
205
207
 
206
208
  CommonMark requires link destinations with spaces to use angle brackets.
207
- When markdown-it fails to parse [text](url with space) as a link, mdformat
208
- escapes the brackets. Detects and repairs those cases.
209
+ Handles two cases:
210
+
211
+ 1. markdown-it fails to parse [text](url space) as a link and mdformat
212
+ escapes the brackets — detects ``\\[text\\](url space)`` and rewrites to
213
+ ``[text](<url space>)``.
214
+ 2. markdown-it parses [text](<url space>) correctly but percent-encodes
215
+ the space in the href — detects [text](url%20space) and restores to
216
+ [text](<url space>) using the original source in node.content.
209
217
 
210
218
  Addresses: https://github.com/KyleKing/mdformat-mkdocs/issues/80
211
219
 
212
220
  """
213
- return _ESCAPED_LINK_SPACED_URL.sub(
221
+ text = _ESCAPED_LINK_SPACED_URL.sub(
214
222
  lambda m: f"[{m.group(1)}](<{m.group(2)}>)",
215
223
  text,
216
224
  )
217
225
 
226
+ spaced_urls_from_source = {
227
+ m.group(1) for m in _ANGLE_BRACKET_SPACED_URL_SOURCE.finditer(node.content)
228
+ }
229
+ if spaced_urls_from_source:
230
+
231
+ def _restore_spaced_url(m: re.Match[str]) -> str:
232
+ link_text, encoded_url = m.group(1), m.group(2)
233
+ decoded_url = encoded_url.replace("%20", " ")
234
+ if decoded_url in spaced_urls_from_source:
235
+ return f"[{link_text}](<{decoded_url}>)"
236
+ return m.group(0)
237
+
238
+ text = _PERCENT_ENCODED_URL_LINK.sub(_restore_spaced_url, text)
239
+
240
+ return text
241
+
218
242
 
219
243
  def _render_text(node: RenderTreeNode, context: RenderContext) -> str:
220
244
  r"""Re-escape dollar signs that mdformat core stripped.
@@ -25,7 +25,7 @@ license-files = ["LICENSE"]
25
25
  name = "mdformat_mkdocs"
26
26
  readme = "README.md"
27
27
  requires-python = ">=3.10.0"
28
- version = "5.2.0b0"
28
+ version = "5.2.0b2"
29
29
 
30
30
  [project.entry-points."mdformat.parser_extension"]
31
31
  mkdocs = "mdformat_mkdocs"
@@ -56,6 +56,7 @@ recommended-mdsf = [
56
56
  ]
57
57
  test = [
58
58
  "beartype >= 0.21.0",
59
+ "hypothesis >= 6.100.0",
59
60
  "pytest >= 9.0.1",
60
61
  "pytest-beartype >= 0.2.0",
61
62
  "pytest-cov >= 7.0.0",
@@ -69,7 +70,7 @@ homepage = "https://github.com/kyleking/mdformat-mkdocs"
69
70
 
70
71
  [tool.commitizen]
71
72
  tag_format = "v${version}"
72
- version = "5.2.0b0"
73
+ version = "5.2.0b2"
73
74
  version_files = ["mdformat_mkdocs/__init__.py", "pyproject.toml:^version"]
74
75
 
75
76
  [tool.mypy]
@@ -183,6 +184,13 @@ isolated_build = true
183
184
  requires = ["tox>=4.32.0"]
184
185
  skip_missing_interpreters = false
185
186
 
187
+ [tool.tox.env.canary]
188
+ basepython = ["py314"]
189
+ changedir = "{tox_root}"
190
+ commands = [["python", "scripts/canary.py", {default = [], extend = true, replace = "posargs"}]]
191
+ description = "Run mdformat --check against real downstream repos. Optionally specify: '-- ruff uv' to test a subset."
192
+ skip_install = false
193
+
186
194
  [tool.tox.env.cz]
187
195
  basepython = ["py314"]
188
196
  commands = [["cz", "bump", {default = [], extend = true, replace = "posargs"}]]