def _expect_inline_link(text, start):
    """(link_dest "link_title")"""
    if start >= len(text) or text[start] != '(':
        return None
    i = start + 1
    m = patterns.whitespace.match(text, i)
    if m:
        i = m.end()
    m = patterns.link_dest_1.match(text, i)
    if m:
        link_dest = m.start(), m.end(), m.group()
        i = m.end()
    else:
        open_num = 0
        escaped = False
        prev = i
        while i < len(text):
            c = text[i]
            if escaped:
                escaped = False
            elif c == '\\':
                escaped = True
            elif c == '(':
                open_num += 1
            elif c in string.whitespace:
                break
            elif c == ')':
                if open_num > 0:
                    open_num -= 1
                else:
                    break
            i += 1
        if open_num != 0:
            return None
        link_dest = prev, i, text[prev:i]
    link_title = i, i, None
    tail_re = re.compile(r'(?:\s+%s)?\s*\)' % patterns.link_title, flags=re.UNICODE)
    m = tail_re.match(text, i)
    if not m:
        return None
    if m.group('title'):
        link_title = m.start('title'), m.end('title'), m.group('title')
    return (link_dest, link_title, m.end())
def _expect_inline_link ( text , start ) : if start >= len ( text ) or text [ start ] != '(' : return None i = start + 1 m = patterns . whitespace . match ( text , i ) if m : i = m . end ( ) m = patterns . link_dest_1 . match ( text , i ) if m : link_dest = m . start ( ) , m . end ( ) , m . group ( ) i = m . end ( ) else : open_num = 0 escaped = False prev = i while i < len ( text ) : c = text [ i ] if escaped : escaped = False elif c == '\\' : escaped = True elif c == '(' : open_num += 1 elif c in string . whitespace : break elif c == ')' : if open_num > 0 : open_num -= 1 else : break i += 1 if open_num != 0 : return None link_dest = prev , i , text [ prev : i ] link_title = i , i , None tail_re = re . compile ( r'(?:\s+%s)?\s*\)' % patterns . link_title , flags = re . UNICODE ) m = tail_re . match ( text , i ) if not m : return None if m . group ( 'title' ) : link_title = m . start ( 'title' ) , m . end ( 'title' ) , m . group ( 'title' ) return ( link_dest , link_title , m . end ( ) )
(link_dest "link_title")