README.md

July 22, 2026 · View on GitHub

ratatui-markdown logo

ratatui-markdown

Markdown rendering, Mermaid diagrams, syntax highlighting, collapsible trees, and rich scroll widgets for ratatui

CI License: SySL Crates.io

Quick Start | Documentation | API Reference

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Français | Español | Русский | العربية


A Rust library providing markdown rendering, Mermaid diagrams, syntax highlighting, collapsible JSON/TOML tree views, and a rich hybrid scroll system — all built on top of ratatui.

Features

  • Markdown rendering — parse and render markdown to styled ratatui::text::Lines, with support for headings, lists, code blocks, blockquotes, tables, images, and inline formatting (bold, italic, inline code)
  • Mermaid diagrams — render sequence, pie, gantt, and state diagrams from ```mermaid code blocks (feature-gated: mermaid)
  • Syntax highlighting — tree-sitter based code block highlighting with per-language feature flags (feature-gated: highlight-lang-*)
  • Image support — resolve ![alt](path) images via the ImageResolver trait (feature-gated: image)
  • Custom rendering hooks — override rendering of any block type (headings, code blocks, lists, tables, etc.) via the RenderHooks trait
  • Collapsible trees — parse JSON or TOML into interactive collapsible trees with expand/collapse, styled keys, and keyboard navigation
  • Hybrid scroll system — dual-mode scrolling: free-scroll for exploring content, engaged mode for navigating focusable items
  • MarkdownPreview / MarkdownViewer — unified widgets combining markdown, tree views, and scroll into a single view
  • RichTheme — fully themeable via the RichTextTheme trait: 15+ color slots for text, borders, JSON values, popups, and more
  • CJK-aware text wrapping — correct width calculation for CJK characters via unicode-width
  • TOML frontmatter support — optionally strip +++-delimited TOML frontmatter from rendered content

Quick Start

Prerequisites

Installation

[dependencies]
ratatui-markdown = "0.3"

For the full feature set (enabled by default):

[dependencies]
ratatui-markdown = { version = "0.3", features = ["preview"] }

Individual features can be enabled selectively:

FeatureDescriptionDefault
markdownMarkdown parsing and rendering
imageImage resolution via ImageResolver trait
scrollHybrid scroll and scrollable widgets
treeJSON/TOML collapsible tree (requires scroll)
previewMarkdownPreview unified widget (requires markdown, scroll, tree)
mermaidMermaid diagram rendering (requires markdown)
viewerMarkdownViewer widget (requires markdown, scroll)
highlightSyntax highlighting via tree-sitter
highlight-lang-*Individual language grammars (requires highlight)
highlight-lang-allAll bundled language grammars

Examples

ExampleDescriptionFeatures required
basicMinimal markdown rendering
codeSyntax-highlighted code blockshighlight-lang-all
custom_code_blockCustom code block rendering hooks
imageImage embedding and zoomimage
mermaidMermaid diagram renderingmermaid
tree_listCollapsible JSON/TOML tree view
cargo run --example basic
cargo run --example code --features highlight-lang-all
cargo run --example image
cargo run --example mermaid
cargo run --example tree_list

Documentation

License

Licensed under the Synthetic Source License (SySL), Version 1.0.