highlightΒΆ
Example:
.. highlight:: ccc
This language is used until the next highlight
directive is encountered.
As discussed previously, language can be any lexer alias supported by
Pygments.
Additional options
Pygments can generate line numbers for code blocks. To enable this, use the
linenothreshold
option.
.. highlight:: python
:linenothreshold: 5
This will produce line numbers for all code blocks longer than five lines.
To ignore minor errors on highlighting, you can specifiy :force:
option.
Changed in version 2.1: :force:
option.
Example-1:
The literal blocks are highlighted as HTML, until a new directive is found.
Source Code
.. highlight:: html
::
<html><head></head>
<body>This is a text.</body>
</html>
Result
<html><head></head>
<body>This is a text.</body>
</html>
End Examples
The following directive changes the hightlight language to SQL.
SELECT * FROM mytable
From here on no highlighting will be done.
SELECT * FROM mytable