def read_image(src, con)
src.ignore_chars(2)
alt_text = read_span(src, EscapedCharInText, [?]])
src.ignore_char
if src.cur_char == SPACE and
(src.next_char == ?[ or src.next_char == ?( )
src.ignore_char
end
case src.cur_char
when ?(
src.ignore_char
src.consume_whitespace
url = read_url(src, [SPACE,?\t,?)])
if not url
error "Could not read url from #{src.cur_chars(10).inspect}",
src,con
end
src.consume_whitespace
title = nil
if src.cur_char != ?)
quote_char = src.cur_char
title = read_quoted(src,con)
if not title
maruku_error 'Must quote title',src,con
else
if not src.next_matches(/\s*\)/)
rest = read_simple(src, escaped=[], break_on_chars=[?)],
break_on_strings=[])
rest.chop!
title << quote_char << rest
end
end
end
src.consume_whitespace
closing = src.shift_char
if closing != ?)
error( ("Unclosed link: '"<<closing<<"'")+
" Read url=#{url.inspect} title=#{title.inspect}",src,con)
end
con.push_element md_im_image(alt_text, url, title)
when ?[
ref_id = read_ref_id(src,con)
if not ref_id
error('Reference not closed.', src, con)
ref_id = ""
end
if ref_id.size == 0
ref_id = alt_text.to_s
end
ref_id = sanitize_ref_id(ref_id)
con.push_element md_image(alt_text, ref_id)
else
ref_id = sanitize_ref_id(alt_text.to_s)
con.push_element md_image(alt_text, ref_id)
end
end