diff options
author | EricFromCanada <eric3knibbe@gmail.com> | 2012-08-16 13:40:07 -0400 |
---|---|---|
committer | EricFromCanada <eric3knibbe@gmail.com> | 2012-08-16 13:40:07 -0400 |
commit | 98a0a953acd3f069975ee0b615b22daae2a16451 (patch) | |
tree | c875de30ec1400c6704ec0f6eddcf115d92b5b9f | |
parent | 21fb64c348a78a1b06946ee3e7bea0c8132e1595 (diff) | |
download | pygments-98a0a953acd3f069975ee0b615b22daae2a16451.tar.gz |
added requiredelimiters option & support for delimiter-free Lasso 9 files
-rw-r--r-- | pygments/lexers/_mapping.py | 2 | ||||
-rw-r--r-- | pygments/lexers/templates.py | 13 | ||||
-rw-r--r-- | pygments/lexers/web.py | 33 |
3 files changed, 35 insertions, 13 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 57440565..171d26ee 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -137,7 +137,7 @@ LEXERS = { 'LassoCssLexer': ('pygments.lexers.templates', 'CSS+Lasso', ('css+lasso',), (), ('text/css+lasso',)), 'LassoHtmlLexer': ('pygments.lexers.templates', 'HTML+Lasso', ('html+lasso',), (), ('text/html+lasso', 'application/x-httpd-lasso', 'application/x-httpd-lasso[89]')), 'LassoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Lasso', ('js+lasso', 'javascript+lasso'), (), ('application/x-javascript+lasso', 'text/x-javascript+lasso', 'text/javascript+lasso')), - 'LassoLexer': ('pygments.lexers.web', 'Lasso', ('lasso', 'lassoscript', 'ldml'), ('*.lasso', '*.lasso[89]', '*.las'), ('text/x-lasso',)), + 'LassoLexer': ('pygments.lexers.web', 'Lasso', ('lasso', 'lassoscript'), ('*.lasso', '*.lasso[89]'), ('text/x-lasso',)), 'LassoXmlLexer': ('pygments.lexers.templates', 'XML+Lasso', ('xml+lasso',), (), ('application/xml+lasso',)), 'LighttpdConfLexer': ('pygments.lexers.text', 'Lighttpd configuration file', ('lighty', 'lighttpd'), (), ('text/x-lighttpd-conf',)), 'LiterateHaskellLexer': ('pygments.lexers.functional', 'Literate Haskell', ('lhs', 'literate-haskell'), ('*.lhs',), ('text/x-literate-haskell',)), diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index 8d924473..1f9effef 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -12,7 +12,7 @@ import re from pygments.lexers.web import \ - PhpLexer, HtmlLexer, XmlLexer, JavascriptLexer, CssLexer + PhpLexer, HtmlLexer, XmlLexer, JavascriptLexer, CssLexer, LassoLexer from pygments.lexers.agile import PythonLexer, PerlLexer from pygments.lexers.compiled import JavaLexer from pygments.lexers.jvm import TeaLangLexer @@ -1642,13 +1642,14 @@ class LassoHtmlLexer(DelegatingLexer): name = 'HTML+Lasso' aliases = ['html+lasso'] - alias_filenames = ['*.html', '*.htm', '*.xhtml', - '*.lasso', '*.lasso[89]', '*.las', '*.incl', '*.inc'] + alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.lasso', '*.lasso[89]', + '*.incl', '*.inc', '*.las'] mimetypes = ['text/html+lasso', 'application/x-httpd-lasso', 'application/x-httpd-lasso[89]'] def __init__(self, **options): + options['requiredelimiters'] = True super(LassoHtmlLexer, self).__init__(HtmlLexer, LassoLexer, **options) def analyse_text(text): @@ -1668,10 +1669,12 @@ class LassoXmlLexer(DelegatingLexer): name = 'XML+Lasso' aliases = ['xml+lasso'] - alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]', '*.las'] + alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]', + '*.incl', '*.inc', '*.las'] mimetypes = ['application/xml+lasso'] def __init__(self, **options): + options['requiredelimiters'] = True super(LassoXmlLexer, self).__init__(XmlLexer, LassoLexer, **options) def analyse_text(text): @@ -1693,6 +1696,7 @@ class LassoCssLexer(DelegatingLexer): mimetypes = ['text/css+lasso'] def __init__(self, **options): + options['requiredelimiters'] = True super(LassoCssLexer, self).__init__(CssLexer, LassoLexer, **options) def analyse_text(text): @@ -1713,6 +1717,7 @@ class LassoJavascriptLexer(DelegatingLexer): 'text/javascript+lasso'] def __init__(self, **options): + options['requiredelimiters'] = True super(LassoJavascriptLexer, self).__init__(JavascriptLexer, LassoLexer, **options) diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 4b44acb3..fb44c48f 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -103,10 +103,10 @@ class JSONLexer(RegexLexer): # integer part of a number int_part = r'-?(0|[1-9]\d*)' - + # fractional part of a number frac_part = r'\.\d+' - + # exponential part of a number exp_part = r'[eE](\+|-)?\d+' @@ -2867,28 +2867,39 @@ class DartLexer(RegexLexer): class LassoLexer(RegexLexer): """ For `Lasso <http://www.lassosoft.com/>`_ source code, covering both - Lasso 9 syntax and LassoScript for Lasso 8.6 and earlier. For Lasso + Lasso 9 syntax and LassoScript for Lasso 8.6 and earlier. For Lasso embedded in HTML, use the `LassoHtmlLexer`. - + Additional options accepted: `builtinshighlighting` If given and ``True``, highlight builtin tags, types, traits, and methods (default: ``True``). + `requiredelimiters` + If given and ``True``, only highlight code between delimiters as Lasso + (default: ``False``). *New in Pygments 1.6.* """ name = 'Lasso' - aliases = ['lasso', 'lassoscript', 'ldml'] - filenames = ['*.lasso', '*.lasso[89]', '*.las'] - alias_filenames = ['*.incl', '*.inc'] + aliases = ['lasso', 'lassoscript'] + filenames = ['*.lasso', '*.lasso[89]'] + alias_filenames = ['*.incl', '*.inc', '*.las'] mimetypes = ['text/x-lasso'] flags = re.IGNORECASE | re.DOTALL | re.MULTILINE tokens = { 'root': [ (r'^#!.+lasso9\b', Comment.Preproc, 'lasso'), + (r'\s+', Other), + (r'\[noprocess\]', Comment.Preproc, ('delimiters', 'noprocess')), + (r'\[', Comment.Preproc, ('delimiters', 'squarebrackets')), + (r'<\?(LassoScript|lasso|=)', Comment.Preproc, ('delimiters', 'anglebrackets')), + (r'<', Other, 'delimiters'), + include('lasso'), + ], + 'delimiters': [ (r'\[noprocess\]', Comment.Preproc, 'noprocess'), (r'\[', Comment.Preproc, 'squarebrackets'), (r'<\?(LassoScript|lasso|=)', Comment.Preproc, 'anglebrackets'), @@ -3013,6 +3024,8 @@ class LassoLexer(RegexLexer): def __init__(self, **options): self.builtinshighlighting = get_bool_opt( options, 'builtinshighlighting', True) + self.requiredelimiters = get_bool_opt( + options, 'requiredelimiters', False) self._builtins = set() if self.builtinshighlighting: @@ -3022,7 +3035,11 @@ class LassoLexer(RegexLexer): RegexLexer.__init__(self, **options) def get_tokens_unprocessed(self, text): - for index, token, value in RegexLexer.get_tokens_unprocessed(self, text): + stack = ['root'] + if self.requiredelimiters: + stack.append('delimiters') + for index, token, value in \ + RegexLexer.get_tokens_unprocessed(self, text, stack): if token is Name.Other: if value.lower() in self._builtins: yield index, Name.Builtin, value |