From 4bb09e3c8e0d34cd48adea2e40c56191f3ae7a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= Date: Sun, 9 Mar 2025 11:34:09 +0100 Subject: [PATCH 1/3] feat: add syntax highlighting in markdown code blocks --- package.json | 10 +++++++++ syntaxes/codeblock.json | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 syntaxes/codeblock.json diff --git a/package.json b/package.json index a6ee4c7..60ddf4c 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,16 @@ "language": "nushell", "scopeName": "source.nushell", "path": "./syntaxes/nushell.tmLanguage.json" + }, + { + "scopeName": "markdown.nushell.codeblock", + "path": "./syntaxes/codeblock.json", + "injectTo": [ + "text.html.markdown" + ], + "embeddedLanguages": { + "meta.embedded.block.nushell": "nushell" + } } ], "keybindings": [ diff --git a/syntaxes/codeblock.json b/syntaxes/codeblock.json new file mode 100644 index 0000000..0d895b2 --- /dev/null +++ b/syntaxes/codeblock.json @@ -0,0 +1,45 @@ +{ + "fileTypes": [], + "injectionSelector": "L:text.html.markdown", + "patterns": [ + { + "include": "#nushell-code-block" + } + ], + "repository": { + "nushell-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(nushell)(\\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.nushell", + "patterns": [ + { + "include": "source.nushell" + } + ] + } + ] + } + }, + "scopeName": "markdown.nushell.codeblock" +} \ No newline at end of file From 96524a6a7cf90d6759c53b8ab24c8b1b248a8327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= Date: Mon, 10 Mar 2025 18:01:35 +0100 Subject: [PATCH 2/3] add feature in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e0d421..6518919 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This [extension for VSCode](https://marketplace.visualstudio.com/items?itemName= ## Features -- Syntax highlighting grammar for Nushell scripts (`.nu` files) +- Syntax highlighting grammar for Nushell scripts (`.nu` files) and ``nushell`` codeblocks in Markdown files - Goto definition - Hover support - Validation (errors with red squiggly lines) From bd84198edcc51f4a27cde800f266e86e73ea1732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Riegel?= Date: Mon, 10 Mar 2025 18:47:51 +0100 Subject: [PATCH 3/3] replace tabs by 4 spaces --- syntaxes/codeblock.json | 86 ++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/syntaxes/codeblock.json b/syntaxes/codeblock.json index 0d895b2..8a0bab3 100644 --- a/syntaxes/codeblock.json +++ b/syntaxes/codeblock.json @@ -1,45 +1,45 @@ { - "fileTypes": [], - "injectionSelector": "L:text.html.markdown", - "patterns": [ - { - "include": "#nushell-code-block" - } - ], - "repository": { - "nushell-code-block": { - "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(nushell)(\\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.nushell", - "patterns": [ - { - "include": "source.nushell" - } - ] - } - ] - } - }, - "scopeName": "markdown.nushell.codeblock" + "fileTypes": [], + "injectionSelector": "L:text.html.markdown", + "patterns": [ + { + "include": "#nushell-code-block" + } + ], + "repository": { + "nushell-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(nushell)(\\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.nushell", + "patterns": [ + { + "include": "source.nushell" + } + ] + } + ] + } + }, + "scopeName": "markdown.nushell.codeblock" } \ No newline at end of file