use streamdown_parser::Parser;
use streamdown_render::Renderer;
fn main() {
let markdown = r#"# Welcome to Streamdown!
This is a **Rust** port of the original Python [Streamdown](https://github.com/kristopolous/Streamdown).
## Features
- Streaming markdown rendering
- Syntax highlighting
- Beautiful terminal output
## Code Example
```rust
fn main() {
println!("Hello, World!");
}
```
## Table
| Feature | Status |
|---------|--------|
| Parser | ✅ Done |
| Render | ✅ Done |
> "The best way to predict the future is to invent it."
> — Alan Kay
"#;
let mut output = Vec::new();
let mut parser = Parser::new();
let width = terminal_size::terminal_size()
.map(|(w, _)| w.0 as usize)
.unwrap_or(80);
{
let mut renderer = Renderer::new(&mut output, width);
for line in markdown.lines() {
let events = parser.parse_line(line);
for event in events {
renderer.render_event(&event).unwrap();
}
}
}
print!("{}", String::from_utf8(output).unwrap());
}