Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Language Savant
Branch: master
Pull request Compare This branch is 3709 commits behind github:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.




Language detection



For disambiguating between files with common extensions, we use a bayesian classifier. For an example, this helps us tell the difference between .h files which could be either C, C++, or Obj-C.



Syntax Highlighting

The actual syntax highlighting is handled by our Pygments wrapper, pygments.rb. It also provides a Lexer abstraction that determines which highlighter should be used on a file.

We typically run on a prerelease version of Pygments, pygments.rb, to get early access to new lexers. The lexers.yml file is a dump of the lexers we have available on our server.


The Language Graph you see on every repository is built by aggregating the languages of all repo's blobs. The top language in the graph determines the project's primary language. Collectively, these stats make up the Top Languages page.

The repository stats API can be used on a directory:

project.languages      #=> { "Ruby" => 0.98,
                             "Shell" => 0.02 }


$ bundle exec linguist lib/
100%  Ruby

Ignore vendored files



Generated file detection


See Linguist::BlobHelper#generated?.

Installation is usually running the latest version of the github-linguist gem that is released on

But for development you are going to want to checkout out the source. To get it, clone the repo and run Bundler to install its dependencies.

git clone
cd linguist/
bundle install

To run the tests:

bundle exec rake test


The majority of patches won't need to touch any Ruby code at all. The master language list is just a configuration file.

Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under samples/ in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions.


Sometimes getting the tests running can be to much work especially if you don't have much Ruby experience. Its okay, be lazy and let our build bot Travis run the tests for you. Just open a pull request and the bot will start cranking away.

Heres our current build status, which is hopefully green: Build Status

Something went wrong with that request. Please try again.