Streamdown-rs 🦀
A streaming markdown renderer for modern terminals, written in Rust.
This is a Rust port of Streamdown by kristopolous, bringing the same beautiful terminal markdown rendering with the performance and safety of Rust.
✨ Features
- Streaming rendering - Renders markdown as it arrives, perfect for LLM output
- Syntax highlighting - Full language support via syntect
- Beautiful output - Pretty tables, lists, code blocks with box drawing
- PTY exec mode - Run commands and render their markdown output
- Clipboard integration - Copy code blocks via OSC 52
- Savebrace - Save code blocks to temp files for shell access
- LaTeX support - Convert LaTeX math to Unicode symbols
- Configurable - TOML configuration for colors and behavior
- Cross-platform - Full Unix support, partial Windows support
📦 Installation
From source
From crates.io (coming soon)
🚀 Quick Start
Pipe markdown content
# Pipe from any command
|
# Render a file
|
# From an LLM
|
Render a file directly
Execute a command and render output
# Run a command in a PTY and render its markdown output
📖 Usage
sd - Streamdown: A streaming markdown renderer for terminals
USAGE:
sd [OPTIONS] [FILE]
ARGS:
<FILE> Markdown file to render (reads from stdin if omitted)
OPTIONS:
-e, --exec <CMD> Execute command and render its output
-w, --width <WIDTH> Terminal width (default: auto-detect)
-c, --config <FILE> Custom config file path
-s, --scrape <DIR> Save code blocks to directory
-d, --debug Enable debug output
-h, --help Print help information
-V, --version Print version information
⚙️ Configuration
Streamdown looks for configuration in:
$XDG_CONFIG_HOME/streamdown/config.toml~/.config/streamdown/config.toml~/.streamdown.toml
Default Configuration
[]
# Base hue (0.0-1.0) for color theme
= 0.6
# Terminal margin (spaces on left)
= 2
[]
# HSV multipliers for derived colors
= [1.0, 0.8, 0.15]
= [1.0, 0.5, 0.4]
= [1.0, 0.6, 0.7]
= [1.0, 0.4, 0.9]
= [0.0, 0.0, 0.5]
= [1.0, 0.8, 1.0]
[]
# Enable OSC 52 clipboard for code blocks
= true
# Enable savebrace (save code to temp file)
= true
# Prompt pattern for PTY mode (regex)
= "[$#>] $"
Color Customization
The color theme is generated from a single base hue using HSV color space. Adjust the hue value (0.0-1.0) to change the overall color scheme:
0.0- Red0.3- Green0.6- Blue (default)0.8- Purple
🎨 Output Examples
Headings
Rendered with bold text and proper centering.
Code Blocks
```python
def hello():
```
Rendered with:
- Syntax highlighting
- Box drawing borders
- Language label
- Clipboard/savebrace integration
Tables
Rendered with Unicode box drawing characters.
Lists
- - --
1. 2.3.
Rendered with proper indentation and bullets.
Think Blocks
Special rendering for LLM "thinking" output.
🔌 Programmatic Usage
Use streamdown as a library in your Rust project:
use Parser;
use Renderer;
Crate Structure
| Crate | Description |
|---|---|
streamdown-core |
Core types, traits, and state management |
streamdown-ansi |
ANSI escape codes and terminal utilities |
streamdown-config |
Configuration loading and style computation |
streamdown-parser |
Streaming markdown parser |
streamdown-syntax |
Syntax highlighting via syntect |
streamdown-render |
Terminal rendering engine |
streamdown-plugin |
Plugin system (LaTeX, etc.) |
🔧 Development
Building
Running Tests
# Run all tests
# Run specific crate tests
# Run with output
Documentation
🆚 Comparison with Python Version
| Feature | Python | Rust |
|---|---|---|
| Streaming parsing | ✅ | ✅ |
| Syntax highlighting | ✅ (Pygments) | ✅ (syntect) |
| Tables | ✅ | ✅ |
| Code blocks | ✅ | ✅ |
| Lists (nested) | ✅ | ✅ |
| Think blocks | ✅ | ✅ |
| PTY exec mode | ✅ | ✅ |
| Clipboard (OSC 52) | ✅ | ✅ |
| Savebrace | ✅ | ✅ |
| LaTeX to Unicode | ✅ | ✅ |
| Configuration | ✅ | ✅ |
| Performance | Good | Excellent |
| Memory safety | Manual | Guaranteed |
| Binary size | ~50MB (with Python) | ~5MB |
📄 License
MIT License - see LICENSE for details.
🙏 Acknowledgments
- kristopolous for the original Streamdown Python implementation
- syntect for syntax highlighting
- The Rust community for excellent crates
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request