Comments (5)
Thanks, I got the code working and tried putting my test snippet inside a "issue88.css"-file (not sure which directory would be correct though) and at the end of CSSReader30FuncTest.testSpecialCasesAsString()
(seemed like the better option as is was easier to debug).
// Issue 88
sCSS = ":where(.some-tile:not(.preserve-color))>*{color:#161616}";
aCSS = CSSReader.readFromStringReader (sCSS, aReaderSettings);
assertNotNull (aCSS);
assertEquals (":where(.some-tile:not(.preserve-color))>*{color:#161616}", new CSSWriter (aWriterSettings).getCSSAsString (aCSS));
I'm guessing that the solution lies inside src/main/jjtree/ParserCSS30.jjt
file inside void pseudo() : {}
where the part:
| LOOKAHEAD( <FUNCTION> )
<FUNCTION> { jjtThis.appendText (token.image); }
( <S> )*
( expr() )?
<RROUND> // do not append because of expression!
should look more like:
void negation() : {}
{
<FUNCTION_NOT> { jjtThis.setText (":not("); }
( <S> )*
( selector ()
( <S> )*
( <COMMA>
( <S> )*
selector()
( <S> )*
)*
)?
<RROUND>
}
(with the selector ()
part).
Either that or different extra functions are needed for ":where()", ":is()", and ":has()" which have different semantics than the other pseudo elements like ":hover".
As I'm not really knowledgeable about JavaCC and I suspect this might be a rather more involved fix, I'll probably won't be able to do much more at this point? (sorry)
Update: changed "issue107" to "issue88" (107 was for another project).
from ph-css.
Well, the CSS grammar is constantly evolving, and it seems like the support for :where
needs improvement.
Relevant links:
- https://drafts.csswg.org/selectors/#zero-matches
- https://developer.mozilla.org/en-US/docs/Web/CSS/:where
Edit: the parser itself is generated, and you need to add target/generated-classes
into your build path, to get the generated classes too
from ph-css.
Thanks for going so far - I will see what I can do, even though my resources for this are currently quite limited :/
from ph-css.
No problem, that's normal :-).
I was trying to ignore the error (I'm only interested in url content) and played around with:
final CSSReaderSettings result = new CSSReaderSettings().setCSSVersion(ECSSVersion.LATEST);
// When parsing fails null is returned by the framework and NullPointerExceptions can arise later on.
result.setCustomExceptionHandler(new ThrowingCSSParseExceptionCallback());
// Not needed for our purposes for now:
// result.setCustomErrorHandler(new ThrowingCSSParseErrorHandler());
// result.setInterpretErrorHandler();
But only the ExceptionHandler is called in this case (so none of the ErrorHandlers). I expect this sort of "problem handling" to be generated by JavaCC, so I'll probably need to do some preprocessing on failing css files to tweak them in a way that the parser won't choke on its content.
from ph-css.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from ph-css.
Related Issues (20)
- :not Selector parsed incorrectly HOT 2
- Unexpected rule '@': Unknown rule in the middle of a rule-set is not allowed! HOT 4
- Previous sibling selectors incorrectly parsed without whitespace HOT 12
- Unable to add declarations where property contains "--" or "@" HOT 3
- Strange exception when creating own shorthand descriptors HOT 2
- :lang with empty expression list parsed incorrectly HOT 3
- :host and ::slotted pseudo class/element functions are parsed incorrectly (used in shadow DOM) HOT 2
- Semantic distinction between an IDENT and a STRING within the CSSExpressionMemberTermSimple HOT 6
- :host and ::slotted parsing sort of wrong HOT 6
- CSSReaderDeclarationList missing methods to pass in CReaderSettings as argument HOT 1
- Scientific number notation not supported by parser HOT 4
- Add :host-context pseudo class function to the Parser HOT 3
- Scientific notation can also contain '.' HOT 7
- *IDENT (<=IE6 hack) in style declaration block, drops all declarations after this one (in browser compliant mode) HOT 7
- :nth-child(expr) is parsed as CSSSelectorSimpleMember HOT 1
- Support `@supports` HOT 1
- CSSParserHelper.unescapeURL not following the css escape diagram HOT 7
- Support for CSS nesting module HOT 3
- Can't parse Bulma 1.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ph-css.