Open futursolo opened 2 years ago
Detecting spaces in token-trees is a hard thing to do. I think the best course right now is to heavily document this. A simply workaround without ambiguity (I think) and not having to detect the space is to prefer the following syntax:
.class-a *.class-b {
color: blue
}
which is actionable and could be implemented to act correctly (possible have to adjust fragment_spacing
). Also, in nightly rust, this can be detected. To give another example where also spacing mucks up the current implementation, although I can't think of an actual css that uses it:
prop: ident --ident;
// ------------- parsed as a single identifier `ident--ident`
Same underlying reason that it's not possible to detect the spacing in stable rust.
This issue is mitigated in #42.
The proper solution requires https://github.com/rust-lang/rust/issues/54725 to become available in stable Rust.
Proc macro's source_text
has been stabilized, so this might be feasible to implement now. At least recognizing spaces is now no problem any longer.
For the following stylesheet:
For inline syntax, the input above yields the following stylesheet:
After consulting the documentation of
proc_macro2
, I am not sure what's the best course of action to solve this issue. (I don't think possible to detect spaces betweenIdent
andPunct
.)@WorldSEnder Any ideas?