Refractored *_to_html functions