]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/leaf.js
Initial commit.
[flow-web.git] / static / highlight / languages / leaf.js
1 /*! `leaf` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Leaf
8 Description: A Swift-based templating language created for the Vapor project.
9 Website: https://docs.vapor.codes/leaf/overview
10 Category: template
11 */
12
13 function leaf(hljs) {
14 const IDENT = /([A-Za-z_][A-Za-z_0-9]*)?/;
15 const LITERALS = [
16 'true',
17 'false',
18 'in'
19 ];
20 const PARAMS = {
21 scope: 'params',
22 begin: /\(/,
23 end: /\)(?=\:?)/,
24 endsParent: true,
25 relevance: 7,
26 contains: [
27 {
28 scope: 'string',
29 begin: '"',
30 end: '"'
31 },
32 {
33 scope: 'keyword',
34 match: LITERALS.join("|"),
35 },
36 {
37 scope: 'variable',
38 match: /[A-Za-z_][A-Za-z_0-9]*/
39 },
40 {
41 scope: 'operator',
42 match: /\+|\-|\*|\/|\%|\=\=|\=|\!|\>|\<|\&\&|\|\|/
43 }
44 ]
45 };
46 const INSIDE_DISPATCH = {
47 match: [
48 IDENT,
49 /(?=\()/,
50 ],
51 scope: {
52 1: "keyword"
53 },
54 contains: [ PARAMS ]
55 };
56 PARAMS.contains.unshift(INSIDE_DISPATCH);
57 return {
58 name: 'Leaf',
59 contains: [
60 // #ident():
61 {
62 match: [
63 /#+/,
64 IDENT,
65 /(?=\()/,
66 ],
67 scope: {
68 1: "punctuation",
69 2: "keyword"
70 },
71 // will start up after the ending `)` match from line ~44
72 // just to grab the trailing `:` if we can match it
73 starts: {
74 contains: [
75 {
76 match: /\:/,
77 scope: "punctuation"
78 }
79 ]
80 },
81 contains: [
82 PARAMS
83 ],
84 },
85 // #ident or #ident:
86 {
87 match: [
88 /#+/,
89 IDENT,
90 /:?/,
91 ],
92 scope: {
93 1: "punctuation",
94 2: "keyword",
95 3: "punctuation"
96 }
97 },
98 ]
99 };
100 }
101
102 return leaf;
103
104 })();
105
106 hljs.registerLanguage('leaf', hljsGrammar);
107 })();