From 84f7348eb638b8168124c53795bbe088e000e397 Mon Sep 17 00:00:00 2001 From: Barry Nolte Date: Tue, 29 Aug 2023 14:12:48 -0700 Subject: [PATCH] Fix for #119 Fix for #119 --- package.json | 14 +++++++++ syntaxes/d2-markdown-injection.json | 45 +++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 syntaxes/d2-markdown-injection.json diff --git a/package.json b/package.json index d4446d4..fca01ee 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,9 @@ }, { "id": "markdown.d2" + }, + { + "id": "d2-markdown-injection" } ], "grammars": [ @@ -84,6 +87,17 @@ "language": "markdown.d2", "scopeName": "text.html.markdown.d2", "path": "./syntaxes/markdown.tmLanguage.json" + }, + { + "language": "d2-markdown-injection", + "scopeName": "markdown.d2.codeblock", + "path": "./syntaxes/d2-markdown-injection.json", + "injectTo": [ + "text.html.markdown" + ], + "embeddedLanguages": { + "meta.embedded.block.d2": "d2" + } } ], "markdown.markdownItPlugins": true, diff --git a/syntaxes/d2-markdown-injection.json b/syntaxes/d2-markdown-injection.json new file mode 100644 index 0000000..aeb3be2 --- /dev/null +++ b/syntaxes/d2-markdown-injection.json @@ -0,0 +1,45 @@ +{ + "fileTypes": [], + "injectionSelector": "L:text.html.markdown", + "patterns": [ + { + "include": "#d2-code-block" + } + ], + "repository": { + "d2-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(d2)(\\s+[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.d2", + "patterns": [ + { + "include": "source.d2" + } + ] + } + ] + } + }, + "scopeName": "markdown.d2.codeblock" +}