Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(Ruby) #{} substitution shouldn't be highlighted in single quotes #3676

Open
verhovsky opened this issue Dec 12, 2022 · 3 comments · May be fixed by #4178
Open

(Ruby) #{} substitution shouldn't be highlighted in single quotes #3676

verhovsky opened this issue Dec 12, 2022 · 3 comments · May be fixed by #4178
Assignees
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@verhovsky
Copy link
Contributor

Describe the issue
In Ruby, single quote and double quote strings work differently:

In addition to disabling interpolation [(#{} syntax)], single-quoted strings also disable all escape sequences except for the single-quote (\') and backslash (\\).

https://docs.ruby-lang.org/en/3.1/syntax/literals_rdoc.html#label-Strings

But in ruby.js, they are implemented identically

{
begin: /'/,
end: /'/
},
{
begin: /"/,
end: /"/
},

which leads it to incorrectly highlight #{} substitutions in single quoted strings which actually have no effect, they are just literal #{} characters (in the "github" theme):

Screenshot 2022-12-11 at 19 00 50

instead of highlighting it as a string, like it does if we remove the #:

Screenshot 2022-12-11 at 19 01 01

Which language seems to have the issue?
Ruby

Are you using highlight or highlightAuto?
N/A

Expected behavior
Single and double quoted strings should have separate highlighting rules for Ruby.

Additional context
https://docs.ruby-lang.org/en/3.1/syntax/literals_rdoc.html#label-Strings

Unrelated, but for double quoted strings, that page also lists a couple interpolation syntax shorthands that are not implemented in the highlight.js grammar:

You can also use #@foo, #@@foo and #$foo as a shorthand for, respectively, #{ @foo }, #{ @@foo } and #{ $foo }.

@verhovsky verhovsky added bug help welcome Could use help from community language labels Dec 12, 2022
@joshgoebel joshgoebel added the good first issue Should be easier for first time contributors label Dec 12, 2022
@joshgoebel
Copy link
Member

Great catch. Would you be interested in working on a PR for this?

@verhovsky
Copy link
Contributor Author

No, sorry.

@kingflamez
Copy link

Hey @joshgoebel I'd love to work on this, could you please assign it to me?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants