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.
- 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
git clone https://github.com/fed-stew/streamdown-rs.git
cd streamdown-rs
cargo install --path .cargo install streamdown# Pipe from any command
echo "# Hello World" | sd
# Render a file
cat README.md | sd
# From an LLM
curl -s https://api.openai.com/... | sdsd document.md# Run a command in a PTY and render its markdown output
sd --exec "python chat.py"
sd -e "llm query 'explain rust lifetimes'"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
Streamdown looks for configuration in:
$XDG_CONFIG_HOME/streamdown/config.toml~/.config/streamdown/config.toml~/.streamdown.toml
[style]
# Base hue (0.0-1.0) for color theme
hue = 0.6
# Terminal margin (spaces on left)
margin = 2
[style.multipliers]
# HSV multipliers for derived colors
dark = [1.0, 0.8, 0.15]
mid = [1.0, 0.5, 0.4]
symbol = [1.0, 0.6, 0.7]
head = [1.0, 0.4, 0.9]
grey = [0.0, 0.0, 0.5]
bright = [1.0, 0.8, 1.0]
[features]
# Enable OSC 52 clipboard for code blocks
clipboard = true
# Enable savebrace (save code to temp file)
savebrace = true
# Prompt pattern for PTY mode (regex)
prompt_pattern = "[$#>] $"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
# Level 1 Heading
## Level 2 Heading
### Level 3 HeadingRendered with bold text and proper centering.
```python
def hello():
print("Hello, World!")
```Rendered with:
- Syntax highlighting
- Box drawing borders
- Language label
- Clipboard/savebrace integration
| Name | Age | City |
|-------|-----|------- |
| Alice | 30 | NYC |
| Bob | 25 | LA |Rendered with Unicode box drawing characters.
- Item 1
- Nested item
- Deeply nested
- Item 2
1. First
2. Second
3. ThirdRendered with proper indentation and bullets.
<think>
Internal reasoning that should be visually distinct...
</think>Special rendering for LLM "thinking" output.
Use streamdown as a library in your Rust project:
use streamdown_parser::Parser;
use streamdown_render::Renderer;
fn main() {
let markdown = "# Hello\n\nThis is **bold** text.";
let mut output = Vec::new();
let mut parser = Parser::new();
{
let mut renderer = Renderer::new(&mut output, 80);
for line in markdown.lines() {
for event in parser.parse_line(line) {
renderer.render_event(&event).unwrap();
}
}
}
print!("{}", String::from_utf8(output).unwrap());
}| 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.) |
cargo build
cargo build --release# Run all tests
cargo test --workspace
# Run specific crate tests
cargo test -p streamdown-parser
# Run with output
cargo test -- --nocapturecargo doc --workspace --open| 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 |
MIT License - see LICENSE for details.
- kristopolous for the original Streamdown Python implementation
- syntect for syntax highlighting
- The Rust community for excellent crates
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