MCPcopy Index your code
hub / github.com/celestia-island/ratatui-markdown

github.com/celestia-island/ratatui-markdown @v0.3.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.6 ↗ · + Follow
1,055 symbols 3,042 edges 81 files 18 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ratatui-markdown logo

ratatui-markdown

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

CI License Crates.io

Quick Start | Documentation | API Reference

<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/README.md">English</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/zhs/index.md">简体中文</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/zht/index.md">繁體中文</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/ja/index.md">日本語</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/ko/index.md">한국어</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/fr/index.md">Français</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/es/index.md">Español</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/ru/index.md">Русский</a> |
<a href="https://github.com/celestia-island/ratatui-markdown/blob/dev/docs/guides/ar/index.md">العربية</a>

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:

Feature Description Default
markdown Markdown parsing and rendering
image Image resolution via ImageResolver trait
scroll Hybrid scroll and scrollable widgets
tree JSON/TOML collapsible tree (requires scroll)
preview MarkdownPreview unified widget (requires markdown, scroll, tree)
mermaid Mermaid diagram rendering (requires markdown)
viewer MarkdownViewer widget (requires markdown, scroll)
highlight Syntax highlighting via tree-sitter
highlight-lang-* Individual language grammars (requires highlight)
highlight-lang-all All bundled language grammars

Examples

Example Description Features required
basic Minimal markdown rendering
code Syntax-highlighted code blocks highlight-lang-all
custom_code_block Custom code block rendering hooks
image Image embedding and zoom image
mermaid Mermaid diagram rendering mermaid
tree_list Collapsible 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

Dual-licensed under MIT OR Apache-2.0.

Extension points exported contracts — how you extend this code

RenderHooks (Interface)
(no doc) [6 implementers]
src/markdown/hooks.rs
CodeHighlighter (Interface)
(no doc) [4 implementers]
src/highlight/mod.rs
RichTextTheme (Interface)
(no doc) [3 implementers]
src/theme.rs
CursorBlinkController (Interface)
(no doc) [1 implementers]
src/text_input/types.rs
ListItemRenderer (Interface)
(no doc) [1 implementers]
src/scroll/scrollable_list.rs
ImageResolver (Interface)
(no doc) [4 implementers]
src/markdown/image.rs

Core symbols most depended-on inside this repo

is_empty
called by 180
src/preview/mod.rs
set_entries
called by 57
src/scroll/span_tree/mod.rs
set_selected
called by 41
src/scroll/span_tree/mod.rs
render_to_lines
called by 41
src/scroll/span_tree/mod.rs
with_cursor_style
called by 40
src/scroll/span_tree/mod.rs
clear
called by 35
src/preview/mod.rs
get_muted_text_color
called by 30
src/theme.rs
parse
called by 30
src/markdown/parser.rs

Shape

Function 516
Method 420
Class 95
Enum 18
Interface 6

Languages

Rust97%
Python3%

Modules by API surface

src/markdown/render_tests.rs148 symbols
src/scroll/span_tree/mod.rs102 symbols
src/theme.rs64 symbols
src/text_input/mod.rs55 symbols
src/scroll/hybrid_scroll/mod.rs38 symbols
src/preview/mod.rs34 symbols
src/scroll/scrollable_list.rs33 symbols
src/tree/collapsible_tree/mod.rs29 symbols
scripts/utils/enforce_use_group.py27 symbols
examples/utils/mod.rs26 symbols
src/mermaid/class_diagram.rs22 symbols
src/markdown/tests.rs22 symbols

For agents

$ claude mcp add ratatui-markdown \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page