10

I asked support@github.com; this is their reply: We use Pygments (http://pygments.org/) to do syntax highlighting and determine which lexer to use based on each file's extension. So unfortunately, it doesn't look like there's a way to get C++ highlighting without renaming the files from *.c -> *.cpp and *.h -> *.hpp. You can do this without losing ...


8

GitHub's language detection is done by the Linguist module, which is conveniently open source. It relies primarily on the file extension to detect the language, although it can be a bit clever to detect ambiguous files (such as .h files). As you can see from the configuration file, .c is firmly defined as a C file. Given the number of files that have to be ...


4

For files with a Shebang, the Shebang is considered when determining the language but seems to be evenly weighted against other tokens. This seems to be a big error because the Shebang should definitively define the language of the file. This can cause issues with highlighting. As a workaround you can add dummy tokens in the form of a comment to "tip the ...


3

You can now force the language of any file in your repositories using Linguist overrides. Linguist is the open source library detecting the language of files across github.com. To force your .c files to be highlighted using the C++ grammar, you can add the following in your .gitattributes file: *.c linguist-language=C++


2

Sharing my answer here I discovered elsewhere on SO. I discovered that you can add a vim or emacs modeline per the Linguist readme to the top of your source file (unfortunately, required for each file) to coerce syntax highlighting for Github.com. Based on the languages.yml file, I think you'd need to add /* vim: syntax=C++ */ to your source file.


1

Here is a list of different brushes that you can add to the script to support several other languages, among which are batch files (bat, cmd, batch): http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/


1

I tried Method 2, using my Blogger account. I have a fairly complicated template, so I added the scripts just below the title tags in the HTML header. It worked without any problems for me. Perhaps you have a setting in your browser that prevents JavaScript from running? I viewed my Blogger post in FireFox. Keep in mind that each time you load your ...


1

Please read the following: http://ramblings.mcpher.com/Home/excelquirks/gaspublish. Bruce McPherson created a way to integrate Google Prettify into Google Apps Script (GAS) allowing code to be prettified using an iFrame. The code can be collected from many places, like Github, within GAS, ScriptDb. You're already familiar with the usage of a public ...


Only top voted, non community-wiki answers of a minimum length are eligible