///|
/// Escape text for HTML contexts without relying on a runtime or DOM.
pub fn escape_html(value : String) -> String {
  let out = StringBuilder::new()
  for c in value {
    match c {
      '&' => out.write_string("&")
      '<' => out.write_string("<")
      '>' => out.write_string(">")
      '"' => out.write_string(""")
      '\'' => out.write_string("'")
      _ => out.write_string(c.to_string())
    }
  }
  out.to_string()
}

///|
pub fn Report::to_html(self : Report) -> String {
  let out = StringBuilder::new()
  out.write_string("",
  )
  for item in self.lines {
    out.write_string("")
  }
  out.write_string("
") out.write_string(escape_html(statement_name(self.kind))) out.write_string(" — ") out.write_string(escape_html(self.period)) out.write_string( "
LineAmountEntries
") out.write_string(escape_html(item.line)) out.write_string("") out.write_string(item.amount.to_string()) out.write_string("") out.write_string(item.entries.to_string()) out.write_string("
Total") out.write_string(self.total.to_string()) out.write_string("
") out.to_string() } ///| pub fn report_document(report : Report, title : String) -> String { "" + escape_html(title) + "" + report.to_html() + "" } ///| pub fn render_variances(variances : Array[Variance]) -> String { let out = StringBuilder::new() out.write_string( "| Line | Current | Prior | Variance | Percent |\n| --- | ---: | ---: | ---: | ---: |\n", ) for item in variances { out.write_string("| ") out.write_string(item.line) out.write_string(" | ") out.write_string(item.current.to_string()) out.write_string(" | ") out.write_string(item.prior.to_string()) out.write_string(" | ") out.write_string(item.absolute.to_string()) out.write_string(" | ") match item.percent { Some(value) => out.write_string(value.to_string()) None => out.write_string("n/a") } out.write_string(" |\n") } out.to_string() }