Skip to content

Commit f7eaa61

Browse files
Added Robot Framework plain text format (#2034)
This adds support for the Robot Framework plain text space separated format. https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#plain-text-format
1 parent 3fda5c9 commit f7eaa61

16 files changed

+865
-3
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+5
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,11 @@
817817
"title": "Roboconf",
818818
"owner": "Golmote"
819819
},
820+
"robot-framework": {
821+
"title": "Robot Framework",
822+
"alias": "robot",
823+
"owner": "RunDevelopment"
824+
},
820825
"ruby": {
821826
"title": "Ruby",
822827
"require": "clike",

components/prism-robot-framework.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
// copy inside tokens
26+
for (var token in inside) {
27+
extendecInside[token] = inside[token];
28+
}
29+
30+
extendecInside['tag'] = {
31+
pattern: /([\r\n](?: |\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, name), 'im'),
42+
alias: 'section',
43+
inside: extendecInside
44+
};
45+
}
46+
47+
48+
var docTag = {
49+
pattern: /(\[Documentation\](?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
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](?: |\t)[ \t]*)(?!\[|\.{3}|#)(?:\S(?:[ \t]\S)*)+/,
65+
lookbehind: true,
66+
inside: {
67+
'variable': variable
68+
}
69+
};
70+
71+
Prism.languages['robot-framework'] = {
72+
'settings': createSection('Settings', {
73+
'documentation': {
74+
pattern: /([\r\n] ?Documentation(?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
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['robot-framework'];
103+
104+
}(Prism));

components/prism-robot-framework.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-robot-framework.html

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<h2>Full example</h2>
2+
<pre><code>*** Settings ***
3+
Documentation Example using the space separated plain text format.
4+
Library OperatingSystem
5+
6+
*** Variables ***
7+
${MESSAGE} Hello, world!
8+
9+
*** Test Cases ***
10+
My Test
11+
[Documentation] Example test
12+
Log ${MESSAGE}
13+
My Keyword /tmp
14+
15+
Another Test
16+
Should Be Equal ${MESSAGE} Hello, world!
17+
18+
*** Keywords ***
19+
My Keyword
20+
[Arguments] ${path}
21+
Directory Should Exist ${path}</code></pre>

plugins/autoloader/prism-autoloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
"objectpascal": "pascal",
154154
"px": "pcaxis",
155155
"py": "python",
156+
"robot": "robot-framework",
156157
"rb": "ruby",
157158
"trig": "turtle",
158159
"ts": "typescript",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
"tsx": "React TSX",
119119
"renpy": "Ren'py",
120120
"rest": "reST (reStructuredText)",
121+
"robot-framework": "Robot Framework",
122+
"robot": "Robot Framework",
121123
"rb": "Ruby",
122124
"sas": "SAS",
123125
"sass": "Sass (Sass)",

plugins/show-language/prism-show-language.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)