Welcome to Inline Syntax Highlight Sphinx Extension¶
Docutils supports inline syntax highlighting through code
directive
and role. Sphinx does it in a different way. This results in the need of two
pygments stylesheets for getting having both syntax highlightings (code blocks
and inline code). And it is always also a matter of docutils and sphinx
versions, because you need newest docutils installed, for supporting this.
This extension handles literal
nodes like sphinx handles literal_block
nodes and creates sphinx style syntax highlighting for inline code.
You can configure, if literals like ``this literal``
are also highlighted
using language, set by highlight
directive. You can also configure, if
code
is highlighted using language defined by highlight
directive.
If you have not yet the docutils version installed, which provides role
code
, this extension provides it.
In this documentation both configuration values below are set to true. Then you can use this extension as follows:
.. highlight:: rst
.. role:: python(code)
:language: python
.. role:: latex(code)
:language: latex
Now here are latex command :latex:`\\setlength` and python command
:python:`import`, created by ``:python:`import```. Here is a
:literal:`literal`, which stays a literal, and
:code:`.. highlight:: rst` makes code role look as it looks.
Which is rendered as follows:
.. highlight:: rst
Now here are latex command