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

Consider finding a new HTML grammar: URL with double slashes within an onclick element highlighted as a code comment #202915

Open
CoconutMacaroon opened this issue Jan 20, 2024 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality grammar Syntax highlighting grammar
Milestone

Comments

@CoconutMacaroon
Copy link

CoconutMacaroon commented Jan 20, 2024

Does this issue occur when all extensions are disabled?: Yes/No
Yes. I did code-insiders.cmd --disable-extensions, and the issue still happened then.

  • VS Code Version: 1.86.0-insider
  • OS Version: Windows 11 Pro 22H2

Steps to Reproduce:

  1. Create a new HTML file, such as demo.html
  2. Paste in the following HTML code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title>Hello world!</title>
        <script>
            console.log("https://example.com");
        </script>
    </head>
    <body>
        <button onclick="console.log('https://example.com');">Click me!</button>
    </body>
    </html>
  3. Observe the rendering of the text:
    image

The string renders correctly when in a <script> ... </script> tag. However, when placed within an onclick of a <button> ... </button>, it (incorrectly) highlights the two slashes and the remainder of the string in green, as if it was a code comment. Interestingly, the semicolon is also green.

The expected behavior is that VS Code recognizes that it isn't a comment, but rather part of a string, and so highlights it like it does in the <script> ... </script> tag.

@perplexyves
Copy link
Contributor

Hello @CoconutMacaroon. A workaround to this colorization issue would be to treat the slash / as if it was an escape character:

<button onclick="console.log('https:\/\/example.com');">Click me!</button>

It would be nice though to dig deeper in it and find out why it's behaving like this.
Thank you for noticing!

@aeschli aeschli assigned alexr00 and unassigned aeschli Jan 22, 2024
@aeschli
Copy link
Contributor

aeschli commented Jan 22, 2024

duplicate of textmate/html.tmbundle#113

@aeschli aeschli closed this as completed Jan 22, 2024
@perplexyves
Copy link
Contributor

Hello @aeschli. Thanks for pointing out to the library textmate/html.tmbundle. However, the PR fix for this issue has been opened there 3 years ago and still hasn't been merged yet. Can we do something regarding it?

@aghArdeshir
Copy link
Contributor

I agree with @perplexyves . The latest commit/issue/MR in that repository is 3 years old. According to the WikiPedia of TextMate:

In October 2021, the latest/last commit was made to GitHub, though no announcement has been made to the effect that the project has been officially abandoned and its source code is still publicly available.

https://en.wikipedia.org/wiki/TextMate

Looks like dead to me too 👍

@alexr00 alexr00 reopened this Jan 23, 2024
@alexr00 alexr00 changed the title URL with double slashes within an onclick element highlighted as a code comment Consider finding a new HTML grammar: URL with double slashes within an onclick element highlighted as a code comment Jan 23, 2024
@alexr00 alexr00 added feature-request Request for new features or functionality grammar Syntax highlighting grammar labels Jan 23, 2024
@alexr00 alexr00 added this to the Backlog milestone Jan 23, 2024
@alexr00
Copy link
Member

alexr00 commented Jan 23, 2024

Reopened and repurposed this issue to track finding a new grammar for HTML syntax highlighting. My first look didn't turn up any good options.

@aghArdeshir
Copy link
Contributor

aghArdeshir commented Jan 23, 2024

@alexr00 I was preparing an issue about this last night, I left it half finished as draft, but posted it tonight: #203212

Now I noticed you've repurposed this issue for that. Feel free to close what I've just created, but I've left some more information about the problem there that you may find useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality grammar Syntax highlighting grammar
Projects
None yet
Development

No branches or pull requests

5 participants