| Crates.io | codemd |
| lib.rs | codemd |
| version | 0.2.1 |
| created_at | 2026-01-16 14:22:38.452757+00 |
| updated_at | 2026-01-24 15:51:48.278073+00 |
| description | CLI tool to extract code from markdown files. |
| homepage | |
| repository | https://github.com/AstraBert/codemd |
| max_upload_size | |
| id | 2048678 |
| size | 49,104 |
Command line tool to extract code from markdown files.
# with npm
npm install @cle-does-things/codemd
# with cargo
cargo install codemd
Check installation:
codemd --help
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
--languageoption, be mindful of the fact that it means language tag:pythonandpyare 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'