1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
=====================================================
The reStructuredText_ Cheat Sheet: Syntax Reminders
=====================================================
:Info: See <https://docutils.sourceforge.io/rst.html> for introductory docs.
:Author: David Goodger <goodger@python.org>
:Date: $Date: 2025-09-13 18:01:09 +0200 (Sa, 13. Sep 2025) $
:Revision: $Revision: 10232 $
:Description: This is a "docinfo block", or bibliographic field list
.. NOTE:: If you are reading this as HTML, please read
`<cheatsheet.rst>`_ instead to see the input syntax examples!
Section Structure
=================
Section titles are underlined or overlined & underlined.
Body Elements
=============
Grid table:
+--------------------------------+-----------------------------------+
| Paragraphs are flush-left, | Literal block, preceded by "::":: |
| separated by blank lines. | |
| | Indented |
| Block quotes are indented. | |
+--------------------------------+ or:: |
| >>> print 'Doctest block' | |
| Doctest block | > Quoted |
+--------------------------------+-----------------------------------+
| | Line blocks preserve line breaks & indents. |
| | Useful for addresses, verse, and adornment-free lists; long |
| lines can be wrapped with continuation lines. |
+--------------------------------------------------------------------+
Simple tables:
================ ============================================================
List Type Examples (syntax in the `text source <cheatsheet.rst>`_)
================ ============================================================
Bullet list * items begin with "-", "+", or "*"
Enumerated list 1. items use any variation of "1.", "A)", and "(i)"
#. also auto-enumerated
Definition list Term is flush-left : optional classifier
Definition is indented, no blank line between
Field list :field name: field body
Option list -o at least 2 spaces between option & description
================ ============================================================
================ ============================================================
Explicit Markup Examples (visible in the `text source`_)
================ ============================================================
Footnote .. [1] Manually numbered or [#] auto-numbered
(even [#labelled]) or [*] auto-symbol
Citation .. [CIT2002] A citation.
Hyperlink Target .. _reStructuredText: https://docutils.sourceforge.io/rst.html
.. _indirect target: reStructuredText_
.. _internal target:
Anonymous Target __ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html
Directive ("::") .. image:: images/biohazard.png
Substitution Def .. |substitution| replace:: like an inline directive
Comment .. is anything else
Empty Comment (".." on a line by itself, with blank lines before & after,
used to separate indentation contexts)
================ ============================================================
Inline Markup
=============
*emphasis*; **strong emphasis**; `interpreted text`; `interpreted text
with role`:emphasis:; ``inline literal text``; standalone hyperlink,
https://docutils.sourceforge.io; named reference, reStructuredText_;
`anonymous reference`__; footnote reference, [1]_; citation reference,
[CIT2002]_; |substitution|; _`inline internal target`.
Directive Quick Reference
=========================
See <https://docutils.sourceforge.io/docs/ref/rst/directives.html> for full info.
================ ============================================================
Directive Name Description
================ ============================================================
attention Specific admonition; also "caution", "danger",
"error", "hint", "important", "note", "tip", "warning"
admonition Generic titled admonition: ``.. admonition:: By The Way``
image ``.. image:: picture.png``; many options possible
figure Like "image", but with optional caption and legend
topic ``.. topic:: Title``; like a mini section
sidebar ``.. sidebar:: Title``; like a mini parallel document
parsed-literal A literal block with parsed inline markup
code Literal block for code with optional syntax highlighting
math Mathematical notation (input in LaTeX format)
rubric ``.. rubric:: Informal Heading``
epigraph Block quote with class="epigraph"
highlights Block quote with class="highlights"
pull-quote Block quote with class="pull-quote"
compound Compound paragraphs
container Generic block-level container element
table Create a titled table
list-table Create a table from a uniform two-level bullet list
csv-table Create a table from CSV data
contents Generate a table of contents
sectnum Automatically number sections, subsections, etc.
header, footer Create document decorations
target-notes Create an explicit footnote for each external target
replace Replacement text for substitution definitions
unicode Unicode character code conversion for substitution defs
date Generates today's date; for substitution defs
include Read an external reST file as if it were inline
raw Non-reST data passed untouched to the Writer
class Set a "class" attribute on the next element
role Create a custom interpreted text role
default-role Set the default interpreted text role
meta Document metadata
title Set the metadata document title
================ ============================================================
Interpreted Text Role Quick Reference
=====================================
See <https://docutils.sourceforge.io/docs/ref/rst/roles.html> for full info.
================ ============================================================
Role Name Description
================ ============================================================
code code in a formal language (see docs for syntax highlighting)
emphasis Equivalent to *emphasis*
literal Equivalent to ``literal`` but processes backslash escapes
math Mathematical notation (input in LaTeX format)
PEP Reference to a numbered Python Enhancement Proposal
RFC Reference to a numbered Internet Request For Comments
raw For non-reST data; cannot be used directly (see docs)
strong Equivalent to **strong**
sub Subscript
sup Superscript
title Title reference (book, etc.); standard default role
================ ============================================================
|