Correctly serialize the <an+b> type
gherkz opened this issue · 3 comments
I'm not 100% sure what the extra empty comments are for in the serializer (something about BAD_PAIRS it seems, whatever they are):
tinycss2/tinycss2/serializer.py
Line 111 in 0268a60
These seem to get added in the following sample:
tinycss2.serialize(tinycss2.parse_stylesheet('div:nth-child(2n+1){}'))
Which results in
div:nth-child(2n/**/+1){}
This is clearly not the desired output. It would be nice if this feature was disabled by default. It could probably even be removed altogether - I can't imagine anyone is relying on these empty comments for anything.
Hi!
This extra empty comment is actually required by the specification, when we find two tokens that shouldn’t be next to each other (that’s what bad pairs are). So, we won’t remove these extra comments added by the serializer
But.
I don’t know why 2n+1 is a bad pair. Maybe the "problem" is here, I have to check that more deeply.
I don’t know why 2n+1 is a bad pair. Maybe the "problem" is here, I have to check that more deeply.
That’s because the an+b syntax used to be described with a dedicated tokenizer. But an <an+b> type is now available, tinycss2 should use its dedicated serialization.