1 | (function (Prism) {
|
2 |
|
3 | var comment = {
|
4 | pattern: /(^[ \t]*| {2}|\t)#.*/m,
|
5 | lookbehind: true,
|
6 | greedy: true
|
7 | };
|
8 |
|
9 | var variable = {
|
10 | pattern: /((?:^|[^\\])(?:\\{2})*)[$@&%]\{(?:[^{}\r\n]|\{[^{}\r\n]*\})*\}/,
|
11 | lookbehind: true,
|
12 | inside: {
|
13 | 'punctuation': /^[$@&%]\{|\}$/
|
14 | }
|
15 | };
|
16 |
|
17 | function createSection(name, inside) {
|
18 | var extendecInside = {};
|
19 |
|
20 | extendecInside['section-header'] = {
|
21 | pattern: /^ ?\*{3}.+?\*{3}/,
|
22 | alias: 'keyword'
|
23 | };
|
24 |
|
25 |
|
26 | for (var token in inside) {
|
27 | extendecInside[token] = inside[token];
|
28 | }
|
29 |
|
30 | extendecInside['tag'] = {
|
31 | pattern: /([\r\n](?: {2}|\t)[ \t]*)\[[-\w]+\]/,
|
32 | lookbehind: true,
|
33 | inside: {
|
34 | 'punctuation': /\[|\]/
|
35 | }
|
36 | };
|
37 | extendecInside['variable'] = variable;
|
38 | extendecInside['comment'] = comment;
|
39 |
|
40 | return {
|
41 | pattern: RegExp(/^ ?\*{3}[ \t]*<name>[ \t]*\*{3}(?:.|[\r\n](?!\*{3}))*/.source.replace(/<name>/g, function () { return name; }), 'im'),
|
42 | alias: 'section',
|
43 | inside: extendecInside
|
44 | };
|
45 | }
|
46 |
|
47 |
|
48 | var docTag = {
|
49 | pattern: /(\[Documentation\](?: {2}|\t)[ \t]*)(?![ \t]|#)(?:.|(?:\r\n?|\n)[ \t]*\.{3})+/,
|
50 | lookbehind: true,
|
51 | alias: 'string'
|
52 | };
|
53 |
|
54 | var testNameLike = {
|
55 | pattern: /([\r\n] ?)(?!#)(?:\S(?:[ \t]\S)*)+/,
|
56 | lookbehind: true,
|
57 | alias: 'function',
|
58 | inside: {
|
59 | 'variable': variable
|
60 | }
|
61 | };
|
62 |
|
63 | var testPropertyLike = {
|
64 | pattern: /([\r\n](?: {2}|\t)[ \t]*)(?!\[|\.{3}|#)(?:\S(?:[ \t]\S)*)+/,
|
65 | lookbehind: true,
|
66 | inside: {
|
67 | 'variable': variable
|
68 | }
|
69 | };
|
70 |
|
71 | Prism.languages['robotframework'] = {
|
72 | 'settings': createSection('Settings', {
|
73 | 'documentation': {
|
74 | pattern: /([\r\n] ?Documentation(?: {2}|\t)[ \t]*)(?![ \t]|#)(?:.|(?:\r\n?|\n)[ \t]*\.{3})+/,
|
75 | lookbehind: true,
|
76 | alias: 'string'
|
77 | },
|
78 | 'property': {
|
79 | pattern: /([\r\n] ?)(?!\.{3}|#)(?:\S(?:[ \t]\S)*)+/,
|
80 | lookbehind: true
|
81 | }
|
82 | }),
|
83 | 'variables': createSection('Variables'),
|
84 | 'test-cases': createSection('Test Cases', {
|
85 | 'test-name': testNameLike,
|
86 | 'documentation': docTag,
|
87 | 'property': testPropertyLike
|
88 | }),
|
89 | 'keywords': createSection('Keywords', {
|
90 | 'keyword-name': testNameLike,
|
91 | 'documentation': docTag,
|
92 | 'property': testPropertyLike
|
93 | }),
|
94 | 'tasks': createSection('Tasks', {
|
95 | 'task-name': testNameLike,
|
96 | 'documentation': docTag,
|
97 | 'property': testPropertyLike
|
98 | }),
|
99 | 'comment': comment
|
100 | };
|
101 |
|
102 | Prism.languages.robot = Prism.languages['robotframework'];
|
103 |
|
104 | }(Prism));
|