reader.py 文件源码

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

项目:pelican-frontmark 作者: noirbizarre 项目源码 文件源码
def code_block(self, node, entering):
        '''Output Pygments if required else use default html5 output'''
        if self.use_pygments:
            self.cr()
            info_words = node.info.split() if node.info else []

            if len(info_words) > 0 and len(info_words[0]) > 0:
                try:
                    lexer = get_lexer_by_name(info_words[0])
                except ValueError:
                    # no lexer found - use the text one instead of an exception
                    lexer = TextLexer()
            else:
                lexer = TextLexer()

            formatter = HtmlFormatter(**self.pygments_options)
            parsed = highlight(node.literal, lexer, formatter)
            self.lit(parsed)
            self.cr()
        else:
            super().code_block(node, entering)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号