<s> try : <EOL> from pygments . formatters import HtmlFormatter <EOL> from pygments . lexers import get_lexer_by_name <EOL> from pygments import highlight as highlighter <EOL> except ImportError : <EOL> highlighter = None <EOL> from native_tags . decorators import function , block <EOL> def highlight_style ( cssclass = '<STR_LIT>' , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if highlighter is None : <EOL> return '<STR_LIT>' <EOL> return HtmlFormatter ( ** kwargs ) . get_style_defs ( '<STR_LIT>' % cssclass ) <EOL> highlight_style = function ( highlight_style ) <EOL> def highlight ( code , lexer , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if highlighter is None : <EOL> return '<STR_LIT>' % code <EOL> return highlighter ( code or '<STR_LIT>' , get_lexer_by_name ( lexer ) , HtmlFormatter ( ** kwargs ) ) <EOL> highlight = function ( highlight , is_safe = True ) <EOL> def highlight_block ( context , nodelist , lexer , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if highlighter is None : <EOL> return '<STR_LIT>' % str ( nodelist . render ( context ) or '<STR_LIT>' ) <EOL> return highlighter ( nodelist . render ( context ) or '<STR_LIT>' , get_lexer_by_name ( lexer ) , HtmlFormatter ( ** kwargs ) ) <EOL> highlight_block = block ( highlight_block , is_safe = True ) </s>
