def get_link_destinations(chunk):
    'Find any target of a link in HTML code\n\n    Use regex to find tags with the id or name attribute, which makes them a possible target of a link\n    :param str chunk: text string\n    :return: destinations, destination_tags\n    :rtype: Tuple[list[str], list[str]]\n    '
    (destinations, destination_tags) = ([], [])
    pattern_tag = '[\\w _\\-:]'
    pattern_backslash = '[\\\\]'
    pattern = ((((((((('<' + pattern_tag) + '+ (id|name)=') + pattern_backslash) + '["\']') + '(') + pattern_tag) + '+)') + pattern_backslash) + '["\'][^>]*>')
    for m in re.finditer(pattern, chunk):
        match = m.group()
        tag = m.group(2)
        destinations.append(match)
        destination_tags.append(tag)
    return (destinations, destination_tags)
Find any target of a link in HTML code

Use regex to find tags with the id or name attribute, which makes them a possible target of a link
:param str chunk: text string
:return: destinations, destination_tags
:rtype: Tuple[list[str], list[str]]
def get_link_destinations(chunk):
    'Find any target of a link in HTML code\n\n    Use regex to find tags with the id or name attribute, which makes them a possible target of a link\n    :param str chunk: text string\n    :return: destinations, destination_tags\n    :rtype: Tuple[list[str], list[str]]\n    '
    (destinations, destination_tags) = ([], [])
    pattern_tag = '[\\w _\\-:]'
    pattern_backslash = '[\\\\]'
    pattern = ((((((((('<' + pattern_tag) + '+ (id|name)=') + pattern_backslash) + '["\']') + '(') + pattern_tag) + '+)') + pattern_backslash) + '["\'][^>]*>')
    for m in re.finditer(pattern, chunk):
        match = m.group()
        tag = m.group(2)
        destinations.append(match)
        destination_tags.append(tag)
    return (destinations, destination_tags)