mirror of
https://git.proxmox.com/git/rustc
synced 2025-08-14 14:26:04 +00:00
23 lines
522 B
Rust
23 lines
522 B
Rust
use std::io::Read;
|
|
|
|
use pulldown_cmark::{Event, Parser};
|
|
|
|
/// Show all events from the text on stdin.
|
|
fn main() {
|
|
let mut text = String::new();
|
|
std::io::stdin().read_to_string(&mut text).unwrap();
|
|
|
|
eprintln!("{text:?} -> [");
|
|
let mut width = 0;
|
|
for event in Parser::new(&text) {
|
|
if let Event::End(_) = event {
|
|
width -= 2;
|
|
}
|
|
eprintln!(" {:width$}{event:?}", "");
|
|
if let Event::Start(_) = event {
|
|
width += 2;
|
|
}
|
|
}
|
|
eprintln!("]");
|
|
}
|