Skip to main content

mdhtml2term

Render MDHTML Markdown in the terminal with Rich.

md_blocks parses Markdown with mdhtml and returns one Rich renderable per top-level block. A terminal app can then print, fold or replace each block on its own. ipyai uses it to render AI replies.

Install

pip install mdhtml2term

Usage

from rich.console import Console
from mdhtml2term import md_blocks

console = Console()
for block in md_blocks(markdown_text): console.print(block)

md_blocks takes a Markdown string and returns a list of Rich renderables. theme names the Pygments theme for code blocks, and defaults to ansi_dark. Other keyword arguments go to mdhtml.md2dom.

Supported content

  • Headings, paragraphs, block quotes, lists, code blocks, tables and horizontal rules. Block quotes and list items can hold any other block, including code and further quotes.
  • Bold, italic, inline code, strikethrough, highlight and line breaks.
  • Links, as OSC 8 hyperlinks followed by their address in brackets.
  • Images, as their alt text in square brackets.
  • Task list checkboxes, as [ ] and [x].
  • A numbered list that resumes after other content keeps its numbering.

Other inline elements show their text. Other block containers render their children.

Metadata

Release files for mdhtml2term 0.1.0

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

Source distribution (sdist)

Source distribution for mdhtml2term 0.1.0
File Size Uploaded
mdhtml2term-0.1.0.tar.gz 9.3 kB Details

Built distribution (wheel)

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

Total release size: 17.9 kB

Release files / mdhtml2term-0.1.0.tar.gz

Download URL mdhtml2term-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cdc3d6f45b4b8969d53f0e5f0a638538fce4d088683ee1c2e78674236c233715
BLAKE2b-256 checksum
How to use checksums
f6aa9d4a6a42db49a70b96b731f004d23c85f4f2d2c0fc18db30ef7bd13d74cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / mdhtml2term-0.1.0-py3-none-any.whl

Download URL mdhtml2term-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d60f9d4de85bdbc98376e97a6198b52cd04f4e463459e5712d454fefd18c38f7
BLAKE2b-256 checksum
How to use checksums
8dec9195574f9e020037919f58b502e8f134b194d981ed2031915e90498c2323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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