def visit_target(self, node: Element) -> None:
    parindex = node.parent.index(node)
    try:
        try:
            next = node.parent[(parindex + 1)]
        except IndexError:
            next = node.parent.parent[node.parent.parent.index(node.parent)]
        if isinstance(next, nodes.section):
            if node.get('refid'):
                self.next_section_ids.add(node['refid'])
            self.next_section_ids.update(node['ids'])
            return
    except (IndexError, AttributeError):
        pass
    if ('refuri' in node):
        return
    if node.get('refid'):
        self.add_anchor(node['refid'], node)
    for id in node['ids']:
        self.add_anchor(id, node)
def visit_target(self, node: Element) -> None:
    parindex = node.parent.index(node)
    try:
        try:
            next = node.parent[(parindex + 1)]
        except IndexError:
            next = node.parent.parent[node.parent.parent.index(node.parent)]
        if isinstance(next, nodes.section):
            if node.get('refid'):
                self.next_section_ids.add(node['refid'])
            self.next_section_ids.update(node['ids'])
            return
    except (IndexError, AttributeError):
        pass
    if ('refuri' in node):
        return
    if node.get('refid'):
        self.add_anchor(node['refid'], node)
    for id in node['ids']:
        self.add_anchor(id, node)