~ubuntu-branches/ubuntu/precise/moin/precise-updates

« back to all changes in this revision

Viewing changes to MoinMoin/support/pygments/lexers/templates.py

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2010-08-11 12:35:34 UTC
  • mfrom: (0.1.19 sid)
  • Revision ID: james.westby@ubuntu.com-20100811123534-q8zu7qrwqul6cvec
Tags: 1.9.3-1ubuntu1
* Merge from Debian unstable (LP: #586518). Based on work by Stefan Ebner.
  Remaining changes:
 - Remove python-xml from Suggests field, the package isn't anymore in
   sys.path.
 - Demote fckeditor from Recommends to Suggests; the code was previously
   embedded in moin, but it was also disabled, so there's no reason 
   for us to pull this in by default currently. Note: fckeditor has a
   number of security problems and so this change probably needs to be
   carried indefinitely.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
"""
11
11
 
12
12
import re
13
 
try:
14
 
    set
15
 
except NameError:
16
 
    from sets import Set as set
17
13
 
18
14
from pygments.lexers.web import \
19
15
     PhpLexer, HtmlLexer, XmlLexer, JavascriptLexer, CssLexer
38
34
           'MakoHtmlLexer', 'MakoXmlLexer', 'MakoJavascriptLexer',
39
35
           'MakoCssLexer', 'JspLexer', 'CheetahLexer', 'CheetahHtmlLexer',
40
36
           'CheetahXmlLexer', 'CheetahJavascriptLexer',
41
 
           'EvoqueLexer', 'EvoqueHtmlLexer', 'EvoqueXmlLexer']
 
37
           'EvoqueLexer', 'EvoqueHtmlLexer', 'EvoqueXmlLexer',
 
38
           'ColdfusionLexer', 'ColdfusionHtmlLexer']
42
39
 
43
40
 
44
41
class ErbLexer(Lexer):
246
243
            (r'\.[a-zA-Z0-9_]+', Name.Variable),
247
244
            (r':?"(\\\\|\\"|[^"])*"', String.Double),
248
245
            (r":?'(\\\\|\\'|[^'])*'", String.Single),
249
 
            (r'([{}()\[\]+\-*/,:]|[><=]=?)', Operator),
 
246
            (r'([{}()\[\]+\-*/,:~]|[><=]=?)', Operator),
250
247
            (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
251
248
             r"0[xX][0-9a-fA-F]+[Ll]?", Number),
252
249
        ],
1294
1291
    def __init__(self, **options):
1295
1292
        super(EvoqueXmlLexer, self).__init__(XmlLexer, EvoqueLexer,
1296
1293
                                             **options)
 
1294
 
 
1295
class ColdfusionLexer(RegexLexer):
 
1296
    """
 
1297
    Coldfusion statements
 
1298
    """
 
1299
    name = 'cfstatement'
 
1300
    aliases = ['cfs']
 
1301
    filenames = []
 
1302
    mimetypes = []
 
1303
    flags = re.IGNORECASE | re.MULTILINE
 
1304
 
 
1305
    tokens = {
 
1306
        'root': [
 
1307
            (r'//.*', Comment),
 
1308
            (r'\+\+|--', Operator),
 
1309
            (r'[-+*/^&=!]', Operator),
 
1310
            (r'<=|>=|<|>', Operator),
 
1311
            (r'mod\b', Operator),
 
1312
            (r'(eq|lt|gt|lte|gte|not|is|and|or)\b', Operator),
 
1313
            (r'\|\||&&', Operator),
 
1314
            (r'"', String.Double, 'string'),
 
1315
            # There is a special rule for allowing html in single quoted
 
1316
            # strings, evidently.
 
1317
            (r"'.*?'", String.Single),
 
1318
            (r'\d+', Number),
 
1319
            (r'(if|else|len|var|case|default|break|switch)\b', Keyword),
 
1320
            (r'([A-Za-z_$][A-Za-z0-9_.]*)\s*(\()', bygroups(Name.Function, Punctuation)),
 
1321
            (r'[A-Za-z_$][A-Za-z0-9_.]*', Name.Variable),
 
1322
            (r'[()\[\]{};:,.\\]', Punctuation),
 
1323
            (r'\s+', Text),
 
1324
        ],
 
1325
        'string': [
 
1326
            (r'""', String.Double),
 
1327
            (r'#.+?#', String.Interp),
 
1328
            (r'[^"#]+', String.Double),
 
1329
            (r'#', String.Double),
 
1330
            (r'"', String.Double, '#pop'),
 
1331
        ],
 
1332
    }
 
1333
 
 
1334
class ColdfusionMarkupLexer(RegexLexer):
 
1335
    """
 
1336
    Coldfusion markup only
 
1337
    """
 
1338
    name = 'Coldfusion'
 
1339
    aliases = ['cf']
 
1340
    filenames = []
 
1341
    mimetypes = []
 
1342
 
 
1343
    tokens = {
 
1344
        'root': [
 
1345
            (r'[^<]+', Other),
 
1346
            include('tags'),
 
1347
            (r'<[^<>]*', Other),
 
1348
        ],
 
1349
        'tags': [
 
1350
            (r'(?s)<!---.*?--->', Comment.Multiline),
 
1351
            (r'(?s)<!--.*?-->', Comment),
 
1352
            (r'<cfoutput.*?>', Name.Builtin, 'cfoutput'),
 
1353
            (r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)',
 
1354
             bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
 
1355
            # negative lookbehind is for strings with embedded >
 
1356
            (r'(?s)(</?cf(?:component|include|if|else|elseif|loop|return|'
 
1357
             r'dbinfo|dump|abort|location|invoke|throw|file|savecontent|'
 
1358
             r'mailpart|mail|header|content|zip|image|lock|argument|try|'
 
1359
             r'catch|break|directory|http|set|function|param)\b)(.*?)((?<!\\)>)',
 
1360
             bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
 
1361
        ],
 
1362
        'cfoutput': [
 
1363
            (r'[^#<]+', Other),
 
1364
            (r'(#)(.*?)(#)', bygroups(Punctuation, using(ColdfusionLexer),
 
1365
                                      Punctuation)),
 
1366
            #(r'<cfoutput.*?>', Name.Builtin, '#push'),
 
1367
            (r'</cfoutput.*?>', Name.Builtin, '#pop'),
 
1368
            include('tags'),
 
1369
            (r'(?s)<[^<>]*', Other),
 
1370
            (r'#', Other),
 
1371
        ],
 
1372
    }
 
1373
 
 
1374
 
 
1375
class ColdfusionHtmlLexer(DelegatingLexer):
 
1376
    """
 
1377
    Coldfusion markup in html
 
1378
    """
 
1379
    name = 'Coldufsion HTML'
 
1380
    aliases = ['cfm']
 
1381
    filenames = ['*.cfm', '*.cfml', '*.cfc']
 
1382
    mimetypes = ['application/x-coldfusion']
 
1383
 
 
1384
    def __init__(self, **options):
 
1385
        super(ColdfusionHtmlLexer, self).__init__(HtmlLexer, ColdfusionMarkupLexer,
 
1386
                                                  **options)
 
1387