AdguardTeam / AdguardTeam/VscodeAdblockSyntax

Implement a CSS syntax highlighter

Offen
#89 4 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
feature request Priority: P4 T: syntax highlighter
Vorherrschende Sprache
TypeScript
Sterne
88
Forks
8
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

A lot of adblock filter rules use CSS, so we should consider implementing a good CSS highlighter according to our goals (this doesn't necessarily mean full CSS support, e.g. we don't have to support comments).

The benefits of this are:
- Make CSS-based cosmetic rules much more transparent
- it improves maintainability
- it makes the rules clearer for those who don't have much experience in writing rules
- Many incorrect selectors can be marked as invalid even at the highlighter level

Because of "Extended CSS syntax", we should definitely think about creating our own highlighter, rather than integrating an existing CSS highlighter. In addition, this will ensure consistent results, since VSCode doesn't use the same CSS scope as GitHub.

I started implementing this earlier (last year), here is a demo of what it would look like:

![image](https://user-images.githubusercontent.com/57285466/235619213-b3d9c74a-1286-4b11-8eee-34aba16309b3.png)

In the case of CSS injection rules, [at-rules](https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule) and [declaration block](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/CSS_Declaration_Block) should also be handled, but the development can be done step-by-step, so e.g. in the first round, we only implement the CSS selectors for element hiding rules.

Reference:
- https://www.w3.org/TR/selectors-3/
- https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors
- https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
- https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/CSS_Declaration_Block
- https://github.com/AdguardTeam/ExtendedCss
- https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.