Skip to content

Commit

Permalink
🩹 Correct embedded recipe block body end check (#69)
Browse files Browse the repository at this point in the history
fix: correct embedded end check
  • Loading branch information
nefrob authored Jan 2, 2025
1 parent 04e7aee commit 8027d75
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 104 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
- Upgrade node from 21 to 22, along with other dependencies
- Improve scope list formatting

### Fixed

- Embedded recipes with empty lines now highlight correctly

## [0.6.0] - 2024-10-06

### Added
Expand Down
10 changes: 5 additions & 5 deletions syntaxes/just.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@
{
"comment": "JavaScript",
"begin": "^\\s+(#!/usr/bin/env\\s+node.*)$",
"end": "^$",
"end": "(?<=^[^\\s]+)",
"beginCaptures": {
"1": {
"name": "comment.line.number-sign.shebang.just"
Expand All @@ -675,7 +675,7 @@
{
"comment": "Perl",
"begin": "^\\s+(#!/usr/bin/env\\s+perl.*)$",
"end": "^$",
"end": "(?<=^[^\\s]+)",
"beginCaptures": {
"1": {
"name": "comment.line.number-sign.shebang.just"
Expand All @@ -691,7 +691,7 @@
{
"comment": "Python",
"begin": "^\\s+(#!/usr/bin/env\\s+python.*)$",
"end": "^$",
"end": "(?<=^[^\\s]+)",
"beginCaptures": {
"1": {
"name": "comment.line.number-sign.shebang.just"
Expand All @@ -707,7 +707,7 @@
{
"comment": "Ruby",
"begin": "^\\s+(#!/usr/bin/env\\s+ruby.*)$",
"end": "^$",
"end": "(?<=^[^\\s]+)",
"beginCaptures": {
"1": {
"name": "comment.line.number-sign.shebang.just"
Expand All @@ -723,7 +723,7 @@
{
"comment": "Shell",
"begin": "^\\s+(#!/usr/bin/env\\s+(?:sh|bash|zsh|fish).*)$",
"end": "^$",
"end": "(?<=^[^\\s]+)",
"beginCaptures": {
"1": {
"name": "comment.line.number-sign.shebang.just"
Expand Down
10 changes: 5 additions & 5 deletions syntaxes/just.tmLanguage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ repository:
patterns:
- comment: JavaScript
begin: "^\\s+(#!/usr/bin/env\\s+node.*)$"
end: ^$
end: (?<=^[^\s]+)
beginCaptures:
'1':
name: comment.line.number-sign.shebang.just
Expand All @@ -494,7 +494,7 @@ repository:
- include: source.js
- comment: Perl
begin: "^\\s+(#!/usr/bin/env\\s+perl.*)$"
end: ^$
end: (?<=^[^\s]+)
beginCaptures:
'1':
name: comment.line.number-sign.shebang.just
Expand All @@ -503,7 +503,7 @@ repository:
- include: source.perl
- comment: Python
begin: "^\\s+(#!/usr/bin/env\\s+python.*)$"
end: ^$
end: (?<=^[^\s]+)
beginCaptures:
'1':
name: comment.line.number-sign.shebang.just
Expand All @@ -512,7 +512,7 @@ repository:
- include: source.python
- comment: Ruby
begin: "^\\s+(#!/usr/bin/env\\s+ruby.*)$"
end: ^$
end: (?<=^[^\s]+)
beginCaptures:
'1':
name: comment.line.number-sign.shebang.just
Expand All @@ -521,7 +521,7 @@ repository:
- include: source.ruby
- comment: Shell
begin: "^\\s+(#!/usr/bin/env\\s+(?:sh|bash|zsh|fish).*)$"
end: ^$
end: (?<=^[^\s]+)
beginCaptures:
'1':
name: comment.line.number-sign.shebang.just
Expand Down
29 changes: 17 additions & 12 deletions syntaxes/tests/embedded/embedded.just
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# Embedded languages

# TODO: how to test embedded grammars in snapshots?

python:
#!/usr/bin/env python3
print('Hello from python!')
#!/usr/bin/env python3
print('Hello from python!')
js:
#!/usr/bin/env node
console.log('Greetings from JavaScript!')
#!/usr/bin/env node
console.log('Greetings from JavaScript!')
perl:
#!/usr/bin/env perl
print "Larry Wall says Hi!\n";
#!/usr/bin/env perl
print "Larry Wall says Hi!\n";
sh:
#!/usr/bin/env sh
hello='Yo'
echo "$hello from a shell script!"
#!/usr/bin/env sh
hello='Yo'
echo "$hello from a shell script!"
ruby:
#!/usr/bin/env ruby
puts "Hello from ruby!"
#!/usr/bin/env ruby
puts "Hello from ruby!"
empty-lines:
#!/usr/bin/env python3
print('Hello from python!')
print('Hello from python!')
192 changes: 110 additions & 82 deletions syntaxes/tests/embedded/embedded.just.snap
Original file line number Diff line number Diff line change
@@ -1,106 +1,134 @@
># Embedded languages
#^^^^^^^^^^^^^^^^^^^^ source.just comment.line.number-sign.just
>
># TODO: how to test embedded grammars in snapshots?
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just comment.line.number-sign.just
>
>python:
#^^^^^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env python3
#^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^^^^ source.just
> print('Hello from python!')
#^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
> #!/usr/bin/env python3
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^^^^ source.just
> print('Hello from python!')
#^^^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
>
>js:
#^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env node
#^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> console.log('Greetings from JavaScript!')
#^^^^^^^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
> #!/usr/bin/env node
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> console.log('Greetings from JavaScript!')
#^^^^^^^^^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
>
>perl:
#^^^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env perl
#^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> print "Larry Wall says Hi!\n";
#^^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
# ^^ source.just
> #!/usr/bin/env perl
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> print "Larry Wall says Hi!\n";
#^^^^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^^ source.just string.quoted.double.just constant.character.escape.just
# ^ source.just string.quoted.double.just
# ^^ source.just
>
>sh:
#^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env sh
#^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^ source.just
> hello='Yo'
#^^^^^^^^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
> echo "$hello from a shell script!"
#^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^ source.just string.quoted.double.just
> #!/usr/bin/env sh
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^ source.just
> hello='Yo'
#^^^^^^^^^^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
> echo "$hello from a shell script!"
#^^^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^ source.just string.quoted.double.just
>
>ruby:
#^^^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env ruby
#^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> puts "Hello from ruby!"
#^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^ source.just string.quoted.double.just
> #!/usr/bin/env ruby
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^ source.just
> puts "Hello from ruby!"
#^^^^^^^^^ source.just
# ^ source.just string.quoted.double.just string.quoted.double.just
# ^^^^^^^^^^^^^^^^ source.just string.quoted.double.just
# ^ source.just string.quoted.double.just
>
>empty-lines:
#^^^^^^^^^^^ source.just entity.name.function.just
# ^ source.just keyword.operator.recipe.end.just
> #!/usr/bin/env python3
#^^^^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just
# ^ source.just keyword.operator.path-join.just
# ^^^ source.just support.function.builtin.just
# ^^^^^^^^^ source.just
> print('Hello from python!')
#^^^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
>
> print('Hello from python!')
#^^^^^^^^^ source.just
# ^ source.just
# ^ source.just string.quoted.single.just string.quoted.single.just
# ^^^^^^^^^^^^^^^^^^ source.just string.quoted.single.just
# ^ source.just string.quoted.single.just
# ^ source.just
>

0 comments on commit 8027d75

Please sign in to comment.