markdown-exec 1.9.3__py3-none-any.whl → 1.10.1__py3-none-any.whl

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.
@@ -1,8 +1,8 @@
1
1
  """Special module without future annotations for executing Python code."""
2
2
 
3
- from typing import Any, Dict, Optional
3
+ from typing import Any, Optional
4
4
 
5
5
 
6
- def exec_python(code: str, filename: str, exec_globals: Optional[Dict[str, Any]] = None) -> None:
6
+ def exec_python(code: str, filename: str, exec_globals: Optional[dict[str, Any]] = None) -> None:
7
7
  compiled = compile(code, filename=filename, mode="exec")
8
8
  exec(compiled, exec_globals) # noqa: S102
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import os
6
6
  from contextlib import contextmanager
7
7
  from textwrap import indent
8
- from typing import TYPE_CHECKING, Any, Callable, Iterator
8
+ from typing import TYPE_CHECKING, Any, Callable
9
9
  from uuid import uuid4
10
10
 
11
11
  from markupsafe import Markup
@@ -14,6 +14,8 @@ from markdown_exec.logger import get_logger
14
14
  from markdown_exec.rendering import MarkdownConverter, add_source, code_block
15
15
 
16
16
  if TYPE_CHECKING:
17
+ from collections.abc import Iterator
18
+
17
19
  from markdown.core import Markdown
18
20
 
19
21
  logger = get_logger(__name__)
@@ -16,8 +16,8 @@ def _run_bash(
16
16
  id: str | None = None, # noqa: A002,ARG001
17
17
  **extra: str,
18
18
  ) -> str:
