__init__.py 文件源码

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

项目:chalktalk_docs 作者: loremIpsum1771 项目源码 文件源码
def get_figtype(node):
    """Return figtype for given node."""
    def has_child(node, cls):
        return any(isinstance(child, cls) for child in node)

    from docutils import nodes
    if isinstance(node, nodes.figure):
        return 'figure'
    elif isinstance(node, nodes.image) and isinstance(node.parent, nodes.figure):
        # bare image node is not supported because it doesn't have caption and
        # no-caption-target isn't a numbered figure.
        return 'figure'
    elif isinstance(node, nodes.table):
        return 'table'
    elif isinstance(node, nodes.container):
        if has_child(node, nodes.literal_block):
            return 'code-block'

    return None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号