Command Line Interface
markdown-code-runner provides a command-line interface for processing Markdown files.
Basic Usage
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] [-s] [-n]
input [input ...]
Automatically update Markdown files with code block output.
positional arguments:
input Path(s) to the input Markdown file(s).
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)
-s, --standardize Post-process to standardize ALL code fences, removing
'markdown-code-runner' modifiers
-n, --no-execute Skip code execution entirely (useful with
--standardize for compatibility processing only)
Options
Input File (Required)
The path to the Markdown file to process.
Output File (-o, --output)
Write the result to a different file instead of modifying in-place.
Verbose Mode (-d, --verbose)
Enable verbose output to see each line being processed.
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.
Standardize All Code Fences (-s, --standardize)
Post-process the output to standardize ALL code fences, removing markdown-code-runner modifiers from language identifiers. This is useful for compatibility with markdown processors like mkdocs and pandoc that don't understand the python markdown-code-runner syntax.
This transforms code fences like:
Into standard code fences:
Skip Code Execution (-n, --no-execute)
Skip code execution entirely. This is useful when you only want to standardize code fences without running any code.
This combination is particularly useful for:
- Preparing files for external markdown processors
- Converting files without re-running code blocks
- Creating compatible output from existing processed files
Version (-v, --version)
Display the installed version.