vscode-ebnf

EBNF for Visual Studio Code
Mirror of https://github.com/Jamozed/vscode-ebnf
git clone http://git.omkov.net/vscode-ebnf
Log | Tree | Refs | README | LICENCE | Download

AuthorDrew Youngwerth <[email protected]>
Date2022-11-22 03:04:44
Commitad4a2a877f0de22273aa68e548da6a041b2e27b5
Parentdd4fced77f3de7aee2ce5eda914e19e5260177db

Add syntax highlighting for EBNF codeblocks in markdown (#2)

Diffstat

M package.json | 9 +++++++++
A syntaxes/ebnf.mdCodeblock.json | 28 ++++++++++++++++++++++++++++

2 files changed, 37 insertions, 0 deletions

diff --git a/package.json b/package.json
index 323824a..4d72fbe 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,15 @@
 				"language": "ebnf",
 				"scopeName": "text.ebnf",
 				"path": "./syntaxes/ebnf.tmLanguage.json"
-			}
+			},
+			{
+      	"scopeName": "markdown.ebnf.codeblock",
+      	"path": "./syntaxes/ebnf.mdCodeblock.json",
+      	"injectTo": ["text.html.markdown"],
+      	"embeddedLanguages": {
+        	"meta.embedded.block.ebnf": "ebnf"
+      	}
+    	}
 		]
 	},
 	"icon": "icon.png",
diff --git a/syntaxes/ebnf.mdCodeblock.json b/syntaxes/ebnf.mdCodeblock.json
new file mode 100644
index 0000000..2f3d201
--- /dev/null
+++ b/syntaxes/ebnf.mdCodeblock.json
@@ -0,0 +1,28 @@
+{
+  "fileTypes": [],
+  "injectionSelector": "L:markup.fenced_code.block.markdown",
+  "patterns": [
+    {
+      "include": "#ebnf-code-block"
+    }
+  ],
+  "repository": {
+    "ebnf-code-block": {
+      "begin": "(?<=[`~])ebnf(\\s+[^`~]*)?$",
+      "end": "(^|\\G)(?=\\s*[`~]{3,}\\s*$)",
+      "patterns": [
+        {
+          "begin": "(^|\\G)(\\s*)(.*)",
+          "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
+          "contentName": "meta.embedded.block.ebnf",
+          "patterns": [
+            {
+              "include": "text.ebnf"
+            }
+          ]
+        }
+      ]
+    }
+  },
+  "scopeName": "markdown.ebnf.codeblock"
+}