-
Notifications
You must be signed in to change notification settings - Fork 279
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
feat: check existence and type of labels in Style selectors #777
Conversation
Deploying with Cloudflare Pages
|
Codecov Report
@@ Coverage Diff @@
## main #777 +/- ##
==========================================
- Coverage 65.56% 65.40% -0.16%
==========================================
Files 53 53
Lines 7939 7978 +39
Branches 1460 1409 -51
==========================================
+ Hits 5205 5218 +13
- Misses 2725 2751 +26
Partials 9 9
Continue to review full report at Codecov.
|
Ah so you changed |
Yep! Still puzzling why there's a distinction in the first place, but yeah it's better to have static errors when types change, instead of these weird exceptions. I'm just change them as I go. There are a lot more in the repo. Maybe do a full pass later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 👍
Description
Closes #774
In this PR, we introduce a new Style selector pattern:
X has <math|text> label
. When included in thewhere
clause of a selector, the compiler checks iflabel
exists and whether it matches with the specified descriptor. Examples:Label x $\vec{x}$
will match withwhere x has math label
Label x "xxxx"
will match withwhere x has text label
where x has label
NoLabel x
will not match withwhere x has label
norwhere x has math/text label
Error handling:
math
andtext
are valid field descriptors. All others will result in parse errorslabel
is the only field name allowed, but instead of throwing a parse error, the compiler reportsSelectorFieldNotSupported
error:Implementation strategy and design decisions
rel_field
rule in the Style parserRelField
type in the Style compilerlabelMap
x
and the label existence and type during selector matchingExamples with steps to reproduce them
Checklist
yarn test
yarn docs
and there were no errors when generating the HTML siteOpen questions
There's no infrastructure for testing selector matching results, so we are not including tests for checking selector matching results.