diff --git a/README.md b/README.md index 59b175c..c98aeb8 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,12 @@ ## Features -Syntax Highlighting for ShellScript language within `package.json` `"scripts"` +Syntax Highlighting for ShellScript language within `package.json` `"scripts"`. ![Example `package.json` code](images/Example.png) ## Known Issues -ShellScript doesn't highlight code after double quotes `"` . -Workaround is to place a semicolon `;` at the start of each string. - This extension targets every JSON file, not just `package.json`. However only a root level `"scripts"` object is affected. @@ -20,3 +17,6 @@ However only a root level `"scripts"` object is affected. ## For more information * The GitHub [Issue](https://github.com/microsoft/vscode/issues/224581) that spawned the idea +* https://github.com/jeff-hykin/better-shell-syntax/issues/100 +* [Repository](https://github.com/RedCMD/JSON-Embedded-Languages) +* [Marketplace](https://marketplace.visualstudio.com/items?itemName=RedCMD.json-embedded-languages) \ No newline at end of file diff --git a/images/Example.png b/images/Example.png index 40b3c97..e8c9c5c 100644 Binary files a/images/Example.png and b/images/Example.png differ diff --git a/syntaxes/package.json.tmLanguage.json b/syntaxes/package.json.tmLanguage.json index 478ee21..916f29d 100644 --- a/syntaxes/package.json.tmLanguage.json +++ b/syntaxes/package.json.tmLanguage.json @@ -2,17 +2,20 @@ "$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json", "name": "package.json", "scopeName": "source.json.package", - "injectionSelector": "L:source.json meta.structure.dictionary.json -meta.embedded.shellscript.json.package -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment", + "injectionSelector": "L:source.json meta.structure.dictionary.json -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment", "patterns": [ { "include": "#scripts" } ], "repository": { "scripts": { - "begin": "(?=\"scripts\")", - "end": "(?<=,)(?!\\G)|(?=})", - "name": "meta.embedded.shellscript.json.package", + "begin": "(?!\\G)(?<=\"scripts\")(?!})", + "end": "(?<=,)|(?=})", "patterns": [ - { "include": "source.json#objectkey" }, + { + "comment": "the JSON object key", + "include": "source.json#objectkey" + }, + { "include": "source.json#comments" }, { "comment": "Taken straight from `source.json`", "begin": ":", @@ -58,7 +61,17 @@ "comment": "Setup a `\\G` anchor for ShellScript to use", "begin": "|", "end": "(*FAIL)", - "patterns": [ { "include": "source.shell" } ] + "patterns": [ + { "include": "source.shell" }, + { + "begin": "(?!^[ \\t]*+$)(?:(?<=^until | until |\\tuntil |^while | while |\\twhile |^elif | elif |\\telif |^else | else |\\telse |^then | then |\\tthen |^do | do |\\tdo |^if | if |\\tif )|(?<=\"\\G|^|;|\\||&|!|\\(|\\{|`))[ \\t]*+(?!nocorrect\\W|nocorrect\\$|function\\W|function\\$|foreach\\W|foreach\\$|repeat\\W|repeat\\$|logout\\W|logout\\$|coproc\\W|coproc\\$|select\\W|select\\$|while\\W|while\\$|pushd\\W|pushd\\$|until\\W|until\\$|case\\W|case\\$|done\\W|done\\$|elif\\W|elif\\$|else\\W|else\\$|esac\\W|esac\\$|popd\\W|popd\\$|then\\W|then\\$|time\\W|time\\$|for\\W|for\\$|end\\W|end\\$|fi\\W|fi\\$|do\\W|do\\$|in\\W|in\\$|if\\W|if\\$)", + "end": "(?=;|\\||&|\\n|\\)|`|\\{|\\}|[ \\t]*#|\\])(?