Skip to content

Commit b7c3447

Browse files
committedAug 27, 2024·
Fix first ShellScript command
1 parent ec331a0 commit b7c3447

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed
 

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
## Features
44

5-
Syntax Highlighting for ShellScript language within `package.json` `"scripts"`
5+
Syntax Highlighting for ShellScript language within `package.json` `"scripts"`.
66
![Example `package.json` code](images/Example.png)
77

88

99
## Known Issues
1010

11-
ShellScript doesn't highlight code after double quotes `"` .
12-
Workaround is to place a semicolon `;` at the start of each string.
13-
1411
This extension targets every JSON file, not just `package.json`.
1512
However only a root level `"scripts"` object is affected.
1613

@@ -20,3 +17,6 @@ However only a root level `"scripts"` object is affected.
2017
## For more information
2118

2219
* The GitHub [Issue](https://github.com/microsoft/vscode/issues/224581) that spawned the idea
20+
* https://github.com/jeff-hykin/better-shell-syntax/issues/100
21+
* [Repository](https://github.com/RedCMD/JSON-Embedded-Languages)
22+
* [Marketplace](https://marketplace.visualstudio.com/items?itemName=RedCMD.json-embedded-languages)

‎images/Example.png

26.4 KB
Loading

‎syntaxes/package.json.tmLanguage.json

+23-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
"$schema": "https://raw.githubusercontent.com/RedCMD/TmLanguage-Syntax-Highlighter/main/vscode.tmLanguage.schema.json",
33
"name": "package.json",
44
"scopeName": "source.json.package",
5-
"injectionSelector": "L:source.json meta.structure.dictionary.json -meta.embedded.shellscript.json.package -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment",
5+
"injectionSelector": "L:source.json meta.structure.dictionary.json -meta.structure.dictionary.value.json -meta.structure.array.json -string -comment",
66
"patterns": [
77
{ "include": "#scripts" }
88
],
99
"repository": {
1010
"scripts": {
11-
"begin": "(?=\"scripts\")",
12-
"end": "(?<=,)(?!\\G)|(?=})",
13-
"name": "meta.embedded.shellscript.json.package",
11+
"begin": "(?!\\G)(?<=\"scripts\")(?!})",
12+
"end": "(?<=,)|(?=})",
1413
"patterns": [
15-
{ "include": "source.json#objectkey" },
14+
{
15+
"comment": "the JSON object key",
16+
"include": "source.json#objectkey"
17+
},
18+
{ "include": "source.json#comments" },
1619
{
1720
"comment": "Taken straight from `source.json`",
1821
"begin": ":",
@@ -58,7 +61,17 @@
5861
"comment": "Setup a `\\G` anchor for ShellScript to use",
5962
"begin": "|",
6063
"end": "(*FAIL)",
61-
"patterns": [ { "include": "source.shell" } ]
64+
"patterns": [
65+
{ "include": "source.shell" },
66+
{
67+
"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\\$)",
68+
"end": "(?=;|\\||&|\\n|\\)|`|\\{|\\}|[ \\t]*#|\\])(?<!\\\\)",
69+
"beginCaptures": { },
70+
"endCaptures": { },
71+
"name": "meta.statement.shell",
72+
"patterns": [ { "include": "source.shell#typical_statements" } ]
73+
}
74+
]
6275
},
6376
{ "include": "source.json#stringcontent" }
6477
]
@@ -91,6 +104,10 @@
91104
"name": "invalid.illegal.expected-dictionary-separator.json"
92105
}
93106
]
107+
},
108+
{
109+
"match": "[^\\s\\}]",
110+
"name": "invalid.illegal.expected-dictionary-separator.json"
94111
}
95112
]
96113
}

0 commit comments

Comments
 (0)
Please sign in to comment.