Open pepsighan opened 6 years ago
Mmm I have been playing with web-sys too, trying to build something similar to Ruukh :). I ended up writing a parser for html in nom, which works quite well except I can see it's not going to parse rust code inside { }'s very easily...
I wonder if we make some noise in https://github.com/dtolnay/syn/issues/406 whether there's much hope on that becoming stable
@davidhewitt Yeah, plugging nom with syn is going to be difficult and also preserving Span
information is of utmost importance so that we can report errors.
syn
is not the one to stabilize line informations, I think it's proc-macro2
.
Hi @csharad, I don't know how feasible to implement this in your project. I tried this with my own project, but finally I prefer strings in "..."
than not. There are only two more characters to type, and also you don't have to invest your time trying to implement it. My reason is that in a large code in html!{...}
, if you put strings in "..."
, with the help of the editor highlighting, they stand out clearly. It helps to distinct/spot out items more easily. Without the "..."
, editors highlight them as identifiers
, punct
... which they are not, make it hard for to find out things we want.
@limira while I definitely see the benefits of the approach you've taken in Simi, my own preference is to have a syntax as close to HTML as possible. Though I concede that to support nice highlighting inside the html! macro will then need extra editor grammar added, I think sticking to HTML syntax gives users of the api a sense of familiarity.
I suspect this is one of those things that's a matter of everyone's individual preferences; both styles have their merits!
@davidhewitt, yeah, because I don't want to stay close to HTML hence I gave up the idea more easily. If you want to stick with HTML, in a .rs
file, (along with the highlighting) you should consider about auto close tag. I mean when users type <div>
then </div>
should be added automatically for the user to feel it's home.
@limira As @davidhewitt has said, html!
macro will try to keep the syntax as close to HTML as possible for familiarity reasons.
html! macro uses literal strings to define texts which is quite cumbersome.
It would be HTML like if we could lift this requirement.
But to implement that we need to get location info from
Span
s ofproc-macro2
which is underprocmacro2_semver_exempt
. So, we'll need to wait on that for the time being.