summaryrefslogtreecommitdiff
path: root/doc/markup/code.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/markup/code.rst')
-rw-r--r--doc/markup/code.rst19
1 files changed, 14 insertions, 5 deletions
diff --git a/doc/markup/code.rst b/doc/markup/code.rst
index 93cd127b..eaaf17d0 100644
--- a/doc/markup/code.rst
+++ b/doc/markup/code.rst
@@ -43,14 +43,14 @@ installed) and handled in a smart way:
This language is used until the next ``highlight`` directive is encountered.
* For documents that have to show snippets in different languages, there's also
- a :dir:`code-block` directive that is given the highlighting language
+ a :rst:dir:`code-block` directive that is given the highlighting language
directly::
.. code-block:: ruby
Some Ruby code.
- The directive's alias name :dir:`sourcecode` works as well.
+ The directive's alias name :rst:dir:`sourcecode` works as well.
* The valid values for the highlighting language are:
@@ -70,7 +70,7 @@ Line numbers
If installed, Pygments can generate line numbers for code blocks. For
automatically-highlighted blocks (those started by ``::``), line numbers must be
-switched on in a :dir:`highlight` directive, with the ``linenothreshold``
+switched on in a :rst:dir:`highlight` directive, with the ``linenothreshold``
option::
.. highlight:: python
@@ -78,7 +78,7 @@ option::
This will produce line numbers for all code blocks longer than five lines.
-For :dir:`code-block` blocks, a ``linenos`` flag option can be given to switch
+For :rst:dir:`code-block` blocks, a ``linenos`` flag option can be given to switch
on line numbers for the individual block::
.. code-block:: ruby
@@ -90,7 +90,7 @@ on line numbers for the individual block::
Includes
^^^^^^^^
-.. directive:: .. literalinclude:: filename
+.. rst:directive:: .. literalinclude:: filename
Longer displays of verbatim text may be included by storing the example text in
an external file containing only plain text. The file may be included using the
@@ -103,6 +103,9 @@ Includes
is absolute (starting with ``/``), it is relative to the top source
directory.
+ Tabs in the input are expanded if you give a ``tab-width`` option with the
+ desired tab width.
+
The directive also supports the ``linenos`` flag option to switch on line
numbers, and a ``language`` option to select a language different from the
current file's standard language. Example with options::
@@ -143,11 +146,17 @@ Includes
string option, only lines that precede the first lines containing that string
are included.
+ You can prepend and/or append a line to the included code, using the
+ ``prepend`` and ``append`` option, respectively. This is useful e.g. for
+ highlighting PHP code that doesn't include the ``<?php``/``?>`` markers.
+
.. versionadded:: 0.4.3
The ``encoding`` option.
.. versionadded:: 0.6
The ``pyobject``, ``lines``, ``start-after`` and ``end-before`` options,
as well as support for absolute filenames.
+ .. versionadded:: 1.0
+ The ``prepend`` and ``append`` options, as well as ``tab-width``.
.. rubric:: Footnotes