source: node_modules/refractor/lang/robotframework.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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