smart-markdown 0.3.0

Parse and render Markdown to ANSI-styled terminal output with live in-place refresh
Documentation
use smart_markdown::{StreamRenderer, ThemeMode};
use std::io::{self, Write};
use std::thread;
use std::time::Duration;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut sr = StreamRenderer::new(80, ThemeMode::Dark);

    println!("Streaming Table Updates Demo\n--------------------------\n");

    // Simulate LLM streaming table header and separator
    for line in sr.push("# Real-time Data Analysis\n\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(300));

    for line in sr.push("| Time | Metric | Value | Status |\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(300));

    for line in sr.push("|------|--------|-------|--------|\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(300));

    // Simulate LLM streaming data rows one by one
    let lines = sr.push("| 10:00 | CPU Usage | 45% | Normal |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    let lines = sr.push("| 10:05 | CPU Usage | 67% | Warning |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    let lines = sr.push("| 10:10 | CPU Usage | 82% | Alert |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    let lines = sr.push("| 10:15 | CPU Usage | 95% | Critical |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    // Flush any remaining content
    for line in sr.flush_remaining() {
        println!("{line}");
    }

    println!();
    Ok(())
}