From dc073598cf17df6ba31a3b9ffe4d6623d78f4ab6 Mon Sep 17 00:00:00 2001 From: RedCMD Date: Wed, 28 Aug 2024 11:07:47 +1200 Subject: [PATCH] Basic support for escaped double quotes `\"...\"` --- package.json | 7 ++++ .../shellscript.json.escaped.tmLanguage.json | 38 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 syntaxes/shellscript.json.escaped.tmLanguage.json diff --git a/package.json b/package.json index 33bc958..1a7d1a8 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,13 @@ "injectTo": [ "source.json" ] + }, + { + "scopeName": "source.shellscript.json.escaped", + "path": "./syntaxes/shellscript.json.escaped.tmLanguage.json", + "injectTo": [ + "source.json" + ] } ] }, diff --git a/syntaxes/shellscript.json.escaped.tmLanguage.json b/syntaxes/shellscript.json.escaped.tmLanguage.json new file mode 100644 index 0000000..a7892a1 --- /dev/null +++ b/syntaxes/shellscript.json.escaped.tmLanguage.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json", + "name": "package.json", + "scopeName": "source.shellscript.json.escaped", + "injectionSelector": "L:source.json meta.embedded.shellscript.json.package -string.quoted.double.shell", + "patterns": [ + { "include": "#string" } + ], + "repository": { + "string": { + "begin": "\\$?(\\\\\")", + "end": "\\\\\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.shell" }, + "1": { "name": "constant.character.escape.json" } + }, + "endCaptures": { "0": { "name": "punctuation.definition.string.end.shell constant.character.escape.json" } }, + "name": "string.quoted.double.shell", + "patterns": [ + { + "match": "\\\\{4}", + "name": "constant.character.escape.shell" + }, + { + "match": "\\\\{3}\"", + "name": "constant.character.escape.shell" + }, + { + "match": "\\\\{2}[$`]", + "name": "constant.character.escape.shell" + }, + { "include": "source.json#stringcontent" }, + { "include": "source.shell#variable" }, + { "include": "source.shell#interpolation" } + ] + } + } +} \ No newline at end of file