<s> from pygments . lexers . web import HtmlLexer , XmlLexer , JavascriptLexer , CssLexer <EOL> from pygments . lexers . agile import PythonLexer , Python3Lexer <EOL> from pygments . lexer import DelegatingLexer , RegexLexer , bygroups , include , using <EOL> from pygments . token import Text , Comment , Operator , Keyword , Name , String , Other <EOL> from pygments . formatters . html import HtmlFormatter <EOL> from pygments import highlight <EOL> from mako import compat <EOL> class MakoLexer ( RegexLexer ) : <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' ] <EOL> filenames = [ '<STR_LIT>' ] <EOL> tokens = { <EOL> '<STR_LIT:root>' : [ <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Text , Comment . Preproc , Keyword , Other ) ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Text , Comment . Preproc , using ( PythonLexer ) , Other ) ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Text , Comment . Preproc , Other ) ) , <EOL> ( r'''<STR_LIT>''' , Comment . Preproc ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Comment . Preproc , Name . Builtin ) , '<STR_LIT>' ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Comment . Preproc , Name . Builtin , Comment . Preproc ) ) , <EOL> ( r'<STR_LIT>' , Comment . Preproc , '<STR_LIT>' ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Comment . Preproc , using ( PythonLexer ) , Comment . Preproc ) ) , <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Comment . Preproc , using ( PythonLexer ) , Comment . Preproc ) ) , <EOL> ( r'''<STR_LIT>''' , bygroups ( Other , Operator ) ) , <EOL> ( r'<STR_LIT>' , Text ) , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> ( r'<STR_LIT>' , Comment . Preproc ) , <EOL> ( r'<STR_LIT>' , Name . Builtin ) , <EOL> include ( '<STR_LIT>' ) , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> ( r'<STR_LIT>' , <EOL> bygroups ( Name . Attribute , String ) ) , <EOL> ( r'<STR_LIT>' , Comment . Preproc , '<STR_LIT:#pop>' ) , <EOL> ( r'<STR_LIT>' , Text ) , <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> ( '<STR_LIT>' , String , '<STR_LIT:#pop>' ) , <EOL> ( "<STR_LIT>" , String , '<STR_LIT:#pop>' ) , <EOL> ( r'<STR_LIT>' , String , '<STR_LIT:#pop>' ) , <EOL> ] , <EOL> } <EOL> class MakoHtmlLexer ( DelegatingLexer ) : <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' ] <EOL> def __init__ ( self , ** options ) : <EOL> super ( MakoHtmlLexer , self ) . __init__ ( HtmlLexer , MakoLexer , <EOL> ** options ) <EOL> class MakoXmlLexer ( DelegatingLexer ) : <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' ] <EOL> def __init__ ( self , ** options ) : <EOL> super ( MakoXmlLexer , self ) . __init__ ( XmlLexer , MakoLexer , <EOL> ** options ) <EOL> class MakoJavascriptLexer ( DelegatingLexer ) : <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , ** options ) : <EOL> super ( MakoJavascriptLexer , self ) . __init__ ( JavascriptLexer , <EOL> MakoLexer , ** options ) <EOL> class MakoCssLexer ( DelegatingLexer ) : <EOL> name = '<STR_LIT>' <EOL> aliases = [ '<STR_LIT>' ] <EOL> def __init__ ( self , ** options ) : <EOL> super ( MakoCssLexer , self ) . __init__ ( CssLexer , MakoLexer , <EOL> ** options ) <EOL> pygments_html_formatter = HtmlFormatter ( cssclass = '<STR_LIT>' , <EOL> linenos = True ) <EOL> def syntax_highlight ( filename = '<STR_LIT>' , language = None ) : <EOL> mako_lexer = MakoLexer ( ) <EOL> if compat . py3k : <EOL> python_lexer = Python3Lexer ( ) <EOL> else : <EOL> python_lexer = PythonLexer ( ) <EOL> if filename . startswith ( '<STR_LIT>' ) or language == '<STR_LIT>' : <EOL> return lambda string : highlight ( string , mako_lexer , <EOL> pygments_html_formatter ) <EOL> return lambda string : highlight ( string , python_lexer , <EOL> pygments_html_formatter ) </s>
