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