Sphinx: List of supported languages for highlighting?

10,817

Solution 1

As far as I can tell, the list is in the file pygments/lexers/_mapping.py, in the (autogenerated) dictionary LEXERS. In my copy, I see a line

'ObjectiveCLexer': ('pygments.lexers.compiled', 'Objective-C', ('objective-c', 'objectivec', 'obj-c', 'objc'), ('*.m',), ('text/x-objective-c',)),

I think this should mean that any of the tags objective-c, objectivec, obj-c, or objc should work, as long as your version of Pygments is up-to-date. They work for me.

Solution 2

pygmentize -L lexers lists all supported lexers.

Solution 3

If you install pygments module. You can use this script to get a list of supported highlighters:

from pygments.lexers import get_all_lexers

lexers = get_all_lexers()
for lexer in lexers:
        print "-\t" + lexer[0] + "\n"
        print "\t-\t" + "\n\t-\t".join(lexer[1]) + "\n"

First indent level of output will be general name and second level will be short names of highlighters that you can use.

Example Output

  • Debian Sourcelist

    • sourceslist
    • sources.list
  • Delphi

    • delphi
    • pas
    • pascal
    • objectpascal

Source

Share:
10,817
Nic Foster
Author by

Nic Foster

Game Developer Companies I've worked with: NetDevil, Gazillion, LEGO, Dire Wolf Digital, Backflip Studios, and Scopely. Languages I know well: C#, C++, Lua. Some knowledge: C, Scala, Java, ActionScript 2.0, Python, HTML. Currently using: C#. Game and Physics Engines I know well: Unity 5.x, GameBryo, QuickStart Engine, Havok, JigLibX. Some knowledge: Orge3D. Currently using: Unity 5.x. APIs, IDEs, and Misc I know well: XNA, Visual Studio, VS Code, IntelliJ IDEA, Git, Perforce. Passing familiarity: ScaleForm, RakNet, TortoiseSVN. Currently using: JetBrains Rider on MacOS.

Updated on June 15, 2022

Comments

  • Nic Foster
    Nic Foster about 2 years

    I'm using Sphinx for code documentation and use several languages within the code, I would like to setup highlighting for all of that code. Sphinx briefly mentions a few of the languages it supports (on this page), and then mentions that it uses Pygments for lexical analysis and highlighting. Sifting through the documentation for both Sphinx and Pygments yielded me no clue on how to do something like highlight objective-c code.

    Pygments does mention the list of languages it supports, here, however that doesn't tell me the exact syntax that I must use within Sphinx (.rst files) to tell the code block to highlight for a specific language. For example, to highlight c++ code you simply use this before your code block:

    .. highlight:: c++

    However after trying these I cannot seem to highlight Objective-C code:

    .. highlight:: Objective-C
    .. highlight:: objective-c
    .. highlight:: Obj-C
    .. highlight:: obj-c
    

    Can anyone supply me with the list of languages (as you would refer to them within documentation)?

  • Ben
    Ben over 5 years
    Wow, best answer by far. I wasted plenty of time with the first two before I noticed this one.