Skip to main content

render

Function render 

Source
pub fn render(tokens: Vec<Token>) -> String
Expand description

Renders a token stream into a raw ANSI-escaped string.

Text tokens are appended as-is. Tag tokens are converted to their corresponding ANSI escape sequences. Does not append a trailing reset; callers are responsible for that if needed.

§Example

let tokens = tokenize("[red]hello[/]")?;
let output = render(tokens);
assert_eq!(output, "\x1b[31mhello\x1b[0m");