# File lib/maruku/input/parse_span_better.rb, line 541
        def read_link(src, con)
                # we read the string and see what happens
                src.ignore_char # opening bracket
                children = read_span(src, EscapedCharInText, [?]])
                src.ignore_char # closing bracket

                # ignore space
                if src.cur_char == SPACE and 
                        (src.next_char == ?[ or src.next_char == ?( )
                        src.shift_char
                end
                
                case src.cur_char
                when ?(
                        src.ignore_char # opening (
                        src.consume_whitespace
                        url = read_url(src, [SPACE,?\t,?)])
                        if not url
                                url = '' # no url is ok
                        end
                        src.consume_whitespace
                        title = nil
                        if src.cur_char != ?) # we have a title
                                quote_char = src.cur_char
                                title = read_quoted(src,con)
                                
                                if not title
                                        maruku_error 'Must quote title',src,con
                                else
                                        # Tries to read a title with quotes: ![a](url "ti"tle")
                                        # this is the most ugly thing in Markdown
                                        if not src.next_matches(/\s*\)/)
                                                # if there is not a closing par ), then read
                                                # the rest and guess it's title with quotes
                                                rest = read_simple(src, escaped=[], break_on_chars=[?)], 
                                                        break_on_strings=[])
                                                # chop the closing char
                                                rest.chop!
                                                title << quote_char << rest
                                        end
                                end
                        end
                        src.consume_whitespace
                        closing = src.shift_char # closing )
                        if closing != ?)
                                maruku_error 'Unclosed link',src,con
                                maruku_recover "No closing ): I will not create"+
                                " the link for #{children.inspect}", src, con
                                con.push_elements children
                                return
                        end
                        con.push_element md_im_link(children,url, title)
                when ?[ # link ref
                        ref_id = read_ref_id(src,con)
                        if ref_id
                                if ref_id.size == 0
                                        ref_id = sanitize_ref_id(children.to_s)
                                else
                                        ref_id = sanitize_ref_id(ref_id)
                                end 
                                con.push_element md_link(children, ref_id)
                        else 
                                maruku_error "Could not read ref_id", src, con
                                maruku_recover "I will not create the link for "+
                                        "#{children.inspect}", src, con
                                con.push_elements children
                                return
                        end
                else # empty [link]
                        id = sanitize_ref_id(children.to_s) #. downcase.gsub(' ','_')
                        con.push_element md_link(children, id)
                end
        end