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

wrong bash beautifier colors #428

Closed
braoult opened this issue Mar 20, 2020 · 4 comments
Closed

wrong bash beautifier colors #428

braoult opened this issue Mar 20, 2020 · 4 comments

Comments

@braoult
Copy link
Contributor

braoult commented Mar 20, 2020

Not sure if this link is valid, nor if it is on exercism side:
On:
https://exercism.io/my/solutions/7a25d82ea512403280f7fd168040eefb
... colorization is wrong from line 57, likely from column 21, the quote (') char (which is escaped with "") looks like a normal quote, which makes all following code wrong.

@glennj
Copy link
Contributor

glennj commented Mar 20, 2020

This is not an issue for the bash track. Exercism uses https://github.com/PrismJS/prism for syntax highlighting, so really the bug report should go there.

@glennj glennj closed this as completed Mar 20, 2020
@glennj
Copy link
Contributor

glennj commented Mar 20, 2020

This module uses regular expressions to parse code, which is a good-enough-but-not-perfect approach. Here's where they identify a quoted string: https://github.com/PrismJS/prism/blob/master/components/prism-bash.js#L122

@braoult
Copy link
Contributor Author

braoult commented Mar 21, 2020

There is a workaround: instead of ' syntax, the "<char>" seems to be understood by prism. another is to remove the quotes in comments:

Initial faulty lines:

printf -v aval "%d" \'a                   # 'a' ascii value
printf -v zval "%d" \'z                   # 'z' ascii value

The following works with prism:

printf -v aval "%d" \'a                  # "a" ascii value
printf -v zval "%d" \'z                  # "z" ascii value

as well as this :

printf -v aval "%d" "'a"                # 'a' ascii value
printf -v zval "%d" "'z"                # 'z' ascii value

Looks like prism is "lost" by having the multiple single quotes on same line, for some reason. I filled a bug report PrismJS/prism#2255).

@braoult
Copy link
Contributor Author

braoult commented Mar 21, 2020

It has (normally) been fixed in prism:

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

No branches or pull requests

2 participants