use nostr::Url;

#[askama::filter_fn]
pub fn gemtextify_bio(
    s: &String,
    _env: &dyn askama::Values,
) -> askama::Result<String> {
    let mut bio = String::new();

    for line in s.lines() {
        if let Ok(url) = Url::parse(line) {
            bio.push_str(&format!("=> {url}"));
        } else {
            bio.push_str(&format!("{line}\n"));
        }
    }

    Ok(bio)
}
