Skip to main content

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/*.

Metadata

Release files for minimd 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minimd 1.0.2
File Size Uploaded Provenance Actions
minimd-1.0.2.tar.gz 4.4 kB Without provenance Details for minimd-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minimd 1.0.2
File Interpreter ABI Platform Actions
minimd-1.0.2-py3-none-any.whl Python 3 none any Details for minimd-1.0.2-py3-none-any.whl

Total release size: 8.5 kB

Release files / minimd-1.0.2.tar.gz

Download URL minimd-1.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
431e06fccc6c3fcbbac1320fd69da6aedf6913539e2fd38aff71380325f84a73
BLAKE2b-256 checksum
How to use checksums
b83773250d08da94e0cf12b765daf17d9dd873178efa103559e0b8d5d462f6af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Release files / minimd-1.0.2-py3-none-any.whl

Download URL minimd-1.0.2-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03e4db5124d138067f9bff8739e08ddf4b2b7f009467b34e4e46bf6b84343889
BLAKE2b-256 checksum
How to use checksums
41092032516a029851e04ec31c69f8268b378c90619e7b6686523ceb84997c5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.6

Security for minimd 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page