Skip to main content

A command-line utility for pulling code blocks out of markdown files.

$ pip install mkcodes

# For traditional markdown code-block support.
$ pip install mkcodes[markdown]

$ mkcodes --help
Usage: mkcodes [OPTIONS] INPUTS...

Options:
  --output TEXT
  --github / --markdown  Github-flavored fence blocks or pure markdown.
  --safe / --unsafe      Allow code blocks without language hints.
  --package-python       Add __init__.py files to python dirs for test
                         discovery
  --default-lang TEXT    Assumed language for code blocks without language
                         hints.
  --help                 Show this message and exit.

Why would I want such a thing?

My purpose is testing.

You can easily enough doctest a markdown file with python -m doctest myfile.md, but I don't like typing or looking at a whole bunch of >>> and ...'s. Also there's no way that I know of to run linters against such code blocks.

Instead, I include (pytest) functional tests in my codeblocks, extract the code blocks with this script, and then run my test runner and linters against the output files.

Running Tests

./test

Metadata

Release files for mkcodes 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkcodes 0.2.0
File Size Uploaded
mkcodes-0.2.0.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkcodes 0.2.0
File Interpreter ABI Platform
mkcodes-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / mkcodes-0.2.0.tar.gz

Download URL mkcodes-0.2.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
340fbf47c7fccb4ceb16b874b036090d05e9f8b9355bc251e125888a3da71624
BLAKE2b-256 checksum
How to use checksums
5245ab73436ffbe517afbee7270b046ee0ee5e51ae0a39229e4a5c24b21b575d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / mkcodes-0.2.0-py3-none-any.whl

Download URL mkcodes-0.2.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e5a5e9200747b22a007d0d50c0f9274e6e9ecd5a7b1cdaf300ff28fdda1553d
BLAKE2b-256 checksum
How to use checksums
3856472c0e6982c5184f24812a4968b950349ea9523141749df786c4b28d1b9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page