main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | Prism.languages.twig = {
|
---|
| 2 | 'comment': /^\{#[\s\S]*?#\}$/,
|
---|
| 3 |
|
---|
| 4 | 'tag-name': {
|
---|
| 5 | pattern: /(^\{%-?\s*)\w+/,
|
---|
| 6 | lookbehind: true,
|
---|
| 7 | alias: 'keyword'
|
---|
| 8 | },
|
---|
| 9 | 'delimiter': {
|
---|
| 10 | pattern: /^\{[{%]-?|-?[%}]\}$/,
|
---|
| 11 | alias: 'punctuation'
|
---|
| 12 | },
|
---|
| 13 |
|
---|
| 14 | 'string': {
|
---|
| 15 | pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
---|
| 16 | inside: {
|
---|
| 17 | 'punctuation': /^['"]|['"]$/
|
---|
| 18 | }
|
---|
| 19 | },
|
---|
| 20 | 'keyword': /\b(?:even|if|odd)\b/,
|
---|
| 21 | 'boolean': /\b(?:false|null|true)\b/,
|
---|
| 22 | 'number': /\b0x[\dA-Fa-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][-+]?\d+)?/,
|
---|
| 23 | 'operator': [
|
---|
| 24 | {
|
---|
| 25 | pattern: /(\s)(?:and|b-and|b-or|b-xor|ends with|in|is|matches|not|or|same as|starts with)(?=\s)/,
|
---|
| 26 | lookbehind: true
|
---|
| 27 | },
|
---|
| 28 | /[=<>]=?|!=|\*\*?|\/\/?|\?:?|[-+~%|]/
|
---|
| 29 | ],
|
---|
| 30 | 'punctuation': /[()\[\]{}:.,]/
|
---|
| 31 | };
|
---|
| 32 |
|
---|
| 33 | Prism.hooks.add('before-tokenize', function (env) {
|
---|
| 34 | if (env.language !== 'twig') {
|
---|
| 35 | return;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | var pattern = /\{(?:#[\s\S]*?#|%[\s\S]*?%|\{[\s\S]*?\})\}/g;
|
---|
| 39 | Prism.languages['markup-templating'].buildPlaceholders(env, 'twig', pattern);
|
---|
| 40 | });
|
---|
| 41 |
|
---|
| 42 | Prism.hooks.add('after-tokenize', function (env) {
|
---|
| 43 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'twig');
|
---|
| 44 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.