codemd

Crates.iocodemd
lib.rscodemd
version0.2.1
created_at2026-01-16 14:22:38.452757+00
updated_at2026-01-24 15:51:48.278073+00
descriptionCLI tool to extract code from markdown files.
homepage
repositoryhttps://github.com/AstraBert/codemd
max_upload_size
id2048678
size49,104
Clelia (Astra) Bertelli (AstraBert)

documentation

README

codemd

Command line tool to extract code from markdown files.

Installation

# with npm
npm install @cle-does-things/codemd

# with cargo
cargo install codemd

Check installation:

codemd --help

Usage

codemd --input <INPUT> --language <LANGUAGE> [--output <OUTPUT>]

Options:

  • -l, --language <LANGUAGE>: Language tag to search for (e.g. python or py for Python, typescript or ts for TypeScript..)
  • -i, --input <INPUT>: Path to the input file (must be markdown)
  • -o, --output <OUTPUT>: Path to the output file. If not provided, code will be printed to the console with syntax highlighting.
  • -c, --command <COMMAND>: Command to execute in order to run the code. Can be used only when --output is set.
  • -h, --help: Print help information
  • -V, --version: Print version information

[!NOTE]

When using the --language option, be mindful of the fact that it means language tag: python and py are two distinct tags, even if they refer to the same language.

Examples

Read code and rich-print it to stdout:

codemd --input README.md --language python

Read code and write the output to a file:

codemd --input guide.md --language sh --output guide.sh

Read the code, write to a file and execute a command:

codemd --input tests.md --language python --output tests.py --command 'pytest tests.py'
Commit count: 12

cargo fmt