Multiple inner whitespaces are collapsed to a single space (except in pre tags): Whitespace surrounding block-level tags is removed. Self-closing tags are converted to open tags. Attributes are sorted and lowercased. References are converted to unicode, except that '<', '>', '&', and '"' are rendered using entities.