transforms.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:chalktalk_docs 作者: loremIpsum1771 项目源码 文件源码
def apply(self):
        def has_child(node, cls):
            return any(isinstance(child, cls) for child in node)

        for node in self.document.traverse(nodes.Element):
            if isinstance(node, nodes.figure):
                if has_child(node, nodes.caption):
                    self.document.note_implicit_target(node)
            elif isinstance(node, nodes.image):
                if node.parent and has_child(node.parent, nodes.caption):
                    self.document.note_implicit_target(node.parent)
            elif isinstance(node, nodes.table):
                if has_child(node, nodes.title):
                    self.document.note_implicit_target(node)
            elif isinstance(node, nodes.literal_block):
                if node.parent and has_child(node.parent, nodes.caption):
                    self.document.note_implicit_target(node.parent)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号