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.

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

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page