1 | (function(Prism) {
|
2 |
|
3 | Prism.languages.handlebars = {
|
4 | 'comment': /\{\{![\s\S]*?\}\}/,
|
5 | 'delimiter': {
|
6 | pattern: /^\{\{\{?|\}\}\}?$/i,
|
7 | alias: 'punctuation'
|
8 | },
|
9 | 'string': /(["'])(?:\\.|(?!\1)[^\\\r\n])*\1/,
|
10 | 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
|
11 | 'boolean': /\b(?:true|false)\b/,
|
12 | 'block': {
|
13 | pattern: /^(\s*~?\s*)[#\/]\S+?(?=\s*~?\s*$|\s)/i,
|
14 | lookbehind: true,
|
15 | alias: 'keyword'
|
16 | },
|
17 | 'brackets': {
|
18 | pattern: /\[[^\]]+\]/,
|
19 | inside: {
|
20 | punctuation: /\[|\]/,
|
21 | variable: /[\s\S]+/
|
22 | }
|
23 | },
|
24 | 'punctuation': /[!"#%&':()*+,.\/;<=>@\[\\\]^`{|}~]/,
|
25 | 'variable': /[^!"#%&'()*+,\/;<=>@\[\\\]^`{|}~\s]+/
|
26 | };
|
27 |
|
28 | Prism.hooks.add('before-tokenize', function(env) {
|
29 | var handlebarsPattern = /\{\{\{[\s\S]+?\}\}\}|\{\{[\s\S]+?\}\}/g;
|
30 | Prism.languages['markup-templating'].buildPlaceholders(env, 'handlebars', handlebarsPattern);
|
31 | });
|
32 |
|
33 | Prism.hooks.add('after-tokenize', function(env) {
|
34 | Prism.languages['markup-templating'].tokenizePlaceholders(env, 'handlebars');
|
35 | });
|
36 |
|
37 | }(Prism));
|