markdown-code-runner
A Rust implementation of markdown-code-runner - automatically update Markdown files with code block output.
Installation
Or build from source:
Usage
<INPUT> Path
)
Markdown Syntax
Backtick Code Blocks
Add markdown-code-runner after the language identifier to mark a code block for execution:
```python markdown-code-runner
print('Hello, world!')
```
This will be replaced by the output.
Hidden Code Blocks (HTML Comments)
Use HTML comments to hide the code while still executing it:
This will be replaced by the output.
For Bash:
This will be replaced by the output.
Skip Marker
Use <!-- CODE:SKIP --> to prevent execution of the next code block:
```python markdown-code-runner
print('This will not be executed')
```
This output will be preserved.
Write to File
Use the filename= option to write code to a file instead of executing:
```rust markdown-code-runner filename=example.rs
fn main() {
}
```
Variable Persistence
Variables defined in Python code blocks are shared across all subsequent Python blocks in the same file:
```python markdown-code-runner
x = 42
print(x)
```
42
```python markdown-code-runner
print(x * 2)
```
84
Indented Code Blocks
Code blocks in list items or other indented contexts are supported:
1.
License
MIT License - see LICENSE for details.
Related
- markdown-code-runner - The original Python implementation