Commits

Anonymous committed 3c455af

[svn] Add ActionScript lexer, #247.

  • Participants
  • Parent commits 52439a5
  • Branches trunk

Comments (0)

Files changed (5)

   enhanced. You shouldn't get UnicodeErrors from it anymore if you
   don't give an encoding option.
 
+- Added 256-color terminal formatter.
+
+- Added ActionScript lexer.
+
+
 Version 0.8.1
 -------------
 (released Jun XX, 2007)

pygments/formatters/_mapping.py

     NullFormatter: ('Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'),
     RawTokenFormatter: ('Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'),
     RtfFormatter: ('RTF', ('rtf',), ('*.rtf',), 'Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft\xc2\xae Word\xc2\xae documents.'),
-    Terminal256Formatter: ('Terminal256', ('terminal256', 'console256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'),
+    Terminal256Formatter: ('Terminal256', ('terminal256', 'console256', '256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'),
     TerminalFormatter: ('Terminal', ('terminal', 'console'), (), 'Format tokens with ANSI color sequences, for output in a text console. Color sequences are terminated at newlines, so that paging the output works correctly.')
 }
 

pygments/formatters/html.py

                 num += 1
         else:
             for t, line in lines:
-                yield 1, '<span class="lineno">%*s</span> ' % (mw, (num%st and ' ' or num)) + line
+                yield 1, '<span class="lineno">%*s</span> ' % (
+                    mw, (num%st and ' ' or num)) + line
                 num += 1
 
     def _wrap_div(self, inner):

pygments/lexers/_mapping.py

 """
 
 LEXERS = {
+    'ActionScriptLexer': ('pygments.lexers.web', 'ActionScript', ('as', 'actionscript'), ('*.as',), ('application/x-actionscript', 'text/x-actionscript', 'text/actionscript')),
     'ApacheConfLexer': ('pygments.lexers.text', 'ApacheConf', ('apacheconf', 'aconf', 'apache'), ('.htaccess', 'apache.conf', 'apache2.conf'), ('text/x-apacheconf',)),
     'BBCodeLexer': ('pygments.lexers.text', 'BBCode', ('bbcode',), (), ('text/x-bbcode',)),
     'BashLexer': ('pygments.lexers.other', 'Bash', ('bash', 'sh'), ('*.sh',), ('application/x-sh', 'application/x-shellscript')),
     'HaskellLexer': ('pygments.lexers.functional', 'Haskell', ('haskell',), ('*.hs',), ()),
     'HtmlDjangoLexer': ('pygments.lexers.templates', 'HTML+Django/Jinja', ('html+django', 'html+jinja'), (), ('text/html+django', 'text/html+jinja')),
     'HtmlGenshiLexer': ('pygments.lexers.templates', 'HTML+Genshi', ('html+genshi', 'html+kid'), (), ('text/html+genshi',)),
-    'HtmlLexer': ('pygments.lexers.web', 'HTML', ('html',), ('*.html', '*.htm', '*.xhtml'), ('text/html', 'application/xhtml+xml')),
+    'HtmlLexer': ('pygments.lexers.web', 'HTML', ('html',), ('*.html', '*.htm', '*.xhtml', '*.xslt'), ('text/html', 'application/xhtml+xml')),
     'HtmlPhpLexer': ('pygments.lexers.templates', 'HTML+PHP', ('html+php',), ('*.phtml',), ('application/x-php', 'application/x-httpd-php', 'application/x-httpd-php3', 'application/x-httpd-php4', 'application/x-httpd-php5')),
     'HtmlSmartyLexer': ('pygments.lexers.templates', 'HTML+Smarty', ('html+smarty',), (), ('text/html+smarty',)),
     'IniLexer': ('pygments.lexers.text', 'INI', ('ini', 'cfg'), ('*.ini', '*.cfg'), ('text/x-ini',)),
     'VimLexer': ('pygments.lexers.text', 'VimL', ('vim',), ('*.vim', '.vimrc'), ('text/x-vim',)),
     'XmlDjangoLexer': ('pygments.lexers.templates', 'XML+Django/Jinja', ('xml+django', 'xml+jinja'), (), ('application/xml+django', 'application/xml+jinja')),
     'XmlErbLexer': ('pygments.lexers.templates', 'XML+Ruby', ('xml+erb', 'xml+ruby'), (), ('application/xml+ruby',)),
-    'XmlLexer': ('pygments.lexers.web', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml', 'application/xsl+xml', 'application/xslt+xml')),
+    'XmlLexer': ('pygments.lexers.web', 'XML', ('xml',), ('*.xml', '*.xsl', '*.rss', '*.xslt'), ('text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml', 'application/xsl+xml', 'application/xslt+xml')),
     'XmlPhpLexer': ('pygments.lexers.templates', 'XML+PHP', ('xml+php',), (), ('application/xml+php',)),
     'XmlSmartyLexer': ('pygments.lexers.templates', 'XML+Smarty', ('xml+smarty',), (), ('application/xml+smarty',))
 }

pygments/lexers/web.py

 
 
 __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer',
-           'PhpLexer']
+           'PhpLexer','ActionScriptLexer']
 
 
 class JavascriptLexer(RegexLexer):
     }
 
 
+class ActionScriptLexer(RegexLexer):
+    """
+    For ActionScript source code.
+
+    *New in Pygments 0.9.*
+    """
+
+    name = 'ActionScript'
+    aliases = ['as', 'actionscript']
+    filenames = ['*.as']
+    mimetypes = ['application/x-actionscript', 'text/x-actionscript',
+                 'text/actionscript']
+
+    flags = re.DOTALL
+    tokens = {
+        'root': [
+            (r'\s+', Text),
+            (r'//.*?\n', Comment),
+            (r'/\*.*?\*/', Comment),
+            (r'/(\\\\|\\/|[^/\n])*/[gim]*', String.Regex),
+            (r'[~\^\*!%&<>\|+=:;,/?\\-]+', Operator),
+            (r'[{}\[\]();.]+', Punctuation),
+            (r'(for|in|while|do|break|return|continue|if|else|throw|try|'
+             r'catch|var|with|new|typeof|arguments|instanceof|this)\b', Keyword),
+            (r'(class|public|private|static|import|extends|implements|interface|'
+             r'intrinsic|return|super|dynamic|function)\b', Keyword.Declaration),
+            (r'(true|false|null|NaN|Infinity|undefined|Void)\b', Keyword.Constant),
+            (r'(Accessibility|AsBroadcaster|Array|Boolean|Date|Error|Function|Math|'
+             r'Number|Object|String|MovieClip|BevelFilter|BitmapData|BitmapFilter|'
+             r'BlurFilter|Camera|Color|ColorMatrixFilter|ColorTransform|ContextMenu|'
+             r'ContextMenuItem|MovieClipLoader|NetConnection|NetStream|Point|PrintJob|'
+             r'ConvolutionFilter|DisplacmentMapFilter|DropShadowFilter|'
+             r'ExternalInterface|FileReference|FileReferenceList|GlowFilter|'
+             r'GradientBevelFilter|GradientGlowFilter|IME|Key|LoadVars|LocalConnection|'
+             r'Locale|Matrix|Microphone|Mouse|Rectangle|Selection|SharedObject|Sound|'
+             r'Stage|StyleSheet|System|TextField|TextFormat|TextRenderer|TextSnapshot|'
+             r'Transform|Video|XML|XMLNode|XMLSocket|XMLUI)\b',
+             Name.Builtin),
+            (r'(eval|isNaN|clearInterval|escape|fscommand|getTimer|getURL|getVersion|'
+             r'isFinite|parseFloat|parseInt|setInterval|trace|updateAfterEvent|escape|'
+             r'unescape)\b',Name.Function),
+            (r'[$a-zA-Z_][a-zA-Z0-9_]*', Name.Other),
+            (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
+            (r'0x[0-9a-f]+', Number.Hex),
+            (r'[0-9]+', Number.Integer),
+            (r'"(\\\\|\\"|[^"])*"', String.Double),
+            (r"'(\\\\|\\'|[^'])*'", String.Single),
+        ]
+    }
+
+
 class CssLexer(RegexLexer):
     """
     For CSS (Cascading Style Sheets).
 
     name = 'XML'
     aliases = ['xml']
-    filenames = ['*.xml', '*.xsl', '*.rss']
+    filenames = ['*.xml', '*.xsl', '*.rss', '*.xslt']
     mimetypes = ['text/xml', 'application/xml', 'image/svg+xml',
                  'application/rss+xml', 'application/atom+xml',
                  'application/xsl+xml', 'application/xslt+xml']