http://docutils.sourceforge.net/docs/rst/quickref.html
Being a cheat-sheet for reStructuredText
Version 0.9 of 2002-07-23
The full details may be found on the reStructuredText page. This document is just intended as a reminder.
Links that look like "(details?)" point into the HTML version of the full reStructuredText specification document. These are relative links; if they don't work, please use the master "Quick reStructuredText" document.
(details?)
Plain text | Typical result | Notes |
---|---|---|
*emphasis* | emphasis | |
**strong emphasis** | strong emphasis | |
`interpreted text` | interpreted text | What interpreted text means is domain dependent. |
``inline literal`` | inline literal
| Spaces should be preserved, but line breaks will not be. |
reference_ | reference | A simple, one-word hyperlink reference. See Hyperlinks. |
`phrase reference`_ | phrase reference | A hyperlink reference with spaces or punctuation needs to be quoted with backquotes. See Hyperlinks. |
anonymous__ | anonymous | Both simple and phrase references may be anonymous (two underscores). See Hyperlinks. |
_`inline internal target` | inline internal target | A crossreference target within text. See Hyperlinks. |
|substitution reference| | (see note) | The result is substituted in from the substitution definition. It could be text, an image, a hyperlink, or a combination of these and others. |
footnote reference [1]_ | footnote reference [1] | See Footnotes. |
citation reference [CIT2002]_ | citation reference [CIT2002] | See Citations. |
http://docutils.sf.net/ | http://docutils.sf.net/ | A standalone hyperlink. |
Asterisk, backquote, vertical bar, and underscore are inline delimiter characters. Asterisk, backquote, and vertical bar act like quote marks; matching characters surround the marked-up word or phrase, whitespace or other quoting is required outside them, and there can't be whitespace just inside them. If you want to use inline delimiter characters literally, escape (with backslash) or quote them (with double backquotes; i.e. use inline literals).
In detail, the reStructuredText specifications says that in inline markup:
Also remember that inline markup may not be nested (well, except that inline literals can contain any of the other inline markup delimiter characters, but that doesn't count because nothing is processed).
(details?)
reStructuredText uses backslashes ("\") to override the special meaning given to markup characters and get the literal characters themselves. To get a literal backslash, use an escaped backslash ("\\"). For example:
Raw reStructuredText | Typical result |
---|---|
*escape* ``with`` "\" | escape with "" |
\*escape* \``with`` "\\" | *escape* ``with`` "\" |
In Python strings it will, of course, be necessary to escape any backslash characters so that they actually reach reStructuredText. The simplest way to do this is to use raw strings:
Python string | Typical result |
---|---|
r"""\*escape* \`with` "\\"""" | *escape* `with` "\" |
"""\\*escape* \\`with` "\\\\"""" | *escape* `with` "\" |
"""\*escape* \`with` "\\"""" | escape with "" |
(details?)
Plain text | Typical result |
---|---|
=====
Title ===== Subtitle -------- Titles are underlined (or over- and underlined) with a printing nonalphanumeric 7-bit ASCII character. Recommended choices are "``= - ` : ' " ~ ^ _ * + # < >``". |
Title
Subtitle Titles are underlined (or over- and underlined) with a printing nonalphanumeric 7-bit ASCII character. Recommended choices are "= - ` : ' " ~ ^ _ * + # < >". |
(details?)
Plain text | Typical result |
---|---|
This is a paragraph. Paragraphs line up at their left
|
This is a paragraph. Paragraphs line up at their left edges, and are normally separated by blank lines. |
(details?)
Plain text | Typical result |
---|---|
Bullet lists:
- This is item 1
- Bullets are "-", "*" or "+".
Note that a blank line is required
| Bullet lists:
Note that a blank line is required before the first item and after the last, but is optional between items. |
(details?)
Plain text | Typical result |
---|---|
Enumerated lists:
3. This is the first item
| Enumerated lists:
|
(details?)
Plain text | Typical result |
---|---|
Definition lists:
what Definition lists associate a term with a definition. how The term is a one-line phrase, and the definition is one or more paragraphs or body elements, indented relative to the term. Blank lines are not allowed between term and definition. | Definition lists:
|
(details?)
Plain text | Typical result | ||||||||
---|---|---|---|---|---|---|---|---|---|
:Authors:
Tony J. (Tibs) Ibbs, David Goodger (and sundry other good-natured folks) :Version: 1.0 of 2001/08/08
|
|
(details?)
Plain text | Typical result | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
-a command-line option "a"
|
|
There must be at least two spaces between the option and the description.
(details?)
Plain text | Typical result |
---|---|
A paragraph containing only two colons
indicates that the following indented text is a literal block. :: Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. The paragraph containing only '::' will be omitted from the result. The ``::`` may be tacked onto the very end of any paragraph. The ``::`` will be omitted if it is preceded by whitespace. The ``::`` will be converted to a single colon if preceded by text, like this:: It's very convenient to use this form. Literal blocks end when text returns to the preceding paragraph's indentation. This means that something like:: We start here and continue here and end here. is possible. |
A paragraph containing only two colons indicates that the following indented text is a literal block. Whitespace, newlines, blank lines, and all kinds of markup (like *this* or \this) is preserved by literal blocks. The paragraph containing only '::' will be omitted from the result. The :: may be tacked onto the very end of any paragraph. The :: will be omitted if it is preceded by whitespace. The :: will be converted to a single colon if preceded by text, like this: It's very convenient to use this form. Literal blocks end when text returns to the preceding paragraph's indentation. This means that something like: We start here and continue here and end here. is possible. |
(details?)
Plain text | Typical result |
---|---|
Block quotes are just:
Indented paragraphs, and they may nest. |
Block quotes are just:
|
(details?)
Plain text | Typical result |
---|---|
Doctest blocks are interactive
>>> print "This is a doctest block."
|
Doctest blocks are interactive Python sessions. They begin with ">>>" and end with a blank line. >>> print "This is a doctest block."
|
"The doctest module searches a module's docstrings for text that looks like an interactive Python session, then executes all such sessions to verify they still work exactly as shown." (From the doctest docs.)
(details?)
There are two syntaxes for tables in reStructuredText. Grid tables are complete but cumbersome to create. Simple tables are easy to create but limited (no row spans, etc.).
Plain text | Typical result | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Grid table: +------------+------------+-----------+
|
Grid table:
| ||||||||||||||||||
Simple table: ===== ===== ======
|
Simple table:
|
(details?)
Plain text | Typical result |
---|---|
A transition marker is a horizontal line
------------ A transition should not begin or end a
|
A transition marker is a horizontal line of 4 or more repeated punctuation characters. A transition should not begin or end a section or document, nor should two transitions be immediately adjacent. |
Transitions are commonly seen in novels and short fiction, as a gap spanning one or more lines, marking text divisions or signaling changes in subject, time, point of view, or emphasis.
(details?)
Plain text | Typical result | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Footnote references, like [5]_.
Note that footnotes may get rearranged, e.g., to the bottom of the "page". .. [5] A numerical footnote. Note
|
Footnote references, like [5].
Note that footnotes may get rearranged, e.g., to the bottom of
the "page".
| ||||||||||
Autonumbered footnotes are
possible, like using [#]_ and [#]_. .. [#] This is the first one.
They may be assigned 'autonumber
.. [#third] a.k.a. third_ .. [#fourth] a.k.a. fourth_ |
Autonumbered footnotes are possible, like using 1 and 2.
They may be assigned 'autonumber labels' - for instance, 4 and 3.
| ||||||||||
Auto-symbol footnotes are also
possible, like this: [*]_ and [*]_. .. [*] This is the first one.
|
Auto-symbol footnotes are also
possible, like this: *
and †.
|
The numbering of auto-numbered footnotes is determined by the order of the footnotes, not of the references. For auto-numbered footnote references without autonumber labels ("[#]_"), the references and footnotes must be in the same relative order. Similarly for auto-symbol footnotes ("[*]_").
(details?)
Plain text | Typical result | ||||||
---|---|---|---|---|---|---|---|
Citation references, like [CIT2002]_.
Note that citations may get rearranged, e.g., to the bottom of the "page". .. [CIT2002] A citation
Citation labels contain alphanumerics,
Given a citation like [this]_, one
.. [this] here. |
Citation references, like [CIT2002].
Note that citations may get rearranged, e.g., to the bottom of
the "page".
Citation labels contain alphanumerics, underlines, hyphens and fullstops. Case is not significant. Given a citation like [this], one can also refer to it like this.
|
(details?)
Plain text | Typical result | ||||||||
---|---|---|---|---|---|---|---|---|---|
External hyperlinks, like Python_.
.. _Python: http://www.python.org/ |
|
"Fold-in" is the representation typically used in HTML documents (think of the indirect hyperlink being "folded in" like ingredients into a cake), and "call-out" is more suitable for printed documents, where the link needs to be presented explicitly, for example as a footnote.
Plain text | Typical result | ||||
---|---|---|---|---|---|
Internal crossreferences, like example_.
.. _example: This is an example crossreference target. |
|
(details?)
Plain text | Typical result |
---|---|
Python_ is `my favourite
programming language`__. .. _Python: http://www.python.org/ __ Python_ |
The second hyperlink target (the line beginning with "__") is both an indirect hyperlink target (indirectly pointing at the Python website via the "Python_" reference) and an anonymous hyperlink target. In the text, a double-underscore suffix is used to indicate an anonymous hyperlink reference.
(details?)
Section titles, footnotes, and citations automatically generate hyperlink targets (the title text or footnote/citation label is used as the hyperlink name).
Plain text | Typical result |
---|---|
Titles are targets, too
======================= Implict references, like `Titles are targets, too`_. |
Titles are targets, too
Implict references, like Titles are targets, too. |
(details?)
Plain text | Typical result |
---|---|
For instance:
.. image:: images/ball1.gif |
For instance:
|
(details?)
Substitutions are like inline directives, allowing graphics and arbitrary constructs within text.
Plain text | Typical result |
---|---|
The |biohazard| symbol must be
used on containers used to
dispose of medical waste.
.. |biohazard| image:: biohazard.png |
The |
(details?)
Plain text | Typical result |
---|---|
.. This text will not be shown
(but, for instance, in HTML might be rendered as an HTML comment) | |
An empty "comment" directive does not
"consume" following blocks. .. So this block is not "lost",
|
An empty "comment" directive does not
"consume" following blocks.
So this block is not "lost", despite its indentation. |
Authors: Tibs (tony@lsl.co.uk or tibs@tibsnjoan.co.uk) and David Goodger (goodger@users.sourceforge.net)