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

Add expressions inside string attribute values #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

savetheclocktower
Copy link
Collaborator

Fixes #44.

I tried to roughly follow the design of template strings in tree-sitter-javascript. Instead of doing something like…

(attribute_value
  (value_fragment)
  (expression (raw_text_expr))
  (value_fragment)
)

…I instead did…

(attribute_value
  (expression (raw_text_expr))
)

…so if you want to identify just the literal string parts, you can take (attribute_value) and ignore/subtract its children.

@savetheclocktower
Copy link
Collaborator Author

By the way, I've purposefully been making atomic PRs, but I've also got a branch with all of these changes combined. If they all look good to you individually, I can open a PR against that branch and we can save ourselves some merging headaches.

@Himujjal
Copy link
Owner

@savetheclocktower I would love for you to make a PR for the same. It would save us time as well

@AlbertMarashi
Copy link

@AlbertMarashi
Copy link

Also, are you sure about not making it like the former you shared?

Else, how will we do something like

[
  (attribute_value)
  (quoted_attribute_value)
] @string

For zed's syntax highlighting?

@savetheclocktower
Copy link
Collaborator Author

Else, how will we do something like

[
  (attribute_value)
  (quoted_attribute_value)
] @string

For zed's syntax highlighting?

I might be misunderstanding, but I don't see how this PR affects your ability to do that. The fact that all quoted_attribute_values have an inner attribute_value node is a behavior that this parser inherits from the HTML parser. It seems like your sample query would still work.

If you're saying that you want a way to identify everything but the expression so that you can highlight those parts like a string but not the expression… I imagine that could be solved by explicitly highlighting the inner expression in a non-string-like way to override the styles it would inherit from the surrounding string.

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.

Attribute value inaccurately highighted as plain string instead of an expression.
3 participants