This is a stopgap measure to enable this library to parse e.g. Bootstrap
4.3.1.
The problem can be illustrated by the example:
1 | @media {
2 | foo {}
3 | }
4 | bar {}
nestedParse parses the first block inside a nested block on its own,
(in this case: foo {}), then uses blocksParser to read the rest. The
previous version of blocksParser is too greedy and consumes everything
until the next '{'. In this case: } bar becomes a "selector", the bar
block becomes the next "subblock" of @media and the "absent" '}' for
@media { fails parsing.
This patch uses '}' as a character that is highly unlikely to happen
inside a selector (although it's still possible, e.g. [attr="}"]) and
highly likely to terminate one-block @-blocks.
Previously, css-text failed on Bootstrap 4.3.1 at the 94th block, now it
can parse all of its >1200 blocks (not completely correctly, but rather
fine for CSS and such a tiny library!).
This is a stopgap measure to enable this library to parse e.g. Bootstrap 4.3.1.
The problem can be illustrated by the example:
nestedParse
parses the first block inside a nested block on its own, (in this case:foo {}
), then usesblocksParser
to read the rest. The previous version ofblocksParser
is too greedy and consumes everything until the next '{'. In this case:} bar
becomes a "selector", thebar
block becomes the next "subblock" of@media
and the "absent" '}' for@media {
fails parsing.This patch uses '}' as a character that is highly unlikely to happen inside a selector (although it's still possible, e.g.
[attr="}"]
) and highly likely to terminate one-block @-blocks.Previously, css-text failed on Bootstrap 4.3.1 at the 94th block, now it can parse all of its >1200 blocks (not completely correctly, but rather fine for CSS and such a tiny library!).