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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkcodes-0.2.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkcodes-0.2.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file mkcodes-0.2.0.tar.gz.

File metadata

  • Download URL: mkcodes-0.2.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for mkcodes-0.2.0.tar.gz
Algorithm Hash digest
SHA256 340fbf47c7fccb4ceb16b874b036090d05e9f8b9355bc251e125888a3da71624
MD5 0994810f9cc49eda526c33c7c92a1eb2
BLAKE2b-256 5245ab73436ffbe517afbee7270b046ee0ee5e51ae0a39229e4a5c24b21b575d

See more details on using hashes here.

File details

Details for the file mkcodes-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mkcodes-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for mkcodes-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e5a5e9200747b22a007d0d50c0f9274e6e9ecd5a7b1cdaf300ff28fdda1553d
MD5 00f03fd4078fade3a4c7bb73e0612cdf
BLAKE2b-256 3856472c0e6982c5184f24812a4968b950349ea9523141749df786c4b28d1b9d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page