def normalize_token(token)
if token[:type] == :EmptyTag
unless VOID_ELEMENTS.include?(token[:name])
parse_error("incorrectly-placed-solidus")
end
token[:type] = :StartTag
end
if token[:type] == :StartTag
token[:name] = token[:name].downcase
unless token[:data].empty?
data = token[:data].reverse.map {|attr, value| [attr.downcase, value] }
token[:data] = Hash[*data.flatten]
end
elsif token[:type] == :EndTag
parse_error("attributes-in-end-tag") unless token[:data].empty?
token[:name] = token[:name].downcase
end
token
end