use std::fs;

use url::Url;

fn main() -> anyhow::Result<()> {
    println!("PWD: {}", std::env::current_dir()?.display());
    let _url = "https://slashdot.org/story/25/01/24/1813201/walgreens-replaced-fridge-doors-with-smart-screens-its-now-a-200-million-fiasco?utm_source=rss1.0mainlinkanon&utm_medium=feed";
    let _url = "https://hackaday.com/2025/01/24/hackaday-podcast-episode-305-caustic-clocks-practice-bones-and-brick-layers/";
    let _url =    "https://theonion.com/monster-devastated-to-see-film-depicting-things-he-told-guillermo-del-toro-in-confidence/";
    let _url = "https://trofi.github.io/posts/330-another-nix-language-nondeterminism-example.html";
    let _url = "https://blog.cloudflare.com/ddos-threat-report-for-2024-q4/";
    let url = "https://trofi.github.io/posts/330-another-nix-language-nondeterminism-example.html";
    let body = reqwest::blocking::get(url)?.text()?;
    let output = "/tmp/h2md/output.html";
    let inliner = css_inline::CSSInliner::options()
        .base_url(Url::parse(url).ok())
        .build();
    let inlined = inliner.inline(&body)?;
    fs::write(output, inlined)?;
    Ok(())
}
