diff options
author | Tim Hatch <tim@timhatch.com> | 2014-05-15 16:58:46 -0700 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-05-15 16:58:46 -0700 |
commit | 919938e38d438dbcba6ed64423fd8f7375a0f59e (patch) | |
tree | f99125be99b3f070f6dc166ff80a38004ed72377 | |
parent | 583ca505dcf138b05b99ee4bee9a545dd9130356 (diff) | |
parent | 3c8f0aed8af0456fc7834a681fe17c792c7dca1d (diff) | |
download | pygments-919938e38d438dbcba6ed64423fd8f7375a0f59e.tar.gz |
Merged in jaingaurav2/pygments-main (pull request #351)
Fix some lines to be within 90 characters
-rw-r--r-- | pygments/lexers/templates.py | 8 | ||||
-rw-r--r-- | pygments/lexers/text.py | 9 | ||||
-rw-r--r-- | pygments/lexers/web.py | 2 | ||||
-rw-r--r-- | tests/examplefiles/demo.cfm | 12 | ||||
-rw-r--r-- | tests/examplefiles/example.coffee (renamed from tests/examplefiles/function_arrows.coffee) | 16 | ||||
-rw-r--r-- | tests/examplefiles/vimrc | 21 | ||||
-rw-r--r-- | tests/test_cfm.py | 46 |
7 files changed, 113 insertions, 1 deletions
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index 46dac2a5..62d5da85 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -1536,7 +1536,7 @@ class ColdfusionMarkupLexer(RegexLexer): (r'<[^<>]*', Other), ], 'tags': [ - (r'(?s)<!---.*?--->', Comment.Multiline), + (r'<!---', Comment.Multiline, 'cfcomment'), (r'(?s)<!--.*?-->', Comment), (r'<cfoutput.*?>', Name.Builtin, 'cfoutput'), (r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)', @@ -1558,6 +1558,12 @@ class ColdfusionMarkupLexer(RegexLexer): (r'(?s)<[^<>]*', Other), (r'#', Other), ], + 'cfcomment': [ + (r'(?s)(.*?)(<!---)', + bygroups(Comment.Multiline, Comment.Multiline), '#push'), + (r'(?s)(.*?)(--->)', + bygroups(Comment.Multiline, Comment.Multiline), '#pop'), + ], } diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py index f23c6980..d855ec79 100644 --- a/pygments/lexers/text.py +++ b/pygments/lexers/text.py @@ -17,6 +17,7 @@ from pygments.lexer import Lexer, LexerContext, RegexLexer, ExtendedRegexLexer, from pygments.token import Punctuation, Text, Comment, Keyword, Name, String, \ Generic, Operator, Number, Whitespace, Literal from pygments.util import get_bool_opt, ClassNotFound +from pygments.lexers.agile import PythonLexer from pygments.lexers.other import BashLexer __all__ = ['IniLexer', 'PropertiesLexer', 'SourcesListLexer', 'BaseMakefileLexer', @@ -835,8 +836,16 @@ class VimLexer(RegexLexer): mimetypes = ['text/x-vim'] flags = re.MULTILINE + _python = r'py(?:t(?:h(?:o(?:n)?)?)?)?' + tokens = { 'root': [ + (r'^([ \t:]*)(' + _python + r')([ \t]*)(<<)([ \t]*)(.*)((?:\n|.)*)(\6)', + bygroups(using(this), Keyword, Text, Operator, Text, Text, + using(PythonLexer), Text)), + (r'^([ \t:]*)(' + _python + r')([ \t])(.*)', + bygroups(using(this), Keyword, Text, using(PythonLexer))), + (r'^\s*".*', Comment), (r'[ \t]+', Text), diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 2a80403a..550c6242 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -2499,6 +2499,7 @@ class CoffeeScriptLexer(RegexLexer): (r'"', String, '#pop'), (r'\\.|\'', String), # double-quoted string don't need ' escapes (r'#{', String.Interpol, "interpoling_string"), + (r'#', String), include('strings') ], 'sqs': [ @@ -2510,6 +2511,7 @@ class CoffeeScriptLexer(RegexLexer): (r'"""', String, '#pop'), (r'\\.|\'|"', String), # no need to escape quotes in triple-string (r'#{', String.Interpol, "interpoling_string"), + (r'#', String), include('strings'), ], 'tsqs': [ diff --git a/tests/examplefiles/demo.cfm b/tests/examplefiles/demo.cfm index d94a06a0..49690484 100644 --- a/tests/examplefiles/demo.cfm +++ b/tests/examplefiles/demo.cfm @@ -1,4 +1,11 @@ <!--- cfcomment ---> +<!--- nested <!--- cfcomment ---> ---> +<!--- multi-line +nested +<!--- +cfcomment +---> +---> <!-- html comment --> <html> <head> @@ -17,6 +24,9 @@ #IsDate("foo")#<br /> #DaysInMonth(RightNow)# </cfoutput> +<cfset x="x"> +<cfset y="y"> +<cfset z="z"> <cfoutput group="x"> #x# <cfoutput>#y#</cfoutput> @@ -29,6 +39,8 @@ <cfset greeting = "Hello #person#"> <cfset greeting = "Hello" & " world!"> +<cfset a = 5> +<cfset b = 10> <cfset c = a^b> <cfset c = a MOD b> <cfset c = a / b> diff --git a/tests/examplefiles/function_arrows.coffee b/tests/examplefiles/example.coffee index cd1ef1e8..2cbd1df3 100644 --- a/tests/examplefiles/function_arrows.coffee +++ b/tests/examplefiles/example.coffee @@ -1,3 +1,5 @@ +# function arrows + methodA:-> 'A' methodB:=> 'B' methodC:()=> 'C' @@ -9,3 +11,17 @@ methodF:(c,d)-> 'F' (-> 'I') (=> 'J') + +# strings + +"#{wow}" +"w#{wow}w" +"#wow" +"wow#" +"w#ow" + +'#{wow}' +'w#{wow}w' +'#wow' +'wow#' +'w#ow' diff --git a/tests/examplefiles/vimrc b/tests/examplefiles/vimrc new file mode 100644 index 00000000..d2f9cd1b --- /dev/null +++ b/tests/examplefiles/vimrc @@ -0,0 +1,21 @@ +" A comment + +:py print "py" +::pyt print 'pyt' + pyth print '''pyth''' + : pytho print "pytho" +python print """python""" + + : : python<<E OF +print """my script""" + +def MyFunc(str): + """ My Function """ + print str +E OF + +let py = 42 +echo py + +let foo = 42 +echo foo diff --git a/tests/test_cfm.py b/tests/test_cfm.py new file mode 100644 index 00000000..2ff25bd6 --- /dev/null +++ b/tests/test_cfm.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +""" + Basic ColdfusionHtmlLexer Test + ~~~~~~~~~~~~~~~~~ + + :copyright: Copyright 2014 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +import unittest +import os + +from pygments.token import Token +from pygments.lexers import ColdfusionHtmlLexer + + +class ColdfusionHtmlLexerTest(unittest.TestCase): + + def setUp(self): + self.lexer = ColdfusionHtmlLexer() + + def testBasicComment(self): + fragment = u'<!--- cfcomment --->' + expected = [ + (Token.Text, u''), + (Token.Comment.Multiline, u'<!---'), + (Token.Comment.Multiline, u' cfcomment '), + (Token.Comment.Multiline, u'--->'), + (Token.Text, u'\n'), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) + + def testNestedComment(self): + fragment = u'<!--- nested <!--- cfcomment ---> --->' + expected = [ + (Token.Text, u''), + (Token.Comment.Multiline, u'<!---'), + (Token.Comment.Multiline, u' nested '), + (Token.Comment.Multiline, u'<!---'), + (Token.Comment.Multiline, u' cfcomment '), + (Token.Comment.Multiline, u'--->'), + (Token.Comment.Multiline, u' '), + (Token.Comment.Multiline, u'--->'), + (Token.Text, u'\n'), + ] + self.assertEqual(expected, list(self.lexer.get_tokens(fragment))) |