githubgithub-linguist

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?


Solution

  • 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.