diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..95d15fb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ], + "name": "Test Extension", + "outFiles": [ + "${workspaceFolder}/out/**/*.js" + ], + "preLaunchTask": "npm: esbuild", + "request": "launch", + "type": "extensionHost" + } + ] +} diff --git a/package.json b/package.json index 3f559e1..0c1c9d0 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,14 @@ "language": "unison", "scopeName": "source.u", "path": "./syntaxes/unison.tmLanguage.json" + }, + { + "path": "./syntaxes/unison-markdown-injection.tmLanguage.json", + "scopeName": "markdown.unison.codeblock", + "injectTo": ["text.html.markdown"], + "embeddedLanguages": { + "meta.embedded.unison": "unison" + } } ], "configuration": { diff --git a/syntaxes/unison-markdown-injection.tmLanguage.json b/syntaxes/unison-markdown-injection.tmLanguage.json new file mode 100644 index 0000000..1ac93e6 --- /dev/null +++ b/syntaxes/unison-markdown-injection.tmLanguage.json @@ -0,0 +1,44 @@ +{ + "scopeName": "markdown.unison.codeblock", + "injectionSelector": "L:text.html.markdown", + "patterns": [ + { + "include": "#unison-code-block" + } + ], + "repository": { + "unison-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(unison)(\\s+[^`~]*)?$)", + "name": "markup.fenced.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced.block.language.markdown" + }, + "5": { + "name": "fenced.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.unison", + "patterns": [ + { + "include": "source.u" + } + ] + } + ] + } + } +}