def self.parse_style_attribute(attributes)
original_style = attributes['style']
raw_style = attributes[1]
if !raw_style || raw_style.include?(' ')
attributes['style'] = raw_style
[raw_style, original_style]
else
hash_index = raw_style.index('#')
dot_index = raw_style.index('.')
if !hash_index.nil? && (dot_index.nil? || hash_index < dot_index)
parsed_style = attributes['style'] = (hash_index > 0 ? raw_style[0..(hash_index - 1)] : nil)
id = raw_style[(hash_index + 1)..-1]
if !dot_index.nil?
id, roles = id.split('.', 2)
attributes['id'] = id
attributes['role'] = roles.tr('.', ' ')
else
attributes['id'] = id
end
elsif !dot_index.nil? && (hash_index.nil? || dot_index < hash_index)
parsed_style = attributes['style'] = (dot_index > 0 ? raw_style[0..(dot_index - 1)] : nil)
roles = raw_style[(dot_index + 1)..-1]
if !hash_index.nil?
roles, id = roles.split('#', 2)
attributes['id'] = id
attributes['role'] = roles.tr('.', ' ')
else
attributes['role'] = roles.tr('.', ' ')
end
else
parsed_style = attributes['style'] = raw_style
end
[parsed_style, original_style]
end
end