Seb Nilsson
Seb Nilsson

Reputation: 26448

Using syntax highlight from GitHub

What syntax highlighting is used on GitHub (for HTML, CSS, JavaScript, C#) when viewing source code-file and is it available for the public to use?

It works on the page and it works when embedding on a page (from a Gist), like this:

<script src="https://gist.github.com/1009439.js"></script>

But can I just include their JavaScript-library and let it highlight my code?

Upvotes: 35

Views: 20504

Answers (5)

Rory O&#39;Kane
Rory O&#39;Kane

Reputation: 30428

According to this help page, GitHub currently highlights syntax with the open-source Linguist library for Ruby. Linguist highlights each language using the tmLanguage files linked in vendor/grammars.

Since Linguist is written in Ruby, it can only be used on the server. If you want a client-side JavaScript library that you can just include on a page, you will have to find a different library.

Upvotes: 21

Paweł Gościcki
Paweł Gościcki

Reputation: 9634

As others have said previously, GitHub uses Pygments. You can achieve the same effect by using it together with pygments-style-github.

Upvotes: 1

raid5ive
raid5ive

Reputation: 6642

I believe they use their albino gem. It is a Ruby wrapper for the pygments syntax highlighter.

Here is an article of a comparison I read recently on javascript based syntax highlighters (if that is what you need): http://softwaremaniacs.org/blog/2011/05/22/highlighters-comparison/

Upvotes: 2

Stephen Diehl
Stephen Diehl

Reputation: 8439

Github uses pygments to highlight syntax. Pygments is running on the server, instead of a pure Javascript client solution. If you're looking for a Javascript solution check out this review of the various options.

Upvotes: 43

Fredrik
Fredrik

Reputation: 2016

According to this: http://www.infoq.com/news/2008/03/github-git-repository-hosting

they are using Python Pygments

Chris Wanstrath shared some information about the inner workings of GitHub with InfoQ:

GitHub is mostly implemented in Rails. The post-commit integration mini-apps we're working on are all written in Merb, we use the Python Pygments for syntax highlighting, and we use Ara T. Howard's Bj plus some Ruby scripts for our queueing system. And, of course, we use the Ruby Grit library to interface with Git.

Upvotes: 5

Related Questions