19
- process = subprocess.run(
20
- ["bash", "-c", code], # noqa: S603,S607
19
+ process = subprocess.run( # noqa: S603
20
+ ["bash", "-c", code], # noqa: S607
21
21
  stdout=subprocess.PIPE,
22
22
  stderr=subprocess.STDOUT,
23
23
  text=True,
@@ -16,7 +16,7 @@ clear_emoji = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
16
16
  assets = """
17
17
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.16.0/ace.js"></script>
18
18
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
19
- <script type="text/javascript" src="https://cdn.jsdelivr.net/pyodide/v0.23.0/full/pyodide.js"></script>
19
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/pyodide/v{version}/full/pyodide.js"></script>
20
20
  <link title="light" rel="alternate stylesheet" href="https://cdn.jsdelivr.net/npm/highlightjs-themes@1.0.0/tomorrow.min.css" disabled="disabled">
21
21
  <link title="dark" rel="alternate stylesheet" href="https://cdn.jsdelivr.net/npm/highlightjs-themes@1.0.0/tomorrow-night-blue.min.css" disabled="disabled">
22
22
  """
@@ -46,6 +46,7 @@ _counter = 0
46
46
  def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **options: Any) -> str: # noqa: ARG001
47
47
  global _counter # noqa: PLW0603
48
48
  _counter += 1
49
+ version = extra.pop("version", "0.26.4").lstrip("v")
49
50
  install = extra.pop("install", "")
50
51
  install = install.split(",") if install else []
51
52
  exclude_assets = extra.pop("assets", "1").lower() in {"0", "false", "no", "off"}
@@ -66,4 +67,4 @@ def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **option
66
67
  rendered = template % data
67
68
  if exclude_assets:
68
69
  return rendered
69
- return assets + rendered
70
+ return assets.format(version=version) + rendered
@@ -50,7 +50,7 @@ def _run_python(
50
50
  id: str | None = None, # noqa: A002
51
51
  **extra: str,
52
52
  ) -> str:
53
- title = extra.get("title", None)
53
+ title = extra.get("title")
54
54
  code_block_id = _code_block_id(id, session, title)
55
55
  _code_blocks[code_block_id] = code.split("\n")
56
56
  exec_globals = _sessions_globals[session] if session else {}
@@ -16,8 +16,8 @@ def _run_sh(
16
16
  id: str | None = None, # noqa: A002,ARG001
17
17
  **extra: str,
18
18
  ) -> str:
19
- process = subprocess.run(
20
- ["sh", "-c", code], # noqa: S603,S607
19
+ process = subprocess.run( # noqa: S603
20
+ ["sh", "-c", code], # noqa: S607
21
21
  stdout=subprocess.PIPE,
22
22
  stderr=subprocess.STDOUT,
23
23
  text=True,
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import logging
6
6
  import os
7
7
  from pathlib import Path
8
- from typing import TYPE_CHECKING, Any, MutableMapping
8
+ from typing import TYPE_CHECKING, Any
9
9
 
10
10
  from mkdocs.config import config_options
11
11
  from mkdocs.config.base import Config
@@ -18,6 +18,8 @@ from markdown_exec.logger import patch_loggers
18
18
  from markdown_exec.rendering import MarkdownConverter, markdown_config
19
19
 
20
20
  if TYPE_CHECKING:
21
+ from collections.abc import MutableMapping
22
+
21
23
  from jinja2 import Environment
22
24
  from mkdocs.config.defaults import MkDocsConfig
23
25
  from mkdocs.structure.files import Files
markdown_exec/pyodide.css CHANGED
@@ -47,4 +47,9 @@ html[data-theme="dark"] {
47
47
  .pyodide-clickable {
48
48
  cursor: pointer;
49
49
  text-align: right;
50
- }
50
+ }
51
+
52
+ /* For themes other than Material. */
53
+ .pyodide .twemoji svg {
54
+ width: 1rem;
55
+ }
@@ -3,9 +3,9 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from contextlib import contextmanager
6
- from functools import lru_cache
6
+ from functools import cache
7
7
  from textwrap import indent
8
- from typing import TYPE_CHECKING, Any, Iterator
8
+ from typing import TYPE_CHECKING, Any
9
9
 
10
10
  from markdown import Markdown
11
11
  from markupsafe import Markup
@@ -18,6 +18,7 @@ from markdown_exec.processors import (
18
18
  )
19
19
 
20
20
  if TYPE_CHECKING:
21
+ from collections.abc import Iterator
21
22
  from xml.etree.ElementTree import Element
22
23
 
23
24
  from markdown import Extension
@@ -180,7 +181,7 @@ emojis not working, etc.).
180
181
  # XML entities that get stashed in headings.
181
182
 
182
183
 
183
- @lru_cache(maxsize=None)
184
+ @cache
184
185
  def _register_headings_processors(md: Markdown) -> None:
185
186
  md.treeprocessors.register(
186
187
  InsertHeadings(md),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: markdown-exec
3
- Version: 1.9.3
3
+ Version: 1.10.1
4
4
  Summary: Utilities to execute code blocks in Markdown files.
5
5
  Keywords: markdown,python,exec,shell,bash,mkdocs
6
6
  Author-Email: =?utf-8?q?Timoth=C3=A9e_Mazzucotelli?= <dev@pawamoy.fr>
@@ -10,12 +10,12 @@ Classifier: Intended Audience :: Developers
10
10
  Classifier: Programming Language :: Python
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3 :: Only
13
- Classifier: Programming Language :: Python :: 3.8
14
13
  Classifier: Programming Language :: Python :: 3.9
15
14
  Classifier: Programming Language :: Python :: 3.10
16
15
  Classifier: Programming Language :: Python :: 3.11
17
16
  Classifier: Programming Language :: Python :: 3.12
18
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
19
  Classifier: Topic :: Documentation
20
20
  Classifier: Topic :: Software Development
21
21
  Classifier: Topic :: Utilities
@@ -28,10 +28,10 @@ Project-URL: Issues, https://github.com/pawamoy/markdown-exec/issues
28
28
  Project-URL: Discussions, https://github.com/pawamoy/markdown-exec/discussions
29
29
  Project-URL: Gitter, https://gitter.im/markdown-exec/community
30
30
  Project-URL: Funding, https://github.com/sponsors/pawamoy
31
- Requires-Python: >=3.8
31
+ Requires-Python: >=3.9
32
32
  Requires-Dist: pymdown-extensions>=9
33
- Requires-Dist: pygments-ansi-color; extra == "ansi"
34
33
  Provides-Extra: ansi
34
+ Requires-Dist: pygments-ansi-color>=0.3; extra == "ansi"
35
35
  Description-Content-Type: text/markdown
36
36
 
37
37
  # Markdown Exec
@@ -39,7 +39,6 @@ Description-Content-Type: text/markdown
39
39
  [![ci](https://github.com/pawamoy/markdown-exec/workflows/ci/badge.svg)](https://github.com/pawamoy/markdown-exec/actions?query=workflow%3Aci)
40
40
  [![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://pawamoy.github.io/markdown-exec/)
41
41
  [![pypi version](https://img.shields.io/pypi/v/markdown-exec.svg)](https://pypi.org/project/markdown-exec/)
42
- [![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/pawamoy/markdown-exec)
43
42
  [![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#markdown-exec:gitter.im)
44
43
 
45
44
  Utilities to execute code blocks in Markdown files.
@@ -49,10 +48,8 @@ and this HTML is injected in place of the code block.
49
48
 
50
49
  ## Installation
51
50
 
52
- With `pip`:
53
-
54
51
  ```bash
55
- pip install markdown-exec[ansi]
52
+ pip install "markdown-exec[ansi]"
56
53
  ```
57
54
 
58
55
  The `ansi` extra provides the necessary bits (`pygments-ansi-color` and a CSS file)
@@ -0,0 +1,26 @@
1
+ markdown_exec-1.10.1.dist-info/METADATA,sha256=yDCifhFAab-n1BJXKMhlgGKzO9rIVJf8adp2T-_n5XE,4934
2
+ markdown_exec-1.10.1.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ markdown_exec-1.10.1.dist-info/entry_points.txt,sha256=ZRi29BtVWZN8GHI2Cc-lN2vEvHrmg9Q-mnY_7ZIlf_c,115
4
+ markdown_exec-1.10.1.dist-info/licenses/LICENSE,sha256=eZQBcJKqlN0QepmOi0u09hlqKMPFdzWjY6NUWYeJGZs,754
5
+ markdown_exec/__init__.py,sha256=imnxEGJ4SCay2aeK-IMv5lnSwi7NurpPaoETXJZRsIk,4675
6
+ markdown_exec/ansi.css,sha256=6PTJxTSsExVgPbMySCuKjih0gr-fdfx2aZ9--u7zWf0,8090
7
+ markdown_exec/debug.py,sha256=dy0bTd9mTTyTaWuUGNkH0UUdMp2ZThsmGh5q9wt9O0c,2840
8
+ markdown_exec/formatters/__init__.py,sha256=w8ui1JaGUA5SCyWd2pPAAopQ5y6QYtDvOUHUa7KW2Wg,51
9
+ markdown_exec/formatters/_exec_python.py,sha256=Gnstq7GFFXKuG8VZEHiT53wacKHR2UcpIrCgrTIwIIM,317
10
+ markdown_exec/formatters/base.py,sha256=yTjHiBBGp_KGocV5ORcPBAbjSSBFRNlkzi3ru8EgPyw,6142
11
+ markdown_exec/formatters/bash.py,sha256=zICzmzzd-jTw0fiFv9K4SP-VI5iBM9KrVzX0E6fua5U,895
12
+ markdown_exec/formatters/console.py,sha256=D2JBIC4MU0ct2MiRCkBO-qo4MiH6Hjy6LXjYAsRmuRA,815
13
+ markdown_exec/formatters/markdown.py,sha256=pd0akvFGUXrc41NABcHUTTkKFA3k5Ju8im-b3kzOvIw,276
14
+ markdown_exec/formatters/pycon.py,sha256=F9xpSRKFWsVpGu5XXybtCkMMJ_PAfyd48Qqo1SWl6RA,854
15
+ markdown_exec/formatters/pyodide.py,sha256=twAY0PWge5svRNjMOi1f0wEuWU9R-K8qIKmsaTBSA_Y,3253
16
+ markdown_exec/formatters/python.py,sha256=11q2UH9kMRl1TUUkEJqsstOvDIzaIIY128CS6Drp4MI,3198
17
+ markdown_exec/formatters/sh.py,sha256=9bMFM5OP7znDg93qkQxETCTIaHWlRRfsVg4C8fz7UEE,885
18
+ markdown_exec/formatters/tree.py,sha256=4XU1KaNqChkkNxMYanwy6glTE2uwcY8Mz9jBZiIf3zY,2046
19
+ markdown_exec/logger.py,sha256=V8b_D19B0NkZuLr6cBQJnQgHAlz6NyqeENqHKWvTk5M,2422
20
+ markdown_exec/mkdocs_plugin.py,sha256=3Gz-9I-6uclzOzUjRs0SN0FmEbQ4L_Pbf-9lT1AMQss,5323
21
+ markdown_exec/processors.py,sha256=sE7ZWz_NisdcOdzQStqzPgvz7qnPkzNy4mqHLy6bugM,4411
22
+ markdown_exec/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ markdown_exec/pyodide.css,sha256=lan5A3qEGA4ABTrXPOWJX8kezQp7naH305NKVTSObhM,954
24
+ markdown_exec/pyodide.js,sha256=6iL-9xA4b9UeZgsxVYq_BiCE-Bwu58NfYwYCzz9C9j0,3845
25
+ markdown_exec/rendering.py,sha256=1Az4xcmEN6TSIoD4liYzpfNhZlnOCwUcH05gFWQd11Y,9468
26
+ markdown_exec-1.10.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.3.1)
2
+ Generator: pdm-backend (2.4.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,3 +1,7 @@
1
+ [console_scripts]
2
+
3
+ [gui_scripts]
4
+
1
5
  [mkdocs.plugins]
2
6
  markdown-exec = markdown_exec.mkdocs_plugin:MarkdownExecPlugin
3
7
 
@@ -1,26 +0,0 @@
1
- markdown_exec-1.9.3.dist-info/METADATA,sha256=6Y9VqysHxQ9UTr9DZNiI4vwx_4RXM0SmKD7nb9oZ0Wk,5080
2
- markdown_exec-1.9.3.dist-info/WHEEL,sha256=SOP-4bEE0jbVaCHQGVvF08uWxk5rcSsfEybvoQVHlD8,90
3
- markdown_exec-1.9.3.dist-info/entry_points.txt,sha256=W-JWRoZzS5TXRcyVnxYmsaVBV4HSl7B_7uTgtaZ-Pms,81
4
- markdown_exec-1.9.3.dist-info/licenses/LICENSE,sha256=eZQBcJKqlN0QepmOi0u09hlqKMPFdzWjY6NUWYeJGZs,754
5
- markdown_exec/__init__.py,sha256=imnxEGJ4SCay2aeK-IMv5lnSwi7NurpPaoETXJZRsIk,4675
6
- markdown_exec/ansi.css,sha256=6PTJxTSsExVgPbMySCuKjih0gr-fdfx2aZ9--u7zWf0,8090
7
- markdown_exec/debug.py,sha256=dy0bTd9mTTyTaWuUGNkH0UUdMp2ZThsmGh5q9wt9O0c,2840
8
- markdown_exec/formatters/__init__.py,sha256=w8ui1JaGUA5SCyWd2pPAAopQ5y6QYtDvOUHUa7KW2Wg,51
9
- markdown_exec/formatters/_exec_python.py,sha256=eVomRZQQl2DySCZIrtqipmBme3kgwIjjRIu8dl22JdE,323
10
- markdown_exec/formatters/base.py,sha256=knl_BBZrOxnsCTPDKHvKBgomv_w0mwuX4ybDf-6YXEM,6110
11
- markdown_exec/formatters/bash.py,sha256=qVn6nPqitUuFX72ll00w_x343zl_bMuXrr-Xyox4dJY,886
12
- markdown_exec/formatters/console.py,sha256=D2JBIC4MU0ct2MiRCkBO-qo4MiH6Hjy6LXjYAsRmuRA,815
13
- markdown_exec/formatters/markdown.py,sha256=pd0akvFGUXrc41NABcHUTTkKFA3k5Ju8im-b3kzOvIw,276
14
- markdown_exec/formatters/pycon.py,sha256=F9xpSRKFWsVpGu5XXybtCkMMJ_PAfyd48Qqo1SWl6RA,854
15
- markdown_exec/formatters/pyodide.py,sha256=fxjYM4Ev2FAiANtGhb7ih9D70Qz3kNH4yJvwz8v7Adw,3169
16
- markdown_exec/formatters/python.py,sha256=vOOFk1pd9-FWKeUG4JYICUvCKsggwj7MX0jnK4EYLLw,3204
17
- markdown_exec/formatters/sh.py,sha256=41kmwFjkyisWYmfJeBMC40kqhEe7sI2E0vvbO9ixjCg,876
18
- markdown_exec/formatters/tree.py,sha256=4XU1KaNqChkkNxMYanwy6glTE2uwcY8Mz9jBZiIf3zY,2046
19
- markdown_exec/logger.py,sha256=V8b_D19B0NkZuLr6cBQJnQgHAlz6NyqeENqHKWvTk5M,2422
20
- markdown_exec/mkdocs_plugin.py,sha256=2PdhdDceGjgpHrfRuDcvSJHXZGdPKEKtedAbWTmrCu8,5291
21
- markdown_exec/processors.py,sha256=sE7ZWz_NisdcOdzQStqzPgvz7qnPkzNy4mqHLy6bugM,4411
22
- markdown_exec/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- markdown_exec/pyodide.css,sha256=7jToXYySNVdX4x9jANwRfjRjYvM6robHibGPWCFzeBQ,871
24
- markdown_exec/pyodide.js,sha256=6iL-9xA4b9UeZgsxVYq_BiCE-Bwu58NfYwYCzz9C9j0,3845
25
- markdown_exec/rendering.py,sha256=ssWg6U-7Ez45N6sLak-oGD2e55qtEkPY8T8l7h1RbDM,9459
26
- markdown_exec-1.9.3.dist-info/RECORD,,