def parse_attributes(data)
attribute_name = nil
in_quotes = false
quote_type = nil
ret = {}
d = ""
prev_char = nil
for char in data.each_char
case
when char == "=" && attribute_name.nil? && in_quotes == false
attribute_name = d.strip
d = ""
when (char == '"' || char == "'") && in_quotes == false && !attribute_name.nil?
in_quotes = true
quote_type = char
when (char == quote_type && in_quotes == true && prev_char != '\\') || (char == ' ' && in_quotes == false && !d.blank?)
ret[attribute_name] = d if WikiBuffer::HTMLElement::ALLOWED_ATTRIBUTES.include?(attribute_name)
attribute_name = nil
in_quotes = false
d = ""
else
prev_char = char
d += char
end
end
ret
end