#NEWLINE# def hilite( self ) : #NEWLINE# #INDENT# '\n        Pass code to the [Pygments](http://pygments.pocoo.org/) highliter with\n        optional line numbers. The output should then be styled with css to\n        your liking. No styles are applied by default - only styling hooks\n        (i.e.: <span class="k">).\n\n        returns : A string of html.\n\n        ' #NEWLINE# self . src = self . src . strip ( '\n' ) #NEWLINE# if ( self . lang is None ) : #NEWLINE# #INDENT# self . _parseHeader ( ) #NEWLINE# #UNINDENT# if ( pygments and self . use_pygments ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# lexer = get_lexer_by_name ( self . lang ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if self . guess_lang : #NEWLINE# #INDENT# lexer = guess_lexer ( self . src ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lexer = get_lexer_by_name ( 'text' ) #NEWLINE# #UNINDENT# #UNINDENT# except ValueError : #NEWLINE# #INDENT# lexer = get_lexer_by_name ( 'text' ) #NEWLINE# #UNINDENT# #UNINDENT# formatter = get_formatter_by_name ( 'html' , linenos = self . linenums , cssclass = self . css_class , style = self . style , noclasses = self . noclasses , hl_lines = self . hl_lines ) #NEWLINE# return highlight ( self . src , lexer , formatter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# txt = self . src . replace ( '&' , '&amp;' ) #NEWLINE# txt = txt . replace ( '<' , '&lt;' ) #NEWLINE# txt = txt . replace ( '>' , '&gt;' ) #NEWLINE# txt = txt . replace ( '"' , '&quot;' ) #NEWLINE# classes = [ ] #NEWLINE# if self . lang : #NEWLINE# #INDENT# classes . append ( ( 'language-%s' % self . lang ) ) #NEWLINE# #UNINDENT# if self . linenums : #NEWLINE# #INDENT# classes . append ( 'linenums' ) #NEWLINE# #UNINDENT# class_str = '' #NEWLINE# if classes : #NEWLINE# #INDENT# class_str = ( ' class="%s"' % ' ' . join ( classes ) ) #NEWLINE# #UNINDENT# return ( '<pre class="%s"><code%s>%s</code></pre>\n' % ( self . css_class , class_str , txt ) )