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

merge 2 prs together #15

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

merge 2 prs together #15

wants to merge 11 commits into from

Conversation

srghma
Copy link

@srghma srghma commented Aug 19, 2020

This pr just contains merged:

NOTE: the changes #14 to Parsing.hs were not needed actually, the #8 already has the same functionality plus handles nested blocks, but I have merged the changes to test files from it anyway

then I have updated the stack version

jgm and others added 11 commits June 27, 2015 23:00
I left out the `@` on media queries.
This also adds a "resize" to limit the size of the structures,
which can now be nested beyond two levels.
This allows the tests amended by yesodweb#7 and yesodweb#8 to pass again.

* Simplified parsing of nested blocks.
* Indefinite nesting levels are now allowed.
* Some illegal CSS that was allowed by the old parser is now
  excluded (e.g. `@print { background: red; }`).
Testing with GHC 7.10 has its drawbacks!
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!).
@srghma
Copy link
Author

srghma commented Aug 19, 2020

I should tell that #8 does not actually fix the nested blocks test

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

Successfully merging this pull request may close these issues.

2 participants