diff --git a/docs/usage/pyodide.md b/docs/usage/pyodide.md index 5d3e25e..143189a 100644 --- a/docs/usage/pyodide.md +++ b/docs/usage/pyodide.md @@ -168,3 +168,23 @@ for theme in themes: ) ) ``` + +## Editor Height Configuration + +You can customize the height of the Pyodide editor using several options: + +### Lines (Recommended) + +The simplest way to control the editor height is with the `lines` parameter, which sets the number of visible lines in the editor. The editor will automatically adjust its height to fit the specified number of lines: + +```pyodide lines=3 assets="no" +# This editor shows 10 lines by default +def fibonacci(n): + """Generate Fibonacci sequence up to n""" + a, b = 0, 1 + while a < n: + yield a + a, b = b, a + b + +print(list(fibonacci(100))) +``` diff --git a/mkdocs.yml b/mkdocs.yml index f1395f4..1561e18 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -159,6 +159,10 @@ plugins: inputs: - index.md - reference/**.md + sections: + - overview + - usage + - api - git-revision-date-localized: enabled: !ENV [DEPLOY, false] enable_creation_date: true diff --git a/src/markdown_exec/_internal/formatters/pyodide.py b/src/markdown_exec/_internal/formatters/pyodide.py index 0dc33b8..d23d068 100644 --- a/src/markdown_exec/_internal/formatters/pyodide.py +++ b/src/markdown_exec/_internal/formatters/pyodide.py @@ -37,7 +37,15 @@ """ @@ -56,7 +64,11 @@ def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **option if "," not in theme: theme = f"{theme},{theme}" theme_light, theme_dark = theme.split(",") - + + # Get line-based configuration + min_lines = int(extra.pop("min_lines", "3")) + max_lines = int(extra.pop("max_lines", "20")) + data = { "id_prefix": f"exec-{_counter}--", "initial_code": code, @@ -66,8 +78,10 @@ def _format_pyodide(code: str, md: Markdown, session: str, extra: dict, **option "session": session or "default", "play_emoji": _play_emoji, "clear_emoji": _clear_emoji, + "min_lines": min_lines, + "max_lines": max_lines, } rendered = _template % data if exclude_assets: return rendered - return _assets.format(version=version) + rendered + return _assets.format(version=version) + rendered \ No newline at end of file