Syntax highlighting in the GitHub Wiki: specifying a programming language

GitHub uses something known as the “GitHub Flavored Markdown” for posts, questions and comments. My questions:

  • Does GitHub use this syntax for its wiki?
  • From what I understand, you can specify a programming language for syntax highlighting using the following syntax:

    ```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ``` 

    Where can I specify the programming language after the line ``` (for example, ```ruby )

    My question is: How to find a qualifier for a programming language? (e.g. C does not seem to work for the C programming language)

+8
github markdown github-linguist
source share
3 answers

List of possible lexers that can be used on the github wiki: http://pygments.org/docs/lexers/

If you find that a particular lexer is not supported, github recommends formatting your code and sending it using the transfer request: https://github.com/blog/774-git-powered-wikis-improved

+6
source share

GitHub Documentation Related :

We use Linguist to define the language and syntax highlighting. You can find out which keywords are valid in the YAML language file .

Linguist " Grammar Index " may be helpful.

+3
source share

How to look for a qualifier for a programming language?

An updated list of language qualifiers can be deduced from the main configuration file of the Linguist repository , languages.yml . For each language in this list, you can use as qualifiers:

  • Language name
  • Any language aliases
  • Any file extension, with or without a host . .

White spaces should be replaced by dashes (for example, emacs-lisp - one specifier for Emacs Lisp ). Languages ​​with the tm_scope: none entry tm_scope: none not have a specific grammar and will not be highlighted on github.com.

jmm made this reverse engineering effort and received confirmation from one of the GitHub engineers. He discovered a problem with all the information about Linguist and maintains a wiki page with qualifiers for all languages (which may not be relevant).

Does GitHub use this syntax for its wiki?

Yes, but github.com wikis also supports several other formats. You can find the complete list of markup repository .

+1
source share

All Articles