parallel_resistance
parallel_resistance

Reputation: 155

Is There Any Way to Disable Error Highlighting in Github?

Github highlights the second % in this line as an error:

fscanf(fp, "%d%*[^\n]\n", &ints[i]);

However, the code compiles perfectly and the removing the 'error' will cause the program to function incorrectly.
Is there any way to either disable this error highlighting or make Github recognize it as correct?

Upvotes: 3

Views: 1226

Answers (2)

VonC
VonC

Reputation: 1323753

Update: pchaigno points out in the comments the section linguist#Overrides, where you can use for instance .gitattributes:

Add a .gitattributes file to your project and use standard git-style path matchers for the files you want to override to set linguist-documentation, linguist-language, linguist-vendored, and linguist-generated. .gitattributes will be used to determine language statistics and will be used to syntax highlight files. You can also manually set syntax highlighting using Vim or Emacs modelines.

$ cat .gitattributes
*.rb linguist-language=Java

Original Answer Jan. 2017

Since you cannot easily remove the GitHub highlight, you can try and use a similar workaround I suggested in "How to fix/ignore syntax error in github"

Try and add on the same line a comment with a '%' in it, in order for the lexer (used by the syntax highlighting engine Rouge and Pygment) to not propagate the "error" to all subsequent lines.

Upvotes: 3

pchaigno
pchaigno

Reputation: 13063

To complete VonC's answer, if you think the highlighting is incorrect, you can actually file a bug report or even fix it; All grammars github.com uses are open source!

How to find the grammar? To find the grammar used for syntax highlighting in your case, you can visit this page on the Linguist project. In front of each language (looks like C in your case), you'll find the repository where the grammar for that language lives (for C, github.com/textmate/c.tmbundle). You can open an issue there with your failing test case, or even better, try and fix it yourself.

Upvotes: 1

Related Questions