Fixed HTML format function. Attributes are now encoded as well.