reStructuredText

Inline Markup

*text*   : italics
**text** : boldface
``text`` : code samples/blocks, verbatim mode - used as the escaping character
|        : vertical bar '|' for line break
thisis\ *one*\ word : use of backslash to intreprete a single word in different formats
`sphinx <http://www.sphinx-doc.org>`_ : create links to internal or external web pages

Headings

# with overline, for parts
* with overline, for chapters
=, for sections
-, for subsections
^, for subsubsections
“, for paragraphs

Colored Boxes

[ note, seealso, todo and warnings]

.. note::  This is a **note** box.

Note

This is a note box.

.. seealso:: This is a simple **seealso** note.

See also

This is a simple seealso note.

.. warning:: note the space between the directive and the text

Warning

note the space between the directive and the text

Lists and Quote-like blocks

Bullet List(* ), Numbered List(numbers or #. )

* List 1
* List 2

1. List 1
2. List 2

#. List 1
#. List 2

Nested lists: separated from the parent list items by blank lines

* this is
* a list

    * with a nested list
    * and some subitems

* and here the parent list continues

Term

  • one-line word or phrase,
  • multiple paragraphs,
  • no blank line between a term line and a definition block
term 1
 Definition 1.

term 2
    Definition 2, paragraph 1.

    Definition 2, paragraph 2.

term 3 : classifier
    Definition 3.

term 4 : classifier one : classifier two
    Definition 4

Directives

A reST directive is like a function – a powerful construct of the reST syntax used to include formatted text, and it accepts:

  • arguments
  • options
  • body
.. code-block:: html
   :linenos:

   <h1>Code Block</h1>

code-block directive: html (argument), linenos (option) toctree directive: maxdepth (option - indicating maximum number of levels in a single menu)

Code and Literal Blocks

ending a paragraph with the special marker ::

  • preceded by whitespace -> marker is removed
  • preceded by non-whitespace -> marker is replaced by a single colon
  • if continued with a same paragraph without a blank line, it is completely left out of the document

Table Example

  • grid, simple, csv, list-table syntax
  • tabularcolumns directive (column spec - to determine column width (default is left-aligned)

Example 1:

==================   ============
Name                 Age
==================   ============
John D Hunter        40
Cast of Thousands    41
And Still More       42
==================   ============


Example 2:

+------------+------------+-----------+
| Header 1   | Header 2   | Header 3  |
+============+============+===========+
| body row 1 | column 2   | column 3  |
+------------+------------+-----------+
| body row 2 | Cells may span columns.|
+------------+------------+-----------+
| body row 3 | Cells may  | - Cells   |
+------------+ span rows. | - contain |
| body row 4 |            | - blocks. |
+------------+------------+-----------+
Header 1 Header 2 Header 3
body row 1 column 2 column 3
body row 2 Cells may span columns.
body row 3 Cells may span rows.
  • Cells
  • contain
  • blocks.
body row 4

Example 3:

.. tabularcolumns:: |l|c|p{5cm}|

+--------------+---+-----------+
|simple text   | 2 | 3         |
+--------------+---+-----------+

Example 4

.. |insta| image:: ../path/to/image
       :width: 50pt
       :height: 30pt

.. |twit| image:: ../path/to/image
       :width: 30pt
       :height: 30pt

+---------------------+----------------+
|  |insta|            |   |twit|       |
+---------------------+----------------+
insta twit

CSV Example:

.. csv-table:: csv-example
   :header: "Fullname", "Address"
   :widths: 20, 20

   "User A", "Lalitpur,"
   "User B", "Kathmandu"