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