Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx: List of supported languages for highlighting?

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)?

like image 693
Nic Foster Avatar asked Jul 03 '12 16:07

Nic Foster


People also ask

What is a directive Sphinx?

A directive (ref) is a generic block of explicit markup. Along with roles, it is one of the extension mechanisms of reST, and Sphinx makes heavy use of it. Docutils supports the following directives: Admonitions: attention, caution, danger, error, hint, important, note, tip, warning and the generic admonition.

How do you highlight in code blocks?

In Code::Blocks select Settings -> Editor -> Occurrences Highlighting (scroll down in the pane on the left side to find it) and then put a check mark in the three checkboxes under Highlight occurrences of selection as shown in the below screenshot. The three checkboxes to select are: Highlight occurrences.


2 Answers

pygmentize -L lexers lists all supported lexers.

  • http://pygments.org/languages/
  • http://pygments.org/docs/lexers/
  • http://pygments.org/docs/cmdline/#getting-help
like image 190
Wes Turner Avatar answered Oct 19 '22 08:10

Wes Turner


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.

like image 29
John Palmieri Avatar answered Oct 19 '22 06:10

John Palmieri