AdguardTeam / AdguardTeam/VscodeAdblockSyntax

Implement a CSS syntax highlighter

未关闭
#89 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
feature request Priority: P4 T: syntax highlighter
主要语言
TypeScript
星标
88
派生
8
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。