/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ define(["require", "exports"], function (require, exports) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.conf = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g, comments: { blockComment: ['{#', '#}'], }, brackets: [ ['{#', '#}'], ['{%', '%}'], ['{{', '}}'], ['(', ')'], ['[', ']'], // HTML [''], ['<', '>'], ], autoClosingPairs: [ { open: '{# ', close: ' #}' }, { open: '{% ', close: ' %}' }, { open: '{{ ', close: ' }}' }, { open: '[', close: ']' }, { open: '(', close: ')' }, { open: '"', close: '"' }, { open: '\'', close: '\'' }, ], surroundingPairs: [ { open: '"', close: '"' }, { open: '\'', close: '\'' }, // HTML { open: '<', close: '>' }, ], }; exports.language = { defaultToken: '', tokenPostfix: '', ignoreCase: true, keywords: [ // (opening) tags 'apply', 'autoescape', 'block', 'deprecated', 'do', 'embed', 'extends', 'flush', 'for', 'from', 'if', 'import', 'include', 'macro', 'sandbox', 'set', 'use', 'verbatim', 'with', // closing tags 'endapply', 'endautoescape', 'endblock', 'endembed', 'endfor', 'endif', 'endmacro', 'endsandbox', 'endset', 'endwith', // literals 'true', 'false', ], tokenizer: { root: [ // whitespace [/\s+/], // Twig Tag Delimiters [/{#/, 'comment.twig', '@commentState'], [/{%[-~]?/, 'delimiter.twig', '@blockState'], [/{{[-~]?/, 'delimiter.twig', '@variableState'], // HTML [/)/, ['delimiter.html', 'tag.html', '', 'delimiter.html']], [/(<)(script)/, ['delimiter.html', { token: 'tag.html', next: '@script' }]], [/(<)(style)/, ['delimiter.html', { token: 'tag.html', next: '@style' }]], [/(<)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], [/(<\/)((?:[\w\-]+:)?[\w\-]+)/, ['delimiter.html', { token: 'tag.html', next: '@otherTag' }]], [/|>=|<=/, 'operators.twig'], // operators - comparison (words) [/(starts with|ends with|matches)(\s+)/, ['operators.twig', '']], // operators - containment [/(in)(\s+)/, ['operators.twig', '']], // operators - test [/(is)(\s+)/, ['operators.twig', '']], // operators - misc [/\||~|:|\.{1,2}|\?{1,2}/, 'operators.twig'], // names [/[^\W\d][\w]*/, { cases: { '@keywords': 'keyword.twig', '@default': 'variable.twig' } }], // numbers [/\d+(\.\d+)?/, 'number.twig'], // punctuation [/\(|\)|\[|\]|{|}|,/, 'delimiter.twig'], // strings [/"([^#"\\]*(?:\\.[^#"\\]*)*)"|\'([^\'\\]*(?:\\.[^\'\\]*)*)\'/, 'string.twig'], // opening double quoted string [/"/, 'string.twig', '@stringState'], // misc syntactic constructs // These are not operators per se, but for the purposes of lexical analysis we // can treat them as such. // arrow functions [/=>/, 'operators.twig'], // assignment [/=/, 'operators.twig'], ], /** * HTML */ doctype: [ [/[^>]+/, 'metatag.content.html'], [/>/, 'metatag.html', '@pop'], ], comment: [ [/-->/, 'comment.html', '@pop'], [/[^-]+/, 'comment.content.html'], [/./, 'comment.content.html'] ], otherTag: [ [/\/?>/, 'delimiter.html', '@pop'], [/"([^"]*)"/, 'attribute.value.html'], [/'([^']*)'/, 'attribute.value.html'], [/[\w\-]+/, 'attribute.name.html'], [/=/, 'delimiter.html'], [/[ \t\r\n]+/], ], // -- BEGIN