markdown-exec 1.10.4__tar.gz → 1.11.0__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 (120) hide show
  1. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/CHANGELOG.md +8 -0
  2. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/PKG-INFO +1 -1
  3. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/usage/pyodide.md +50 -0
  4. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/pyproject.toml +1 -1
  5. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/pyodide.py +29 -1
  6. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/assets/pyodide.css +0 -2
  7. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/assets/pyodide.js +15 -1
  8. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/CODE_OF_CONDUCT.md +0 -0
  9. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/CONTRIBUTING.md +0 -0
  10. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/LICENSE +0 -0
  11. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/README.md +0 -0
  12. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/coverage.ini +0 -0
  13. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/git-changelog.toml +0 -0
  14. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/mypy.ini +0 -0
  15. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/pytest.ini +0 -0
  16. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/ruff.toml +0 -0
  17. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/vscode/launch.json +0 -0
  18. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/vscode/settings.json +0 -0
  19. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/config/vscode/tasks.json +0 -0
  20. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/.overrides/main.html +0 -0
  21. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/.overrides/partials/comments.html +0 -0
  22. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/.overrides/partials/path-item.html +0 -0
  23. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/changelog.md +0 -0
  24. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/code_of_conduct.md +0 -0
  25. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/contributing.md +0 -0
  26. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/credits.md +0 -0
  27. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/css/insiders.css +0 -0
  28. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/css/material.css +0 -0
  29. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/css/mkdocstrings.css +0 -0
  30. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/gallery.md +0 -0
  31. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/index.md +0 -0
  32. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/insiders/changelog.md +0 -0
  33. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/insiders/goals.yml +0 -0
  34. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/insiders/index.md +0 -0
  35. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/insiders/installation.md +0 -0
  36. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/js/feedback.js +0 -0
  37. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/js/insiders.js +0 -0
  38. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/license.md +0 -0
  39. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/reference/api.md +0 -0
  40. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/schema.json +0 -0
  41. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/ansi.sh +0 -0
  42. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/argparse.py +0 -0
  43. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/argparse_format.py +0 -0
  44. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/chalk.py +0 -0
  45. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/d2.py +0 -0
  46. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/diagrams.py +0 -0
  47. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/drawsvg.py +0 -0
  48. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/expandable_filetree.py +0 -0
  49. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/hyperbolic.py +0 -0
  50. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/matplotlib.py +0 -0
  51. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/plotly.py +0 -0
  52. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/pydeps.py +0 -0
  53. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/qrcode.py +0 -0
  54. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/rich.py +0 -0
  55. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/rich_terminal.py +0 -0
  56. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/runpy.py +0 -0
  57. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/gallery/textual.py +0 -0
  58. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/boolean_matrix.py +0 -0
  59. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/hide.py +0 -0
  60. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/multiple.pycon +0 -0
  61. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/platform_html.py +0 -0
  62. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/platform_md.py +0 -0
  63. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/source.py +0 -0
  64. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/snippets/usage/source.pycon +0 -0
  65. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/usage/index.md +0 -0
  66. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/usage/python.md +0 -0
  67. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/usage/shell.md +0 -0
  68. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/docs/usage/tree.md +0 -0
  69. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/duties.py +0 -0
  70. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/mkdocs.yml +0 -0
  71. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/scripts/gen_credits.py +0 -0
  72. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/scripts/get_version.py +0 -0
  73. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/scripts/insiders.py +0 -0
  74. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/scripts/make +0 -0
  75. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/scripts/make.py +0 -0
  76. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/__init__.py +0 -0
  77. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/__init__.py +0 -0
  78. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/debug.py +0 -0
  79. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/__init__.py +0 -0
  80. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/_exec_python.py +0 -0
  81. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/base.py +0 -0
  82. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/bash.py +0 -0
  83. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/console.py +0 -0
  84. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/markdown.py +0 -0
  85. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/pycon.py +0 -0
  86. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/python.py +0 -0
  87. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/sh.py +0 -0
  88. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/formatters/tree.py +0 -0
  89. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/logger.py +0 -0
  90. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/main.py +0 -0
  91. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/mkdocs_plugin.py +0 -0
  92. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/processors.py +0 -0
  93. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/_internal/rendering.py +0 -0
  94. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/assets/ansi.css +0 -0
  95. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/__init__.py +0 -0
  96. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/base.py +0 -0
  97. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/bash.py +0 -0
  98. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/console.py +0 -0
  99. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/markdown.py +0 -0
  100. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/pycon.py +0 -0
  101. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/pyodide.py +0 -0
  102. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/python.py +0 -0
  103. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/sh.py +0 -0
  104. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/formatters/tree.py +0 -0
  105. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/logger.py +0 -0
  106. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/mkdocs_plugin.py +0 -0
  107. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/processors.py +0 -0
  108. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/py.typed +0 -0
  109. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/src/markdown_exec/rendering.py +0 -0
  110. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/__init__.py +0 -0
  111. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/conftest.py +0 -0
  112. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_api.py +0 -0
  113. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_base_formatter.py +0 -0
  114. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_converter.py +0 -0
  115. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_headings.py +0 -0
  116. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_python.py +0 -0
  117. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_shell.py +0 -0
  118. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_toc.py +0 -0
  119. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_tree.py +0 -0
  120. {markdown_exec-1.10.4 → markdown_exec-1.11.0}/tests/test_validator.py +0 -0
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  <!-- insertion marker -->
8
+ ## [1.11.0](https://github.com/pawamoy/markdown-exec/releases/tag/1.11.0) - 2025-06-28
9
+
10
+ <small>[Compare with 1.10.4](https://github.com/pawamoy/markdown-exec/compare/1.10.4...1.11.0)</small>
11
+
12
+ ### Features
13
+
14
+ - Add option to set height of Pyodide/Ace editors ([c64a2ef](https://github.com/pawamoy/markdown-exec/commit/c64a2efd8cb7a7a691039e866dab5839f8ef8bfe) by Jayant Pranjal). [Issue-41](https://github.com/pawamoy/markdown-exec/issues/41), Co-authored-by: Jayant <jayant@Jayants-MacBook-Air.local>, Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
15
+
8
16
  ## [1.10.4](https://github.com/pawamoy/markdown-exec/releases/tag/1.10.4) - 2025-06-27
9
17
 
10
18
  <small>[Compare with 1.10.3](https://github.com/pawamoy/markdown-exec/compare/1.10.3...1.10.4)</small>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-exec
3
- Version: 1.10.4
3
+ Version: 1.11.0
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>
@@ -45,6 +45,56 @@ print("Hello.")
45
45
 
46
46
  NOTE: **All Pyodide blocks on the same page should use the same version!**
47
47
 
48
+ ## Editor height
49
+
50
+ The height of the editor can be configured with the `height` option. It accepts the following values:
51
+
52
+ - `0` or `auto`: A fixed number of lines, based on initial code.
53
+ - a positive number, like `10`: A fixed number of lines.
54
+ - a positive range, like `5-30`: The minimum and maximum number of lines. The editor will shring/grow as you type.
55
+
56
+ The default is `auto`.
57
+
58
+ A few examples:
59
+
60
+ ````md exec="1" source="tabbed-left" tabs="Markdown|Rendered" title="Fixed height (10 lines)"
61
+ ```pyodide height="10"
62
+ from typing import Iterator
63
+
64
+ # This is an example
65
+ class Math:
66
+ @staticmethod
67
+ def fib(n: int) -> Iterator[int]:
68
+ """Fibonacci series up to n."""
69
+ a, b = 0, 1
70
+ while a < n:
71
+ yield a
72
+ a, b = b, a + b
73
+
74
+ result = sum(Math.fib(42))
75
+ print(f"The answer is {result}")
76
+ ```
77
+ ````
78
+
79
+ ````md exec="1" source="tabbed-left" tabs="Markdown|Rendered" title="Between 1 and 40 lines"
80
+ ```pyodide height="1-40"
81
+ from typing import Iterator
82
+
83
+ # This is an example
84
+ class Math:
85
+ @staticmethod
86
+ def fib(n: int) -> Iterator[int]:
87
+ """Fibonacci series up to n."""
88
+ a, b = 0, 1
89
+ while a < n:
90
+ yield a
91
+ a, b = b, a + b
92
+
93
+ result = sum(Math.fib(42))
94
+ print(f"The answer is {result}")
95
+ ```
96
+ ````
97
+
48
98
  ## Sessions
49
99
 
50
100
  Editors with the same session share the same `globals()` dictionary,
@@ -45,7 +45,7 @@ classifiers = [
45
45
  dependencies = [
46
46
  "pymdown-extensions>=9",
47
47
  ]
48
- version = "1.10.4"
48
+ version = "1.11.0"
49
49
 
50
50
  [project.optional-dependencies]
51
51
  ansi = [
@@ -37,7 +37,15 @@ _template = """
37
37
 
38
38
  <script>
39
39
  document.addEventListener('DOMContentLoaded', (event) => {
40
- setupPyodide('%(id_prefix)s', install=%(install)s, themeLight='%(theme_light)s', themeDark='%(theme_dark)s', session='%(session)s');
40
+ setupPyodide(
41
+ '%(id_prefix)s',
42
+ install=%(install)s,
43
+ themeLight='%(theme_light)s',
44
+ themeDark='%(theme_dark)s',
45
+ session='%(session)s',
46
+ minLines=%(min_lines)s,
47
+ maxLines=%(max_lines)s,
48
+ );
41
49
  });
42
50
  </script>
43
51
  """
@@ -45,9 +53,26 @@ document.addEventListener('DOMContentLoaded', (event) => {
45
53
  _counter = 0
46
54
 
47
55
 
56
+ def _calculate_height(code: str, extra: dict) -> tuple[int, int]:
57
+ """Calculate height configuration for the Pyodide editor."""
58
+ height = extra.pop("height", "auto")
59
+
60
+ if height in ("auto", "0"):
61
+ min_lines = max_lines = len(code.strip().splitlines()) if code.strip() else 5
62
+ elif "-" in height:
63
+ min_lines, max_lines = height.split("-")
64
+ min_lines = max(1, int(min_lines or "5"))
65
+ max_lines = max(min_lines, int(max_lines or "30"))
66
+ else:
67
+ min_lines = max_lines = int(height)
68
+
69
+ return min_lines, max_lines
70
+
71
+
48
72
  def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **options: Any) -> str: # noqa: ARG001
49
73
  global _counter # noqa: PLW0603
50
74
  _counter += 1
75
+
51
76
  version = extra.pop("version", "0.26.4").lstrip("v")
52
77
  install = extra.pop("install", "")
53
78
  install = install.split(",") if install else []
@@ -56,6 +81,7 @@ def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **option
56
81
  if "," not in theme:
57
82
  theme = f"{theme},{theme}"
58
83
  theme_light, theme_dark = theme.split(",")
84
+ min_lines, max_lines = _calculate_height(code, extra)
59
85
 
60
86
  data = {
61
87
  "id_prefix": f"exec-{_counter}--",
@@ -66,6 +92,8 @@ def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **option
66
92
  "session": session or "default",
67
93
  "play_emoji": _play_emoji,
68
94
  "clear_emoji": _clear_emoji,
95
+ "min_lines": min_lines,
96
+ "max_lines": max_lines,
69
97
  }
70
98
  rendered = _template % data
71
99
  if exclude_assets:
@@ -13,8 +13,6 @@ html[data-theme="dark"] {
13
13
 
14
14
  .pyodide-editor {
15
15
  width: 100%;
16
- min-height: 200px;
17
- max-height: 400px;
18
16
  font-size: .85em;
19
17
  }
20
18
 
@@ -77,7 +77,15 @@ function updateTheme(editor, light, dark) {
77
77
  });
78
78
  }
79
79
 
80
- async function setupPyodide(idPrefix, install = null, themeLight = 'tomorrow', themeDark = 'tomorrow_night', session = null) {
80
+ async function setupPyodide(
81
+ idPrefix,
82
+ install = null,
83
+ themeLight = 'tomorrow',
84
+ themeDark = 'tomorrow_night',
85
+ session = null,
86
+ minLines = 5,
87
+ maxLines = 30,
88
+ ) {
81
89
  const editor = ace.edit(idPrefix + "editor");
82
90
  const run = document.getElementById(idPrefix + "run");
83
91
  const clear = document.getElementById(idPrefix + "clear");
@@ -88,6 +96,12 @@ async function setupPyodide(idPrefix, install = null, themeLight = 'tomorrow', t
88
96
  editor.session.setMode("ace/mode/python");
89
97
  setTheme(editor, getTheme(), themeLight, themeDark);
90
98
 
99
+ editor.setOption("minLines", minLines);
100
+ editor.setOption("maxLines", maxLines);
101
+
102
+ // Force editor to resize after setting options
103
+ editor.resize();
104
+
91
105
  writeOutput(output, "Initializing...");
92
106
  let pyodide = await pyodidePromise;
93
107
  if (install && install.length) {
File without changes
File without changes
File without changes