Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(ruby) don't highlight interpolation in single quoted strings #4178

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

verhovsky
Copy link
Contributor

Fixes #3676

Changes

Not all Ruby strings can contain (contains:) string substitutions (SUBST).

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +91 B

View Changes
file base pr diff
es/languages/ruby.min.js 1.84 KB 1.88 KB +46 B
highlight.min.js 8.22 KB 8.22 KB -1 B
languages/ruby.min.js 1.84 KB 1.89 KB +46 B

@verhovsky verhovsky changed the title Ruby's single quoted strings don't do interpolation fix(ruby) don't highlight interpolation in single quoted strings Nov 29, 2024
Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

4 files changed

Total change +92 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.18 KB +1 B
es/highlight.min.js 8.18 KB 8.18 KB +1 B
es/languages/ruby.min.js 1.84 KB 1.88 KB +45 B
languages/ruby.min.js 1.84 KB 1.89 KB +45 B

"<>",
"\\/\\/",
"%%",
"--"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to flush this out a fit further while we're here?

Copy link

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

5 files changed

Total change +486 B

View Changes
file base pr diff
es/core.min.js 8.18 KB 8.22 KB +43 B
es/highlight.min.js 8.18 KB 8.22 KB +43 B
es/languages/ruby.min.js 1.84 KB 2.02 KB +179 B
highlight.min.js 8.22 KB 8.26 KB +43 B
languages/ruby.min.js 1.84 KB 2.02 KB +178 B

@joshgoebel
Copy link
Member

I jumped in here on top of your work to organize things a bit nicer and try to DRY it up just a little... any additional thoughts? I left some work for the future, but I think it's broken out a lot clearer now.

"[]",
"{}",
"<>",
"\\/\\/",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean

Suggested change
"\\/\\/",
"//",

d.charAt(1) won't work because it's 4 characters long.

> d = "\\/\\/"
'\\/\\/'
> d.charAt(0)
'\\'
> d.charAt(1)
'/'

https://docs.ruby-lang.org/en/3.1/syntax/literals_rdoc.html#label-Percent+Literals says

Each of the literals in described in this section may use these paired delimiters

  • [...]
  • Any other character, as both beginning and ending delimiters.

Which seems like something regex can't handle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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