directives.py 文件源码

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

项目:prestashop-sync 作者: dragoon 项目源码 文件源码
def pygments_directive(name, arguments, options, content, lineno,
                        content_offset, block_text, state, state_machine):
        try:
            lexer = get_lexer_by_name(arguments[0])
        except ValueError:
            # no lexer found - use the text one instead of an exception
            lexer = TextLexer()
        # take an arbitrary option if more than one is given
        formatter = options and VARIANTS[options.keys()[0]] or DEFAULT
        parsed = highlight(u'\n'.join(content), lexer, formatter)
        parsed = '<div class="codeblock">%s</div>' % parsed
        return [nodes.raw('', parsed, format='html')]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号