Skip to content

Commit

Permalink
Added Robot Framework plain text format (#2034)
Browse files Browse the repository at this point in the history
This adds support for the Robot Framework plain text space separated format.
https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#plain-text-format
  • Loading branch information
RunDevelopment authored Sep 3, 2019
1 parent 3fda5c9 commit f7eaa61
Show file tree
Hide file tree
Showing 16 changed files with 865 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,11 @@
"title": "Roboconf",
"owner": "Golmote"
},
"robot-framework": {
"title": "Robot Framework",
"alias": "robot",
"owner": "RunDevelopment"
},
"ruby": {
"title": "Ruby",
"require": "clike",
Expand Down
104 changes: 104 additions & 0 deletions components/prism-robot-framework.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
(function (Prism) {

var comment = {
pattern: /(^[ \t]*| {2}|\t)#.*/m,
lookbehind: true,
greedy: true
};

var variable = {
pattern: /((?:^|[^\\])(?:\\{2})*)[$@&%]\{(?:[^{}\r\n]|\{[^{}\r\n]*\})*\}/,
lookbehind: true,
inside: {
'punctuation': /^[$@&%]\{|\}$/
}
};

function createSection(name, inside) {
var extendecInside = {};

extendecInside['section-header'] = {
pattern: /^ ?\*{3}.+?\*{3}/,
alias: 'keyword'
};

// copy inside tokens
for (var token in inside) {
extendecInside[token] = inside[token];
}

extendecInside['tag'] = {
pattern: /([\r\n](?: |\t)[ \t]*)\[[-\w]+\]/,
lookbehind: true,
inside: {
'punctuation': /\[|\]/
}
};
extendecInside['variable'] = variable;
extendecInside['comment'] = comment;

return {
pattern: RegExp(/^ ?\*{3}[ \t]*<name>[ \t]*\*{3}(?:.|[\r\n](?!\*{3}))*/.source.replace(/<name>/g, name), 'im'),
alias: 'section',
inside: extendecInside
};
}


var docTag = {
pattern: /(\[Documentation\](?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
lookbehind: true,
alias: 'string'
};

var testNameLike = {
pattern: /([\r\n] ?)(?!#)(?:\S(?:[ \t]\S)*)+/,
lookbehind: true,
alias: 'function',
inside: {
'variable': variable
}
};

var testPropertyLike = {
pattern: /([\r\n](?: |\t)[ \t]*)(?!\[|\.{3}|#)(?:\S(?:[ \t]\S)*)+/,
lookbehind: true,
inside: {
'variable': variable
}
};

Prism.languages['robot-framework'] = {
'settings': createSection('Settings', {
'documentation': {
pattern: /([\r\n] ?Documentation(?: |\t)[ \t]*)(?![ \t]|#)(?:.|[ \t]*(?:\r\n?|\n)[ \t]*\.{3}[ \t]*)+/,
lookbehind: true,
alias: 'string'
},
'property': {
pattern: /([\r\n] ?)(?!\.{3}|#)(?:\S(?:[ \t]\S)*)+/,
lookbehind: true
}
}),
'variables': createSection('Variables'),
'test-cases': createSection('Test Cases', {
'test-name': testNameLike,
'documentation': docTag,
'property': testPropertyLike
}),
'keywords': createSection('Keywords', {
'keyword-name': testNameLike,
'documentation': docTag,
'property': testPropertyLike
}),
'tasks': createSection('Tasks', {
'task-name': testNameLike,
'documentation': docTag,
'property': testPropertyLike
}),
'comment': comment
};

Prism.languages.robot = Prism.languages['robot-framework'];

}(Prism));
1 change: 1 addition & 0 deletions components/prism-robot-framework.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions examples/prism-robot-framework.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<h2>Full example</h2>
<pre><code>*** Settings ***
Documentation Example using the space separated plain text format.
Library OperatingSystem

*** Variables ***
${MESSAGE} Hello, world!

*** Test Cases ***
My Test
[Documentation] Example test
Log ${MESSAGE}
My Keyword /tmp

Another Test
Should Be Equal ${MESSAGE} Hello, world!

*** Keywords ***
My Keyword
[Arguments] ${path}
Directory Should Exist ${path}</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"objectpascal": "pascal",
"px": "pcaxis",
"py": "python",
"robot": "robot-framework",
"rb": "ruby",
"trig": "turtle",
"ts": "typescript",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
"tsx": "React TSX",
"renpy": "Ren'py",
"rest": "reST (reStructuredText)",
"robot-framework": "Robot Framework",
"robot": "Robot Framework",
"rb": "Ruby",
"sas": "SAS",
"sass": "Sass (Sass)",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f7eaa61

Please sign in to comment.