A markdown parser
Project description
meltdown
A naive markdown parser in pure python.
WARNING: The library will never attempt to do any sanitization on the input. If used for user generated content it is highly recommended to use an external sanitization library.
Installation
meltdown currently only supports Python 3.12.
pip install meltdown
Usage
from meltdown import MarkdownParser, HtmlProducer
doc = MarkdownParser().parse("# Hello **friends**!")
html = HtmlProducer().produce(doc)
print(doc.dump())
print(html)
The default HtmlProducer
is heavily inspired by pandoc,
however, if you are unhappy you can easily write your own producer or if only
some formattings are unwanted override the default methods.
In the following example we change the bold formatting form <strong>
to <b>
:
from meltdown import MarkdownParser, HtmlProducer
from meltdown.Nodes import *
from typing import Self
class CustomHtmlProducer(HtmlProducer):
def visit_bold(self: Self, node: BoldNode):
self._output += "<b>"
for child in node.children:
child.accept(self)
self._output += "<b>"
doc = MarkdownParser().parse("# Hello **friends**!")
html = CustomHtmlProducer().produce(doc)
print(html)
Run all tests
python -m pytest
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file meltdown-0.0.4.tar.gz
.
File metadata
- Download URL: meltdown-0.0.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d7079384d8702b7bdadeafd2a0b7e1ed32846c072eb13d365cc96f08503b0c |
|
MD5 | 721c7d92a136853feef345915ac25df9 |
|
BLAKE2b-256 | 5dc4ab221e1727c939496f9f0cfe296c31cd4179fbe05dfb77a090f4271f9712 |
File details
Details for the file meltdown-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: meltdown-0.0.4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09e97a08854b843f4e3de1aaceef51b20b8f916a89c9647531424434d751bf98 |
|
MD5 | 6ad589a60ce7a450e01c961e261f4c05 |
|
BLAKE2b-256 | 6a0e11395423012dbaa1a7a436a133cb0d33e34a34c784fc01034d3099ba0649 |