Skip to main content

Extract code blocks from text files

Project description


CircleCI codecov PyPi Version GitHub stars

This is excode, a tool for extracting code blocks from markdown files.

For example, the command



Lorem ipsum
some_code = 1
dolor sit amet.

and creates,

def test0():
    some_code = 1

This can be used for automatically turning snippets from a into unit tests.

Filter code blocks

The command

excode -f "python,test"

only extracts code blocks with the header


(Appending anything to <lang_name> in the markdown header doesn't influence the syntax highlighting.)


excode is available from the Python Package Index, so simply

pip install -U excode

to install or upgrade.


To run the unit tests, check out this repository and type



To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    $ make publish


excode is published under the MIT license.

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
excode-0.4.3-py2.py3-none-any.whl (4.3 kB) Copy SHA256 hash SHA256 Wheel py2.py3
excode-0.4.3.tar.gz (3.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page