You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Versions: markdown-it-py 3.0.0 (__version__ = "4.0.0" internal) + mdurl 0.1.2
Type: Pure Python (both)
SPM target: Bundled in Rich dep chain (Console.print(Markdown(...)))
Total modules: markdown_it 66, mdurl 6
CommonMark-compliant Markdown parser (markdown_it) plus its small
URL-handling helper (mdurl). Used by rich for its
Console.print(Markdown(...)) rendering, and importable directly when
you want to parse / transform Markdown in your own scripts.
Modules — markdown_it
Top-level
Module
What it does
markdown_it.__init__
Re-exports MarkdownIt
markdown_it.main
MarkdownIt class — entry point. .render(src), .parse(src), .enable(rule), .disable(rule), .use(plugin)
Linkify (rules_inline.linkify) is bundled but inert unless you
also install linkify-it-py — see main.pytry: import linkify_it.
Quick start — mdurl
importmdurl# Parse a URL into components (similar to urllib.parse but with markdown-specific quirks)parsed=mdurl.parse("https://example.com/path?q=1#frag")
print(parsed.protocol, parsed.hostname, parsed.pathname)
# → 'https:' 'example.com' '/path?q=1'# Encode a URL the way markdown_it doesencoded=mdurl.encode("https://example.com/with space")
print(encoded) # 'https://example.com/with%20space'# Decodedecoded=mdurl.decode("https%3A//example.com/with%20space")
For most purposes, prefer urllib.parse (stdlib). mdurl exists to
match Markdown's specific URL-handling rules (autolinks vs links,
percent-encoding edge cases) for parser compatibility with the JS
markdown-it package.
markdown_it → HTML → custom CSS-to-PDF (no headless browser on iOS); or Markdown → LaTeX → offlinai_latex.pdftex
Transform Markdown (custom rules)
markdown_it's token-tree API
Strip Markdown to plain text
markdown_it → render → bs4 strip
Pairing with rich
fromrich.consoleimportConsolefromrich.markdownimportMarkdownconsole=Console()
console.print(Markdown("""
# Hello
Some **bold** text. Run `pip install rich` to get this.
```python
print("syntax highlighting works")
"""))
Rich's `Markdown` class converts the markdown_it token tree into rich
text + tables + syntax-highlighted code blocks for terminal display.
Works in CodeBench's in-app terminal.
---
## iOS notes
Both packages are pure Python — they work identically on iOS and any
other platform. No native extensions, no platform-specific paths.
- **`markdown_it/main.py`** has a guarded `import linkify_it` —
optional dep, skipped if absent. Linkify URL auto-detection
silently turns into a no-op without it.
- **CLI** (`python -m markdown_it`) reads stdin / file, prints HTML.
Works in CodeBench's terminal.
---
## Limitations
- **Pure Python** — slower than C implementations (`mistune` ext,
upstream `markdown` package's C accelerators). Fine for documents
under ~1 MB; noticeable for huge corpora.
- **No streaming parser** — input parsed all at once.
- **HTML in Markdown sanitised by default** — `<script>` tags etc.
passed through as text. Set `html=True` in MarkdownIt options to
allow inline HTML (trusted input only).
- **`linkify-it` not bundled** — auto-URL detection rule is registered
but skipped at runtime. `pip install linkify-it-py` to enable.
---
## Build provenance
- **markdown-it-py 3.0.0** — pure Python, identical to upstream PyPI
wheel
- **mdurl 0.1.2** — pure Python, identical to upstream
Both minimal-dependency; bundled because rich declares them as required.