added docstrings and rename toHTML into to_html