Releases: basnijholt/markdown-code-runner
v2.6.0
What's New
Features
- Support for indented code blocks (#47): Code blocks inside list items or other indented contexts now work correctly. The indentation is stripped from code before execution and re-added to output. Fixes #11.
Bug Fixes
- Fix examples.md template (#45): Escape comment markers and remove orphaned content from the template.
Documentation
- Developer notes (#46): Added documentation explaining the recursion problem and solution patterns (CODE:SKIP, PLACEHOLDER, nested HTML comment escaping).
Maintenance
- Switch to ruff format (#48): Replace black with ruff-format in pre-commit, standardize line length to 120 characters, and migrate to modern
ruff.lint.*config sections.
v2.5.0
New Features
Standardize Code Fences for External Markdown Processors
Added new CLI flags and Python API parameters to standardize code fences, making output compatible with markdown processors like mkdocs, Zensical, and pandoc that don't understand the python markdown-code-runner syntax.
CLI
# Execute code AND standardize all code fences
markdown-code-runner --standardize input.md
markdown-code-runner -s input.md
# Only standardize without executing code
markdown-code-runner --no-execute --standardize input.md
markdown-code-runner -n -s input.mdPython API
from markdown_code_runner import update_markdown_file, standardize_code_fences
# Execute and standardize in one pass
update_markdown_file("README.md", "output.md", standardize=True)
# Only standardize, skip execution
update_markdown_file("README.md", "output.md", execute=False, standardize=True)
# Use the utility function directly
clean_content = standardize_code_fences(content)What It Does
The --standardize flag post-processes output to transform code fences like:
```python markdown-code-runner
print('hello')
```Into standard code fences:
```python
print('hello')
```Closes
- Closes #26
v2.4.2
What's Changed
Documentation
- Add shields to README (#41)
- Add Python version classifiers to pyproject.toml
This release adds proper PyPI classifiers so the Python version badge displays correctly.
Full Changelog: v2.4.1...v2.4.2
v2.4.1
What's Changed
Documentation
- Add Zensical documentation site (#35)
- Add documentation link to README and pyproject.toml (#39)
- Clean up README: remove emojis and add SVG logo (#40)
Infrastructure
- Pin Python to 3.14.2 (#36, #34)
- Remove docs-site branch references from docs workflow (#38)
- Update actions/checkout to v6 (#33)
- Update actions/setup-python to v6 (#31)
- Update astral-sh/setup-uv to v7 (#32)
Full Changelog: v2.4.0...v2.4.1
v2.4.0
What's Changed
- feat: automatically trim trailing whitespace from output blocks by @basnijholt in #29
- ⬆️ Update actions/checkout action to v5 by @renovate[bot] in #28
- ⬆️ Update astral-sh/setup-uv action to v6 by @renovate[bot] in #25
- ⬆️ Update python to v3.13.5 by @renovate[bot] in #24
Full Changelog: v2.3.0...v2.4.0
v2.3.0
What's Changed
- feat: add backtick standardization to clean up markdown-code-runner t… by @sanyamsmulay in #27
New Contributors
- @sanyamsmulay made their first contribution in #27
Full Changelog: v2.2.0...v2.3.0
v2.2.0
What's Changed
- Add Mend Renovate bot by @basnijholt in #16
- ⬆️ Update actions/setup-python action to v5 by @renovate in #18
- ⬆️ Update actions/checkout action to v4 by @renovate in #17
- Use uv in CI by @basnijholt in #21
- ⬆️ Pin python to 3.13.2 by @renovate in #20
- Drop Python 3.7 and 3.8 support by @basnijholt in #22
- Update pre-commit hooks by @basnijholt in #23
New Contributors
Full Changelog: v2.1.0...v2.2.0
version 2.1.0
What's Changed
- Allow any language to be saved to a file by @basnijholt in #12
- Remove use of pkg_resources for Python 3.12 compatibility by @basnijholt in #14
Full Changelog: v2.0.0...v2.1.0
v2.0.0
Version 2.0.0
New Features:
- Changed code block markers from
<!-- START_CODE -->and<!-- END_CODE -->to<!-- CODE:START -->and<!-- CODE:END -->. - Changed output markers from
<!-- START_OUTPUT -->and<!-- END_OUTPUT -->to<!-- OUTPUT:START -->and<!-- OUTPUT:END -->. - Added
<!-- CODE:SKIP -->comment option to skip the execution of a code block. - Introduced support for executing code blocks in triple backticks.
- Added support for bash code blocks.
- Added support for file code blocks, allowing to execute any language (in combination with bash).
Improvements:
- Refactored code to improve maintainability and readability.
- Better regular expression handling for markers.
- Enhanced error messages and input validation.
v1.0.0
Release Notes
markdown-code-runner v1.0.0
We are excited to announce the first release of markdown-code-runner! This Python module automatically executes code blocks within a Markdown file and updates the output in-place. This release includes the following features and improvements:
Features
- Parse Markdown files and detect code blocks marked with
<!-- START_CODE -->and<!-- END_CODE -->. - Execute Python code within the detected code blocks.
- Insert the output of the executed code blocks into the Markdown file, replacing the content between
<!-- START_OUTPUT -->and<!-- END_OUTPUT -->markers. - Optionally, use a
<!-- SKIP -->marker to skip the execution of a specific code block and keep the original output. - Retain the formatting of the original Markdown file, including comments and other non-code elements.
- The main function,
process_markdown, takes a list of Markdown-formatted strings as input and returns a modified list of Markdown-formatted strings with code block output inserted.
Bug Fixes
- Fixed issues with handling the output of code blocks that were skipped using the
<!-- SKIP -->marker. - Improved error handling and added informative error messages for various edge cases.
Testing
- Comprehensive test suite covering various use cases and edge cases.
- Test case for the new
<!-- SKIP -->marker functionality.
We hope you find markdown-code-runner useful for your projects involving code execution within Markdown files. We look forward to your feedback and suggestions for future improvements!