Skip to content

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 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
@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

3 participants