Minimal markdown parser
Project description
Minimd
Minimal markdown parser.
https://pypi.org/project/minimd/
Tokenize some markdown tags from text files.
Installation
Install minimd library by running pip install minimd.
Usage
Extract token from a markdown file.
>>> import minimd
>>> with open('docs/doc1.md') as f:
... for token in minimd.tokenize_file(f):
... print(token)
...
Token.TITLE('# First title\n', level=1)
Token.AFTER_TITLE(level=1)
Token.LINE('\n')
Token.LINE('* Bullet point\n')
Token.LINE('\n')
Token.START_CODE('```python\n', language='python', skip=False)
Token.LINE('def example_function():\n')
Token.LINE(" print('foo')\n")
Token.END_CODE('```\n')
Or for an iterable of files (tokens are added to separate files).
>>> import minimd
>>> with open('docs/doc1.md') as f1, open('docs/doc2.md') as f2:
... for token in minimd.tokenize_files([f1, f2]):
... print(token)
...
Token.FILE()
Token.TITLE('# First title\n', level=1)
Token.AFTER_TITLE(level=1)
Token.LINE('\n')
Token.LINE('* Bullet point\n')
Token.LINE('\n')
Token.START_CODE('```python\n', language='python', skip=False)
Token.LINE('def example_function():\n')
Token.LINE(" print('foo')\n")
Token.END_CODE('```\n')
Token.AFTER_FILE()
Token.FILE()
Token.TITLE('# Second title\n', level=1)
Token.AFTER_TITLE(level=1)
Token.LINE('\n')
Token.TITLE('## Subtitle\n', level=2)
Token.AFTER_TITLE(level=2)
Token.LINE('\n')
Token.LINE('Hello World!\n')
Token.AFTER_FILE()
Test input files are saved in docs directory.
There is also a minimd entrypoint to see how is tokenized a set of files.
% minimd docs/*.md
Token.FILE()
Token.TITLE('# First title\n', level=1)
Token.AFTER_TITLE(level=1)
Token.LINE('\n')
Token.LINE('* Bullet point\n')
Token.LINE('\n')
Token.START_CODE('```python\n', language='python', skip=False)
Token.LINE('def example_function():\n')
Token.LINE(" print('foo')\n")
Token.END_CODE('```\n')
Token.AFTER_FILE()
Token.FILE()
Token.TITLE('# Second title\n', level=1)
Token.AFTER_TITLE(level=1)
Token.LINE('\n')
Token.TITLE('## Subtitle\n', level=2)
Token.AFTER_TITLE(level=2)
Token.LINE('\n')
Token.LINE('Hello World!\n')
Token.AFTER_FILE()
Development
Environment
Use pip install -e '.[dev]' to install minimd with development dependencies (tests & lint).
Contributing
Code of the project is managed on https://github.com/entwanne/minimd/ git repository.
Building & deploying a new version
You need to install twine package (pip install twine) to be able to deploy a version of the library.
You can use python -m build (pip install build) to build the current version of the package.
Then you can deploy this version to PyPI by running twine upload dist/*.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minimd-1.0.2.tar.gz.
File metadata
- Download URL: minimd-1.0.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
431e06fccc6c3fcbbac1320fd69da6aedf6913539e2fd38aff71380325f84a73
|
|
| MD5 |
87f07a25630a0ae65130917d42bf51f8
|
|
| BLAKE2b-256 |
b83773250d08da94e0cf12b765daf17d9dd873178efa103559e0b8d5d462f6af
|
File details
Details for the file minimd-1.0.2-py3-none-any.whl.
File metadata
- Download URL: minimd-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03e4db5124d138067f9bff8739e08ddf4b2b7f009467b34e4e46bf6b84343889
|
|
| MD5 |
e3215e0e0522a38f5ae1e6115661af41
|
|
| BLAKE2b-256 |
41092032516a029851e04ec31c69f8268b378c90619e7b6686523ceb84997c5b
|