[d24f17c] | 1 | 'use strict'
|
---|
| 2 | var refractorMarkupTemplating = require('./markup-templating.js')
|
---|
| 3 | module.exports = tt2
|
---|
| 4 | tt2.displayName = 'tt2'
|
---|
| 5 | tt2.aliases = []
|
---|
| 6 | function tt2(Prism) {
|
---|
| 7 | Prism.register(refractorMarkupTemplating)
|
---|
| 8 | ;(function (Prism) {
|
---|
| 9 | Prism.languages.tt2 = Prism.languages.extend('clike', {
|
---|
| 10 | comment: /#.*|\[%#[\s\S]*?%\]/,
|
---|
| 11 | keyword:
|
---|
| 12 | /\b(?:BLOCK|CALL|CASE|CATCH|CLEAR|DEBUG|DEFAULT|ELSE|ELSIF|END|FILTER|FINAL|FOREACH|GET|IF|IN|INCLUDE|INSERT|LAST|MACRO|META|NEXT|PERL|PROCESS|RAWPERL|RETURN|SET|STOP|SWITCH|TAGS|THROW|TRY|UNLESS|USE|WHILE|WRAPPER)\b/,
|
---|
| 13 | punctuation: /[[\]{},()]/
|
---|
| 14 | })
|
---|
| 15 | Prism.languages.insertBefore('tt2', 'number', {
|
---|
| 16 | operator: /=[>=]?|!=?|<=?|>=?|&&|\|\|?|\b(?:and|not|or)\b/,
|
---|
| 17 | variable: {
|
---|
| 18 | pattern: /\b[a-z]\w*(?:\s*\.\s*(?:\d+|\$?[a-z]\w*))*\b/i
|
---|
| 19 | }
|
---|
| 20 | })
|
---|
| 21 | Prism.languages.insertBefore('tt2', 'keyword', {
|
---|
| 22 | delimiter: {
|
---|
| 23 | pattern: /^(?:\[%|%%)-?|-?%\]$/,
|
---|
| 24 | alias: 'punctuation'
|
---|
| 25 | }
|
---|
| 26 | })
|
---|
| 27 | Prism.languages.insertBefore('tt2', 'string', {
|
---|
| 28 | 'single-quoted-string': {
|
---|
| 29 | pattern: /'[^\\']*(?:\\[\s\S][^\\']*)*'/,
|
---|
| 30 | greedy: true,
|
---|
| 31 | alias: 'string'
|
---|
| 32 | },
|
---|
| 33 | 'double-quoted-string': {
|
---|
| 34 | pattern: /"[^\\"]*(?:\\[\s\S][^\\"]*)*"/,
|
---|
| 35 | greedy: true,
|
---|
| 36 | alias: 'string',
|
---|
| 37 | inside: {
|
---|
| 38 | variable: {
|
---|
| 39 | pattern: /\$(?:[a-z]\w*(?:\.(?:\d+|\$?[a-z]\w*))*)/i
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
| 43 | }) // The different types of TT2 strings "replace" the C-like standard string
|
---|
| 44 | delete Prism.languages.tt2.string
|
---|
| 45 | Prism.hooks.add('before-tokenize', function (env) {
|
---|
| 46 | var tt2Pattern = /\[%[\s\S]+?%\]/g
|
---|
| 47 | Prism.languages['markup-templating'].buildPlaceholders(
|
---|
| 48 | env,
|
---|
| 49 | 'tt2',
|
---|
| 50 | tt2Pattern
|
---|
| 51 | )
|
---|
| 52 | })
|
---|
| 53 | Prism.hooks.add('after-tokenize', function (env) {
|
---|
| 54 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'tt2')
|
---|
| 55 | })
|
---|
| 56 | })(Prism)
|
---|
| 57 | }
|
---|