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

Enable syntax highlighting for AdBlock filter files #72

Merged
merged 1 commit into from
Sep 10, 2022
Merged

Enable syntax highlighting for AdBlock filter files #72

merged 1 commit into from
Sep 10, 2022

Conversation

Alhadis
Copy link

@Alhadis Alhadis commented Sep 10, 2022

Support for AdBlock filter lists was recently added to GitHub Linguist. However, only .txt files beginning with an obvious-looking header are classified as filter-lists, which rules out most/all of the filter-lists in this repository.

This PR adds an override to declare the language of this project's .txt files explicitly.

(Note that adding/updating a .gitattributes file won't affect a project's language classification until another commit is pushed, which forces GitHub to recalculate the repo's language stats)

@hacamer hacamer merged commit 76a89b9 into Cats-Team:main Sep 10, 2022
@hacamer
Copy link
Contributor

hacamer commented Sep 10, 2022

@Alhadis Thank you for your suggestion. By the way,

 /script/**/*.txt -adb
/rules/fasthosts.txt -adb

What does "-adb" mean?

@Alhadis
Copy link
Author

Alhadis commented Sep 10, 2022

@hacamer adb is the name of the custom attribute I defined on this line:

[attr]adb linguist-language=AdBlock linguist-detectable

Basically, all this does is create an alias for linguist-language=AdBlock linguist-detectable so it's easier to set those attributes on multiple filenames: 

Without a custom attribute:
*.txt linguist-language=AdBlock linguist-detectable
/script/**/*.txt -linguist-language -linguist-detectable
/rules/fasthosts.txt -linguist-language -linguist-detectable
With a custom attribute:
[attr]adb linguist-language=AdBlock linguist-detectable
 
*.txt adb
/script/**/*.txt -adb
/rules/fasthosts.txt -adb

-adb simply unsets the attributes that adb is aliased to. It's the same syntax used to unset other gitattributes.

See gitattributes(5) for the syntax's full details.

@Alhadis Alhadis deleted the fix-highlighting branch September 10, 2022 06:53
@hacamer
Copy link
Contributor

hacamer commented Sep 10, 2022

@hacamer adb is the name of the custom attribute I defined on this line:

[attr]adb linguist-language=AdBlock linguist-detectable

Basically, all this does is create an alias for linguist-language=AdBlock linguist-detectable so it's easier to set those attributes on multiple filenames: 

Without a custom attribute:

*.txt linguist-language=AdBlock linguist-detectable
/script/**/*.txt -linguist-language -linguist-detectable
/rules/fasthosts.txt -linguist-language -linguist-detectable

With a custom attribute:

[attr]adb linguist-language=AdBlock linguist-detectable
 
*.txt adb
/script/**/*.txt -adb
/rules/fasthosts.txt -adb

-adb simply unsets the attributes that adb is aliased to. It's the same syntax used to unset other gitattributes.

See gitattributes(5) for the syntax's full details.

@Alhadis thank you!

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