use streamdown_parser::Parser;
use streamdown_render::{RenderStyle, Renderer};
fn main() {
let markdown = r#"# Custom Styled Output
This example shows how to customize the colors and styling.
## Code Block
```python
def greet(name):
return f"Hello, {name}!"
print(greet("World"))
```
## Features
- **Bold text** stands out
- *Italic text* is emphasized
- `inline code` is highlighted
> A quote with custom colors!
"#;
let custom_style = RenderStyle {
bright: "0;255;255".to_string(),
head: "0;255;128".to_string(),
symbol: "255;255;0".to_string(),
grey: "128;128;128".to_string(),
dark: "20;20;60".to_string(),
mid: "80;60;120".to_string(),
light: "180;160;220".to_string(),
};
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::with_style(&mut output, width, custom_style);
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());
}