35

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?

5 Answers 5

43

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.

Sign up to request clarification or add additional context in comments.

3 Comments

The funny thing is though GitHub uses pygments, pygments doesn't use GitHub. They're on Bitbucket
Could that be because they used Pygments from the get go when creating Github? Which would mean that Pygments would have to have been hosted elsewhere considering Github did not yet exist.
Github no longer uses pygments. It now uses a Ruby package called "Linguist" that can process TextMate-compatible highlighting grammers, See github.com/github/linguist
21

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.

Comments

5

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.

1 Comment

Pygments is used by a bunch of things, including Trac. It's cool.
2

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/

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.