Skip to content

Command Line Interface

markdown-code-runner provides a command-line interface for processing Markdown files.

Basic Usage

markdown-code-runner /path/to/your/markdown_file.md

This will process the file in-place, executing all code blocks and updating the output sections.

Help Output

usage: markdown-code-runner [-h] [-o OUTPUT] [-d] [-v]
                            [--no-backtick-standardize]
                            input

Automatically update Markdown files with code block output.

positional arguments:
  input                 Path to the input Markdown file.

options:
  -h, --help            show this help message and exit
  -o, --output OUTPUT   Path to the output Markdown file. (default: overwrite
                        input file)
  -d, --verbose         Enable debugging mode (default: False)
  -v, --version         show program's version number and exit
  --no-backtick-standardize
                        Disable backtick standardization (default: enabled for
                        separate output files, disabled for in-place)

Options

Input File (Required)

The path to the Markdown file to process.

markdown-code-runner README.md

Output File (-o, --output)

Write the result to a different file instead of modifying in-place.

markdown-code-runner README.md -o README_updated.md

Verbose Mode (-d, --verbose)

Enable verbose output to see each line being processed.

markdown-code-runner README.md --verbose

Disable Backtick Standardization (--no-backtick-standardize)

By default, when writing to a separate output file, the markdown-code-runner tag is removed from backtick code blocks. Use this flag to disable that behavior.

markdown-code-runner README.md -o output.md --no-backtick-standardize

Version (-v, --version)

Display the installed version.

markdown-code-runner --version

Examples

Process a Single File

markdown-code-runner docs/index.md

Process Multiple Files

for f in docs/*.md; do
    markdown-code-runner "$f"
done

Process All Files in a Directory

find docs -name "*.md" -exec markdown-code-runner {} \;

Process with Verbose Output

markdown-code-runner README.md --verbose