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 support for the contents of yew's html! macro #172

Closed
ChrisRenfrow opened this issue Jan 11, 2023 · 5 comments
Closed

Add support for the contents of yew's html! macro #172

ChrisRenfrow opened this issue Jan 11, 2023 · 5 comments

Comments

@ChrisRenfrow
Copy link

ChrisRenfrow commented Jan 11, 2023

Yew, a front-end web-framework for Rust similar to React, contains a html! macro for writing HTML and SVG code declaratively. I believe it makes sense to add support for these blocks in tree-sitter-rust, just as tree-sitter-javascript supports JavaScript syntax extension (jsx) to a similar end.

Here is Yew's documentation on how the grammar within html! differs from proper HTML.

While I've never written my own tree-sitter grammar, I am more than willing to take-on the implementation of this enhancement. If anybody has some time to spare I would appreciate some pointers on how to get started, otherwise I'm sure I can manage on my own. :)
My availability has changed since I proposed this change and I can no longer contribute as I had offered.

@carloskiki
Copy link

I think this could be even more general and work with the syn_rsx crate for example. I have never written any tree-sitter grammar and I don't know how we would detect when rsx/html is used. I know multiple rust web frameworks would benefit from this.

@amaanq
Copy link
Member

amaanq commented Apr 1, 2023

It's popular, sure, but not something to be added in the main grammar. You can try to implement injections similar to how nvim-treesitter does it instead

If this were to be added, then adding every other "style" of macros for any semi popular lib will be advocated for as this would set a precedence. So for that reason, it shouldn't be added

@igor-ribeiro
Copy link

@ChrisRenfrow can you share your grammar?

@ChrisRenfrow
Copy link
Author

My apologies, I haven't started anything in regards to this issue and I don't have the time to contribute as I previously indicated. If anyone with the time to commit to this task would like to pick it up they're more than welcome to do so!

@igor-ribeiro
Copy link

@ChrisRenfrow actually, my bad, I read "While I've HAVE written my own tree-sitter grammar..." 🤦🏽‍♂️

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

No branches or pull requests

4 participants