Skip to main content

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

Project description

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

Project details


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.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

mkcodes-0.1.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkcodes-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.11 Linux/5.10.63

File hashes

Hashes for mkcodes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 df4f59e2e754b5792de8d8c5af13f907452be41a0f0f1d5007fc2e557a2de975
MD5 aa8b767d9057402a958f7121c226c9db
BLAKE2b-256 b83392d9985faf14581a7e5d15ec1e563351ebf652ba62da19f656b6893bf85d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mkcodes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.11 Linux/5.10.63

File hashes

Hashes for mkcodes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 205c081400fbb0fc1cd2407e771a158b43df6fdfb46ebea3f63de1f310b57ad4
MD5 a899c6c6cd8baf2049e00af424d81850
BLAKE2b-256 94530b5b182c579eb387c162f72aaad6e5358bde3e7b30f8c37926bd8a1569a9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page