summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2007-06-13 15:17:00 +0200
committergbrandl <devnull@localhost>2007-06-13 15:17:00 +0200
commitb42aceccbbd16c264724a3c0ea2fc5166b29255c (patch)
treeb9c015d33f6c8d26984439bb76ace89576dd67d5
parent33f8bc0fbecb0edf2952cc82c50f09e44e17c14c (diff)
downloadpygments-b42aceccbbd16c264724a3c0ea2fc5166b29255c.tar.gz
[svn] Add ActionScript lexer, #247.
-rw-r--r--CHANGES5
-rwxr-xr-xpygments/formatters/_mapping.py2
-rw-r--r--pygments/formatters/html.py3
-rw-r--r--pygments/lexers/_mapping.py5
-rw-r--r--pygments/lexers/web.py55
5 files changed, 64 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index c280458f..3b424884 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,11 @@ Version 0.9
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)
diff --git a/pygments/formatters/_mapping.py b/pygments/formatters/_mapping.py
index 039641c2..1b13ded3 100755
--- a/pygments/formatters/_mapping.py
+++ b/pygments/formatters/_mapping.py
@@ -32,7 +32,7 @@ FORMATTERS = {
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.')
}
diff --git a/pygments/formatters/html.py b/pygments/formatters/html.py
index 73ac77a5..cdc1c1ce 100644
--- a/pygments/formatters/html.py
+++ b/pygments/formatters/html.py
@@ -475,7 +475,8 @@ class HtmlFormatter(Formatter):
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):
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index ea13acd0..649e9142 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -14,6 +14,7 @@
"""
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')),
@@ -42,7 +43,7 @@ LEXERS = {
'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',)),
@@ -93,7 +94,7 @@ LEXERS = {
'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',))
}
diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py
index acacefec..d1affc2b 100644
--- a/pygments/lexers/web.py
+++ b/pygments/lexers/web.py
@@ -24,7 +24,7 @@ from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, \
__all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer',
- 'PhpLexer']
+ 'PhpLexer','ActionScriptLexer']
class JavascriptLexer(RegexLexer):
@@ -66,6 +66,57 @@ 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).
@@ -408,7 +459,7 @@ class XmlLexer(RegexLexer):
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']