Python mistune 模块,escape() 实例源码
我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用mistune.escape()。
@H_404_20@
def block_code(text, lang, inlinestyles=False, linenos=False): if not lang: text = text.strip() return u'<pre><code>%s</code></pre>\n' % mistune.escape(text) try: lexer = get_lexer_by_name(lang, stripall=True) formatter = html.HtmlFormatter( noclasses=inlinestyles, linenos=linenos ) code = highlight(text, lexer, formatter) if linenos: return '<div class="highlight-wrapper">%s</div>\n' % code return code except BaseException: return '<pre class="%s"><code>%s</code></pre>\n' % ( lang, mistune.escape(text) )