Reputation: 96274
GitHub uses something known as the "GitHub Flavored Markdown" for messages, issues and comments. My questions are:
From what I understand one can specify the programming language for syntax highlighting using the following syntax:
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
Where one can specify the programming language after the ```
string (e.g. ```ruby
)
My question is: How do I look up the specifier for a programming language? (e.g. C
does not seem to work for the C programming language)
Upvotes: 20
Views: 10599
Reputation: 13103
How do I look up the specifier for a programming language?
The up-to-date list of language specifiers can be deduced from the main configuration file of the Linguist repository, languages.yml
. For each language in that list, you can use as specifiers:
aliases
.
.White spaces must be replaced by dashes (e.g., emacs-lisp
is one specifier for Emacs Lisp
). Languages with a tm_scope: none
entry don't have a grammar defined and won't be highlighted on github.com.
jmm made this reverse engineering effort and received confirmation from one of GitHub's engineers. He opened an issue with all the information on Linguist and maintains a wiki page with the specifiers for all languages (which might not be up-to-date).
Does GitHub also use this syntax for their Wiki?
Yes, but github.com's wikis also supports several other formats. You can find the complete list on the markup repository.
Upvotes: 2
Reputation: 1060
Quoting GitHub's documentation on the subject:
We use Linguist to perform language detection and syntax highlighting. You can find out which keywords are valid in the languages YAML file.
Linguist's "Grammar index" may prove also useful.
Upvotes: 6
Reputation: 11730
For a list of the possible lexers that github wiki can use see here: http://pygments.org/docs/lexers/
If you find that a certain lexer is not supported, github recommends forking their code and submitting it via a pull request: https://github.com/blog/774-git-powered-wikis-improved
Upvotes: 10