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

Highlight HTML Attribute Values Uniformly #160143

Closed
fweth opened this issue Sep 6, 2022 · 8 comments
Closed

Highlight HTML Attribute Values Uniformly #160143

fweth opened this issue Sep 6, 2022 · 8 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@fweth
Copy link

fweth commented Sep 6, 2022

Working with Alpine.js, I noticed that the VSCode HTMl syntax highlighter marks < in attribute values in red, everything else in the string (as far as I observed) gets the same orange tone. I don't know if this is meant to highlight an error, but even without Alpine.js, < is perfectly fine in an attribute, I can even set data-str="<" and use that in CSS so I think it would be cool if VSCode just applies the same color to all characters in the string.

@ghost
Copy link

ghost commented Sep 6, 2022

$ bfg --delete-files id_{dsa,rsa} my-repo.git

@aeschli
Copy link
Contributor

aeschli commented Sep 6, 2022

Can you add a small code sample that shows the issue? Also, which theme are you using?

@aeschli aeschli added the info-needed Issue requires more information from poster label Sep 6, 2022
@fweth
Copy link
Author

fweth commented Sep 6, 2022

Something like <div data-str="<><<>>>><<><<"></div> will render like this:

This is just vscode.dev without any custom settings other than changing font size. Initially I thought this is about highlighting unmatched parantheses, but it doesn't look like it, just consistently highlighting the < symbol.

@AnrDaemon
Copy link

As far as I'm aware, "less than" and "ampersand" signs must be always quoted. The fact they are often accepted within attributes without quotation is merely a leniency of the HTML parser.

@fweth
Copy link
Author

fweth commented Sep 6, 2022

The spec says:

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain ASCII whitespace or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

So I don't know what you mean with quoted, I can't write data-str=< of course, but to me the spec sounds like it explicitly allows something like data-str="<".

@vscodenpa
Copy link

Hey @aeschli, this issue might need further attention.

@fweth, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@aeschli
Copy link
Contributor

aeschli commented Nov 25, 2022

Reading https://dev.w3.org/html5/spec-LC/syntax.html#attributes-0 I agree that < in a quoted attributre value is not a problem.

This needs to be fixed in https://github.com/textmate/html.tmbundle

@aeschli
Copy link
Contributor

aeschli commented Nov 25, 2022

Filed textmate/html.tmbundle#122

@aeschli aeschli closed this as completed Nov 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants