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

Support @supports {rule} in mapcss #2081

Merged
merged 4 commits into from
Nov 21, 2023
Merged

Conversation

Famlam
Copy link
Collaborator

@Famlam Famlam commented Nov 19, 2023

Adds basic support for @supports {} blocks in mapcss

It doesn't really parse the @supports conditions, that would be:

  1. Unnecessary difficult :)
  2. Give dilemma's, e.g. we try to mimic JOSM's parsing, so should we return true or false on user-agent: josm?

Instead, it checks if there is a -osmoseItemClassLevel property present, and only if so, it assumes it's safe for Osmose. All other (possibly unsafe) rules are discarded.

Note that the regeneration of mapcss didn't add new rules to transport.validator.mapcss because last time the rule that is now in @supports was already present; it was just not in a @supports context. (See this old-new comparison)

Note on the changes in the *.g4 file: the whitespace after the SUPPORTS_NOT must be present. If not, antlrs generated file will detect the not in i.e. *[not:name][name]["not:name"=*"name"], from plugins/notprefix.validator.mapcss as such a SUPPORTS_NOT, failing to compile after that. (This also happens with set, but as we don't have rules with *[set* it doesn't cause issues). If you want to avoid this, we have to move these fixed string rules (SUPPORTS_NOT, SUPPORTS_AND, SUPPORTS_OR, and SET) to the end of the g4 file (although I didn't check yet if this causes other issues for set).

See #2077

Parse syntax of `@supports` following the specifications of CSS3 (which are followed by mapcss)

`supports_declaration` is simplified as I don't intent to actually parse it, but it should be able to handle all grammar that JOSM supports
All rules in `@supports` blocks are dropped unless `-osmoseItemClassLevel` is set.

Also adds tests
@frodrigo
Copy link
Member

Ok. Thank you.

@frodrigo frodrigo merged commit 18c54db into osm-fr:dev Nov 21, 2023
3 checks passed
@Famlam Famlam deleted the mapcss-supports branch November 21, 2023 19:41
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