use {crate::ast::Node, std::fmt::Write}; pub fn convert(source: &[Node]) -> String { let mut html = String::new(); // Since we have an AST tree of the Gemtext, it is very easy to convert from // this AST tree to an alternative markup format. for node in source { match node { Node::Text(text) => { let _ = write!(&mut html, "
{text}
"); } Node::Link { to, text } => { let _ = write!( &mut html, "{}{text}"); } Node::PreformattedText { text, .. } => { let _ = write!(&mut html, "
{text}");
}
Node::Whitespace => {}
}
}
html
}