<s> """<STR_LIT>""" <EOL> INLINESTYLES = False <EOL> from pygments . formatters import HtmlFormatter <EOL> DEFAULT = HtmlFormatter ( noclasses = INLINESTYLES ) <EOL> VARIANTS = { <EOL> } <EOL> from docutils import nodes <EOL> from docutils . parsers . rst import directives , Directive <EOL> from pygments import highlight <EOL> from pygments . lexers import get_lexer_by_name , TextLexer <EOL> class Pygments ( Directive ) : <EOL> """<STR_LIT>""" <EOL> required_arguments = <NUM_LIT:1> <EOL> optional_arguments = <NUM_LIT:0> <EOL> final_argument_whitespace = True <EOL> option_spec = dict ( [ ( key , directives . flag ) for key in VARIANTS ] ) <EOL> has_content = True <EOL> def run ( self ) : <EOL> self . assert_has_content ( ) <EOL> try : <EOL> lexer = get_lexer_by_name ( self . arguments [ <NUM_LIT:0> ] ) <EOL> except ValueError : <EOL> lexer = TextLexer ( ) <EOL> formatter = self . options and VARIANTS [ self . options . keys ( ) [ <NUM_LIT:0> ] ] or DEFAULT <EOL> parsed = highlight ( u'<STR_LIT:\n>' . join ( self . content ) , lexer , formatter ) <EOL> return [ nodes . raw ( '<STR_LIT>' , parsed , format = '<STR_LIT:html>' ) ] <EOL> directives . register_directive ( '<STR_LIT>' , Pygments ) </s>
