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.

Files for excode, version 0.4.3
Filename, size File type Python version Upload date Hashes
Filename, size excode-0.4.3-py2.py3-none-any.whl (4.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size excode-0.4.3.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page