On Sun, 27 Mar 2022, Alexey Torgashin via fpc-pascal wrote:
@Michael Van Canneyt
I didn't test but I hope this package can parse this _minified_ CSS file?
Minified or not is normally not relevant for parsing.
Attached on the forum
https://forum.lazarus.freepascal.org/index.php/topic,58853.msg438550.html#msg438550
It has many tricks. E.g. @media blocks (@media supports nested blocks, not
only 1 level), e.g. {} block for N classes, e.g. weird class names.
Nested blocks are supported.
But weird class names:
extractcssclasses brackets.min.css -o out
Exception at 00000000004C107B: ECSSParser:
Error: line 9, pos 18: Unexpected token: Got ctkIDENTIFIER (as UTF8String:
"zoom"), expected: ctkCOLON .
"*zoom", really ? That's not even valid CSS syntax.
I checked 2 EBNF grammars: neither will allow this.
I checked the W3 spec: Confirms this is simply not valid syntax.
Browsers are simply very forgiving for all the junk found in CSS files:
The CSS syntax is so sloppy, almost impossible to cover all cases.
That's why there are a lot of test files.
But patches to make the implementation more forgiving are welcome.
I suppose things like *zoom can be easily supported.
Do you have the unminified file ? So I can see how to interpret the '*zoom':
treat as '* zoom' or as identifier '*zoom'
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal