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

Vue: Handle more edge cases #950

Merged
merged 1 commit into from
Apr 1, 2024
Merged

Conversation

Gusted
Copy link
Contributor

@Gusted Gusted commented Apr 1, 2024

  • The parsing of v- directives expected that this always ended in ">, however it is possible that there are other attributes after an v- directive also it made the assumption that there couldn't be any spaces in the value of the directive. Therefore it could result in incorrect lexing where almost the whole file could be marked as an LiteralString.
  • Handle - in HTML element names.
  • Explicitly mark = as an operator token.
  • Tests added.
  • Ref: https://codeberg.org/forgejo/forgejo/issues/2945

Before

Screen Shot 2024-04-01 at 13 58 18

After

Screen Shot 2024-04-01 at 23 01 17

@Maia-Everett
Copy link

Maia-Everett commented Apr 1, 2024

As the original reporter of this bug for Forgejo, the "after" behavior is exactly what I wanted and I hope this gets merged. Thanks!

Edit: though I'm not sure why the closing tags for q-* elements are colored red why the closing tags for standard HTML elements aren't. Either this is working as intended, or it's a separate bug.

- The parsing of `v-` directives expected that this always ended in
`">`, however it is possible that there are other attributes after an
`v-` directive also it made the assumption that there couldn't be any
spaces in the value of the directive. Therefore it could result in
incorrect lexing where almost the whole file could be marked as an
LiteralString.
- Handle `-` in HTML element names.
- Explicitely mark `=` as an operator token.
- Tests added.
- Ref: https://codeberg.org/forgejo/forgejo/issues/2945
@Gusted Gusted changed the title Vue: Better parsing of v- directives Vue: Handle more edge cases Apr 1, 2024
@Gusted
Copy link
Contributor Author

Gusted commented Apr 1, 2024

Edit: though I'm not sure why the closing tags for q-* elements are colored red why the closing tags for standard HTML elements aren't. Either this is working as intended, or it's a separate bug.

Fixed by https://github.com/alecthomas/chroma/compare/90531d5c073acb919eeecfbe743ae8c6ef0f0dfa..d33880c230195603aa80484942e268944ebd6e17 also updated the screenshot accordingly.

@alecthomas alecthomas merged commit 5f83664 into alecthomas:master Apr 1, 2024
2 checks passed
@Gusted Gusted deleted the vue-fixes branch April 1, 2024 21:02
@Gusted
Copy link
Contributor Author

Gusted commented Apr 1, 2024

@alecthomas Thank you for time to review this! Much appreciated.

@alecthomas
Copy link
Owner

Thanks for the PR!

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.

3 participants