Closed DandelionSprout closed 1 year ago
I have very low understanding of the file syntax
This is a TMLanguage file that tokenizes the source code using regexp's (the "color" depends on the type of token you return and also on the color scheme the editor uses). It is also used by VSCode and GitHub. If you are interested, the basic philosophy is well described in the following link: https://macromates.com/manual/en/language_grammars In this repo we have described it in JSON syntax, but of course other syntax can be used, e.g. YML, etc. In the future, I would like to convert it to a different format to make it more maintainable.
Regarding to the issue, currently the host rules aren't supported by the highlighter (TMLanguage) or the linter (AGLint).
@ameshkov what do you think? Should we add support for host rules? This would mean development in two directions:
hostRule
(or something) entry to TMLanguage to support highlightingHostRuleParser
module should be added to the AGLint's parser
Tbh, I don't think we should add any special handling for hosts rules, they're too different. Besides, I generally do not support using that syntax for content blocking purposes :)
Also, there's already an add-on that add /etc/hosts
syntax support to VS code:
https://marketplace.visualstudio.com/items?itemName=tommasov.hosts
While I have very low understanding of the file syntax of https://github.com/ameshkov/VscodeAdblockSyntax/blob/master/syntaxes/adblock.tmLanguage.json, I like the red and blue text colours in the syntax (as it's being used in GitHub's online file editor) enough that I wonder if Hosts entries could be given such colours too?
If we for instance take
127.0.0.1 adbox.lt www.adbox.lt
from https://github.com/EasyList-Lithuania/easylist_lithuania/blob/master/EasyListLithuaniaHosts.txt, then I imagine the127.0.0.1
part could be given a red colour.The pattern to match would be something like
^((\d{1,3}\.){3}\d{1,3}|[0-9a-fA-F:]{2,72}) {1,}[a-z0-9-]{1,}\.[a-z0-9-].*
, but I'll probably have to leave the "patterns/name" stuff to you guys.