toHtml ported to utils