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

Code Panel: weird syntax highlighting #1116

Closed
jamessspanggg opened this issue Mar 4, 2020 · 5 comments · Fixed by #1521
Closed

Code Panel: weird syntax highlighting #1116

jamessspanggg opened this issue Mar 4, 2020 · 5 comments · Fixed by #1521

Comments

@jamessspanggg
Copy link
Contributor

jamessspanggg commented Mar 4, 2020

Link to reproduce

Screen Shot 2020-03-04 at 11 43 55 PM

@Tejas2805
Copy link
Contributor

Tejas2805 commented Mar 5, 2020

Based on my investigation its looks like, hljs is picking it up as regex and that's why the wrong highlighting.

UPDATE: This is a bug in highlight.js and happens because it's picking up the code as regex. I have tried the latest released version (v9.18.1), but it's still not fixed. They plan to release it in v10.0

@jamessspanggg
Copy link
Contributor Author

jamessspanggg commented Mar 5, 2020

@Tejas2805 I've looked into it and I think the issue is because -

``${(pos - offset) * 100 / base}%`; is an ES6 way for string interpolation, while the code highlighted is based on javascript instead of ES6:
Screen Shot 2020-03-05 at 8 50 29 PM

Have tried switching to interpret it as ES6 and it highlights correctly:
Screen Shot 2020-03-05 at 8 51 35 PM

Update: I think my investigation is wrong, ES6 syntax is supported in hljs javascript

@gerhean
Copy link
Contributor

gerhean commented Mar 29, 2021

UPDATE: This is a bug in highlight.js and happens because it's picking up the code as regex. I have tried the latest released version (v9.18.1), but it's still not fixed. They plan to release it in v10.0

The latest Highlight.js is at v10.7.1, so can be fixed easily. However the code given in Link to reproduce does not exist anymore so can't really test.

@dcshzj
Copy link
Member

dcshzj commented Apr 2, 2021

You can reproduce this by specifying the date range to generate the report:

gradlew run -Dargs="--since d1 --until 16/03/2020"
gradlew run -Dargs="--view ./reposense-report"

Click on the Code Panel for Metta (ongspxm) to see the weird syntax highlighting.

@gerhean
Copy link
Contributor

gerhean commented Apr 2, 2021

image

Fixed by v10.7.1

Will be doing PR soon.

fzdy1914 pushed a commit that referenced this issue Apr 23, 2021
RepoSense frontend is using `[email protected]` which has some 
highlighting issues.

These issues were fixed by the following PR in `highlightjs`:
highlightjs/highlight.js#2531

Let's update `highlightjs` to `10.7.1` in RepoSense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants