def parseBareLinkDestination(self, reader: TextReader, document: Element) -> str:
    assert reader.consume(re.compile('[ \\n]*'))
    if (reader.remain == ''):
        return None
    parens = 0
    start = reader.position
    while reader.remain:
        c = reader.remain[0]
        if (c in (' ', '\n')):
            break
        elif (c == '('):
            parens += 1
        elif (c == ')'):
            parens -= 1
            if (parens < 0):
                break
        elif escaped_chars_pattern.match(reader.remain):
            reader.step()
        reader.step()
    end = reader.position
    return self.normalize_link_destination(reader[start:end])
def parseBareLinkDestination(self, reader: TextReader, document: Element) -> str:
    assert reader.consume(re.compile('[ \\n]*'))
    if (reader.remain == ):
        return None
    parens = 0
    start = reader.position
    while reader.remain:
        c = reader.remain[0]
        if (c in (' ', '\n')):
            break
        elif (c == '('):
            parens += 1
        elif (c == ')'):
            parens -= 1
            if (parens < 0):
                break
        elif escaped_chars_pattern.match(reader.remain):
            reader.step()
        reader.step()
    end = reader.position
    return self.normalize_link_destination(reader[start:end])