def read_attribute_list(src, con=nil, break_on_chars=nil)
break_on_chars = Array(break_on_chars)
separators = break_on_chars + ['=', ' ', "\t"]
escaped = Maruku::EscapedCharInQuotes
al = AttributeList.new
loop do
src.consume_whitespace
break if break_on_chars.include? src.cur_char
case src.cur_char
when ':'
src.ignore_char
when nil
break
when '='
src.ignore_char
maruku_error "In attribute lists, cannot start identifier with `=`."
tell_user "Ignoring and continuing."
when '#'
src.ignore_char
if id = read_quoted_or_unquoted(src, con, escaped, separators)
al << [:id, id]
else
maruku_error 'Could not read `id` attribute.', src, con
tell_user 'Ignoring bad `id` attribute.'
end
when '.'
src.ignore_char
if klass = read_quoted_or_unquoted(src, con, escaped, separators)
al << [:class, klass]
else
maruku_error 'Could not read `class` attribute.', src, con
tell_user 'Ignoring bad `class` attribute.'
end
else
unless key = read_quoted_or_unquoted(src, con, escaped, separators)
maruku_error 'Could not read key or reference.'
next
end
if src.cur_char != '=' && key.length > 0
al << [:ref, key]
next
end
src.ignore_char
if val = read_quoted_or_unquoted(src, con, escaped, separators)
al << [key, val]
else
maruku_error "Could not read value for key #{key.inspect}.", src, con
tell_user "Ignoring key #{key.inspect}"
end
end
end
al
end