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 Markdown Demo with Table Updates\n----------------------------------------\n"
    );

    // Stream some headings and text
    for line in sr.push("# Live Data Dashboard\n\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

    for line in sr.push("## System Metrics\n\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

    // Stream table header and separator
    for line in sr.push("| Component | Status | Value | Trend |\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

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

    // Stream first data row
    let lines = sr.push("| CPU Usage | Normal | 42%   | →     |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    // Stream second data row
    let lines = sr.push("| Memory    | Normal | 67%   | ↗     |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    // Stream third data row
    let lines = sr.push("| Disk I/O  | High   | 89%   | ↗↗    |\n");
    for line in lines {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(500));

    // Add some text after the table
    for line in sr.push("\n### Alerts\n\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

    // Stream a list
    for line in sr.push("- High disk I/O detected\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

    for line in sr.push("- Memory usage trending upward\n") {
        println!("{line}");
    }
    io::stdout().flush()?;
    thread::sleep(Duration::from_millis(200));

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

    println!();
    Ok(())
}