Skip to content

Commit b9de061

Browse files
committed
feat(vscode): support for highlighning robot code in markdown code blocks
use the at defining the language in a codeblock you can use `robot` or `robotframework` as specifier Example: ~~~ ```robot *** Settings *** Library Browser *** Variables *** ${BROWSER} Chrome *** Test Cases *** Open Browser New Page http://www.google.com Click name=q Evaluate ${{(a+' asd'+ b + 2)[1:3]}} ``` ~~~
1 parent 59f3da9 commit b9de061

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
],
8282
"main": "./out/extension.js",
8383
"contributes": {
84+
"markdown.markdownItPlugins": true,
8485
"icons": {
8586
"robotcode-robot": {
8687
"description": "RobotFramework Icon",
@@ -344,6 +345,9 @@
344345
".resource"
345346
],
346347
"configuration": "./language-configuration.json"
348+
},
349+
{
350+
"id": "robotframework-injection"
347351
}
348352
],
349353
"grammars": [
@@ -359,6 +363,17 @@
359363
"comment.robotframework",
360364
"comment"
361365
]
366+
},
367+
{
368+
"language": "robotframework-injection",
369+
"scopeName": "markdown.robotframework.codeblock",
370+
"path": "./syntaxes/codeblock_robotframework.tmLanguage.json",
371+
"injectTo": [
372+
"text.html.markdown"
373+
],
374+
"embeddedLanguages": {
375+
"meta.embedded.block.robotframework": "robotframework"
376+
}
362377
}
363378
],
364379
"keybindings": [
@@ -948,6 +963,12 @@
948963
"command": "robotcode.keywordsTreeView.showDocumentation",
949964
"enablement": "resourceLangId == robotframework && view == robotcode.keywordsTreeView",
950965
"icon": "$(book)"
966+
},
967+
{
968+
"title": "Create New File",
969+
"shortTitle": "Robot Framework File",
970+
"category": "RobotCode",
971+
"command": "robotcode.createNewFile"
951972
}
952973
],
953974
"menus": {
@@ -997,6 +1018,13 @@
9971018
"command": "robotcode.keywordsTreeView.showDocumentation",
9981019
"when": "view == robotcode.keywordsTreeView"
9991020
}
1021+
],
1022+
"file/newFile": [
1023+
{
1024+
"command": "robotcode.createNewFile",
1025+
"group": "file",
1026+
"when": "!virtualWorkspace"
1027+
}
10001028
]
10011029
},
10021030
"breakpoints": [
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"fileTypes": [],
3+
"injectionSelector": "L:text.html.markdown",
4+
"patterns": [
5+
{
6+
"include": "#robotframework-code-block"
7+
}
8+
],
9+
"repository": {
10+
"robotframework-code-block": {
11+
"begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(robot|robotframework)(\\s+[^`~]*)?$)",
12+
"name": "markup.fenced_code.block.markdown",
13+
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
14+
"beginCaptures": {
15+
"3": {
16+
"name": "punctuation.definition.markdown"
17+
},
18+
"4": {
19+
"name": "fenced_code.block.language.markdown"
20+
},
21+
"5": {
22+
"name": "fenced_code.block.language.attributes.markdown"
23+
}
24+
},
25+
"endCaptures": {
26+
"3": {
27+
"name": "punctuation.definition.markdown"
28+
}
29+
},
30+
"patterns": [
31+
{
32+
"begin": "(^|\\G)(\\s*)(.*)",
33+
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
34+
"contentName": "meta.embedded.block.robotframework",
35+
"patterns": [
36+
{
37+
"include": "source.robotframework"
38+
}
39+
]
40+
}
41+
]
42+
}
43+
},
44+
"scopeName": "markdown.robotframework.codeblock"
45+
}

syntaxes/robotframework.tmLanguage.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2405,5 +2405,6 @@
24052405
"uuid": "a7fae509-bc8d-451e-b5fc-a47feb9d2a9e",
24062406
"fileTypes": [ "robotframework" ],
24072407
"name": "Robot Framework",
2408-
"scopeName": "source.robotframework"
2408+
"scopeName": "source.robotframework",
2409+
"displayName": "Robot Framework"
24092410
}

0 commit comments

Comments
 (0)