Skip to main content

Extract code blocks from text files

Project description

excode

CircleCI codecov PyPi Version GitHub stars

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

For example, the command

excode input.md test.py

takes input.md,

Lorem ipsum
```python
some_code = 1
```
dolor sit amet.

and creates test.py,

def test0():
    some_code = 1
    return

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

Filter code blocks

The command

excode -f "python,test" input.md test.py

only extracts code blocks with the header

```python,test
some_code()
```

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

Installation

excode is available from the Python Package Index, so simply

pip install -U excode

to install or upgrade.

Testing

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

pytest

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    $ make publish
    

License

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 Jun 9, 2018
excode-0.4.3.tar.gz (3.9 kB) Copy SHA256 hash SHA256 Source None Jun 9, 2018

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 DigiCert DigiCert EV certificate StatusPage StatusPage Status page