Re-implemented escaping algorithm. Added HTML5 references.