codeblockext.py 文件源码

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

项目:SuperOcto 作者: mcecchi 项目源码 文件源码
def run(self):
        # get result from parent implementation
        code_block = CodeBlock.run(self)

        def find_and_wrap_literal_block(node):
            """
            Recursive method to turn all literal blocks located within a node into :class:`literal_block_ext`.
            """

            if isinstance(node, container):
                # container node => handle all children
                children = []
                for child in node.children:
                    children.append(find_and_wrap_literal_block(child))
                node.children = children
                return node

            elif isinstance(node, literal_block):
                # literal block => replace it
                return self._wrap_literal_block(node)

            else:
                # no idea what that is => leave it alone
                return node

        # replace all created literal_blocks with literal_block_ext instances
        return map(find_and_wrap_literal_block, code_block)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号