19

GitHub uses something known as the "GitHub Flavored Markdown" for messages, issues and comments. My questions are:

  • Does GitHub also use this syntax for their Wiki?
  • 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)

1
  • Both C and c should work.
    – pchaigno
    Commented Aug 20, 2017 at 19:28

3 Answers 3

10

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

1
  • 2
    GitHub used Pygments for syntax highlighting at a time, but the list of lexers from Pygments never fully matched the list of available lexers in GitHub. GitHub now relies on Sublime Text, Atom, and TextMate grammars for syntax highlighting. See 3D1T0R's answer for the list of lexers available.
    – pchaigno
    Commented Aug 14, 2017 at 20:15
6

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.

2

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:

  1. The language name
  2. Any of the language aliases
  3. Any of the file extensions, with or without a leading ..

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.