-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Tarun Nayaka R edited this page Dec 20, 2025
·
3 revisions
A lightweight, extensible Markdown → HTML parser with a clean Python API and CLI.
Designed for learning, hackability, and real-world tooling without heavy dependencies.
mdparser-html converts Markdown into clean, modern HTML with optional styling, Tailwind support, and syntax highlighting.
Core goals:
- Simple architecture
- Single public API
- Easy to extend
- Predictable output
pip install mdparser-htmlPython ≥ 3.8 required. No runtime dependencies.
md2html input.md -o output.htmlfrom mdparser import parse_markdown
html = parse_markdown("# Hello World")
print(html)parse_markdown(
text: str,
full_html: bool = True,
title: str = "Markdown to HTML",
include_cdn: bool = True
) -> str| Name | Type | Description |
|---|---|---|
text |
str |
Markdown input |
full_html |
bool |
Return full HTML document or body-only |
title |
str |
HTML <title>
|
include_cdn |
bool |
Include Prism / Highlight.js / Tailwind |
Full HTML output
html = parse_markdown(md)Body-only output
body = parse_markdown(md, full_html=False)Disable CDN
html = parse_markdown(md, include_cdn=False)# Heading 1
## Heading 2# [text-blue-500 font-bold] Styled Heading**bold**
*italic*
`code`- Item
- Item
1. First
2. SecondCustom fenced blocks using ::: with Tailwind classes.
::: hero bg-blue-100 p-4
# Welcome
This is a hero section
:::Rendered as:
<div class="hero bg-blue-100 p-4">
<h1>Welcome</h1>
<p>This is a hero section</p>
</div>✅ Supports nested fenced divs
Simple, readable table syntax:
:::table
Name | Role | Age
Tarun | Developer | 21
Alex | Tester | 22
:::Rendered as:
- Semantic
<table> - Styled headers
- Clean borders & spacing
- Headings, tables, fenced divs → styled
- Inline elements remain semantic
- Tailwind classes passed through unchanged
- No forced CSS frameworks
-
Single public API:
parse_markdown - Regex + state-machine parsing
- Recursive fenced div handling
- Internal helpers intentionally hidden
- Output-first design (not AST yet)
- 36+ test cases
- Nested fenced div coverage
- Table edge cases
- CLI + API tests
Run locally:
pytest- AST-based parser
- Performance optimizations
- Additional output formats (Pug)
- Plugin hooks
- Markdown extensions
- Issues welcome
- PRs encouraged
- Architecture discussions preferred before large changes
- 📦 PyPI: https://pypi.org/project/mdparser-html
- 📘 Docs: https://mdparser.tarunnayaka.me
- 🐙 GitHub: https://github.com/Rtarun3606k/mdparser
- 🐛 Issues: https://github.com/Rtarun3606k/mdparser/issues
MIT License © 2025 Tarun Nayaka R