import re


def get_link_destinations(chunk):
    """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]]
    """
    destinations, destination_tags = [], []
    # html links. label{} has already been converted
    pattern_tag = r'[\w _\-:]'
    pattern_backslash = '[\\\]'
    pattern = r'<' + 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