///|
pub(all) struct HtmlAttrs(Map[String, String?])
///|
const NODE_RENDER_SEPARATOR = ""
///|
pub fn sexp_to_html(
source : String,
separator? : String = NODE_RENDER_SEPARATOR,
) -> Result[String, String] {
parse_sexp_html(source).map(nodes => render_html_fragment(nodes, separator~))
}
///|
pub fn render_html_fragment(
nodes : Array[SexpNode],
separator? : String = NODE_RENDER_SEPARATOR,
) -> String {
nodes.map(SexpNode::render_html).join(separator)
}
///|
pub fn render_html_document(
html_attrs : HtmlAttrs,
head : Array[SexpNode],
body : Array[SexpNode],
doctype : String?,
) -> String {
let builder = StringBuilder()
if doctype is Some(value) {
builder <+ "\n"
}
builder.write_string(render_open_tag("html", html_attrs))
builder <+ "\n "
push_rendered_lines(builder, head, " ")
builder <+ "\n \n "
push_rendered_lines(builder, body, " ")
builder <+ "\n \n