def visit_caption(self, node: Element) -> None:
    if (isinstance(node.parent, nodes.figure) or (isinstance(node.parent, nodes.container) and node.parent.get('literal_block'))):
        self.body.append('\n@caption{')
    else:
        logger.warning(__('caption not inside a figure.'), location=node)
def visit_caption(self, node: Element) -> None:
    if (isinstance(node.parent, nodes.figure) or (isinstance(node.parent, nodes.container) and node.parent.get('literal_block'))):
        self.body.append('\n@caption{')
    else:
        logger.warning(__('caption not inside a figure.'), location=node)