| 1 |
.. include:: ../../header2.rst |
| 2 |
|
| 3 |
======================================= |
| 4 |
reStructuredText Markup Specification |
| 5 |
======================================= |
| 6 |
|
| 7 |
:Author: David Goodger |
| 8 |
:Contact: [email protected] |
| 9 |
:Revision: $Revision: 10313 $ |
| 10 |
:Date: $Date: 2026-04-29 17:15:49 +0200 (Mi, 29. Apr 2026) $ |
| 11 |
:Copyright: This document has been placed in the public domain. |
| 12 |
|
| 13 |
.. Note:: |
| 14 |
|
| 15 |
This document is a detailed technical specification; it is not a |
| 16 |
tutorial or a primer. If this is your first exposure to |
| 17 |
reStructuredText, please read `A ReStructuredText Primer`_ and the |
| 18 |
`Quick reStructuredText`_ user reference first. |
| 19 |
|
| 20 |
.. _A ReStructuredText Primer: ../../user/rst/quickstart.html |
| 21 |
.. _Quick reStructuredText: ../../user/rst/quickref.html |
| 22 |
|
| 23 |
|
| 24 |
reStructuredText_ is plaintext that uses simple and intuitive |
| 25 |
constructs to indicate the structure of a document. These constructs |
| 26 |
are equally easy to read in raw and processed forms. This document is |
| 27 |
itself an example of reStructuredText (raw, if you are reading the |
| 28 |
`text file`__, or processed, if you are reading an HTML document, for |
| 29 |
example). The reStructuredText parser is a component of Docutils_. |
| 30 |
|
| 31 |
Simple, implicit markup is used to indicate special constructs, such |
| 32 |
as section headings, bullet lists, and emphasis. The markup used is |
| 33 |
as minimal and unobtrusive as possible. Less often-used constructs |
| 34 |
and extensions to the basic reStructuredText syntax may have more |
| 35 |
elaborate or explicit markup. |
| 36 |
|
| 37 |
reStructuredText is applicable to documents of any length, from the |
| 38 |
very small (such as inline program documentation fragments, e.g. |
| 39 |
Python docstrings) to the quite large (this document). |
| 40 |
|
| 41 |
The first section gives a quick overview of the syntax of the |
| 42 |
reStructuredText markup by example. A complete specification is given |
| 43 |
in the `Syntax Details`_ section. |
| 44 |
|
| 45 |
`Literal blocks`_ (in which no markup processing is done) are used for |
| 46 |
examples throughout this document, to illustrate the plaintext markup. |
| 47 |
|
| 48 |
__ restructuredtext.rst |
| 49 |
|
| 50 |
.. contents:: |
| 51 |
|
| 52 |
|
| 53 |
----------------------- |
| 54 |
Quick Syntax Overview |
| 55 |
----------------------- |
| 56 |
|
| 57 |
A reStructuredText document is made up of body or block-level |
| 58 |
elements, and may be structured into sections. Sections_ are |
| 59 |
indicated through title style (underlines & optional overlines). |
| 60 |
Sections contain body elements and/or subsections. Some body elements |
| 61 |
contain further elements, such as lists containing list items, which |
| 62 |
in turn may contain paragraphs and other body elements. Others, such |
| 63 |
as paragraphs, contain text and `inline markup`_ elements. |
| 64 |
|
| 65 |
Here are examples of `body elements`_: |
| 66 |
|
| 67 |
- Paragraphs_ (and `inline markup`_):: |
| 68 |
|
| 69 |
Paragraphs contain text and may contain inline markup: |
| 70 |
*emphasis*, **strong emphasis**, `interpreted text`, ``inline |
| 71 |
literals``, standalone hyperlinks (https://www.python.org), |
| 72 |
external hyperlinks (Python_), internal cross-references |
| 73 |
(example_), footnote references ([1]_), citation references |
| 74 |
([CIT2002]_), substitution references (|example|), and _`inline |
| 75 |
internal targets`. |
| 76 |
|
| 77 |
Paragraphs are separated by blank lines and are left-aligned. |
| 78 |
|
| 79 |
- Five types of lists: |
| 80 |
|
| 81 |
1. `Bullet lists`_:: |
| 82 |
|
| 83 |
- This is a bullet list. |
| 84 |
|
| 85 |
- Bullets can be ``*``, ``+``, or ``-``. |
| 86 |
|
| 87 |
2. `Enumerated lists`_:: |
| 88 |
|
| 89 |
1. This is an enumerated list. |
| 90 |
|
| 91 |
2. Enumerators may be arabic numerals, letters, or roman |
| 92 |
numerals. |
| 93 |
|
| 94 |
3. `Definition lists`_:: |
| 95 |
|
| 96 |
what |
| 97 |
Definition lists associate a term with a definition. |
| 98 |
|
| 99 |
how |
| 100 |
The term is a one-line phrase, and the definition is one |
| 101 |
or more paragraphs or body elements, indented relative to |
| 102 |
the term. |
| 103 |
|
| 104 |
4. `Field lists`_:: |
| 105 |
|
| 106 |
:what: Field lists map field names to field bodies, like |
| 107 |
database records. They are often part of an extension |
| 108 |
syntax. |
| 109 |
|
| 110 |
:how: The field marker is a colon, the field name, and a |
| 111 |
colon. |
| 112 |
|
| 113 |
The field body may contain one or more body elements, |
| 114 |
indented relative to the field marker. |
| 115 |
|
| 116 |
5. `Option lists`_, for listing command-line options:: |
| 117 |
|
| 118 |
-a command-line option "a" |
| 119 |
-b file options can have arguments |
| 120 |
and long descriptions |
| 121 |
--long options can be long also |
| 122 |
--input=file long options can also have |
| 123 |
arguments |
| 124 |
/V DOS/VMS-style options too |
| 125 |
|
| 126 |
There must be at least two spaces between the option and the |
| 127 |
description. |
| 128 |
|
| 129 |
- `Literal blocks`_:: |
| 130 |
|
| 131 |
Literal blocks are either indented or line-prefix-quoted blocks, |
| 132 |
and indicated with a double-colon (``::``) at the end of the |
| 133 |
preceding paragraph (right here -->):: |
| 134 |
|
| 135 |
if literal_block: |
| 136 |
text = 'is left as-is' |
| 137 |
spaces_and_linebreaks = 'are preserved' |
| 138 |
markup_processing = None |
| 139 |
|
| 140 |
- `Block quotes`_:: |
| 141 |
|
| 142 |
Block quotes consist of indented body elements: |
| 143 |
|
| 144 |
This theory, that is mine, is mine. |
| 145 |
|
| 146 |
-- Anne Elk (Miss) |
| 147 |
|
| 148 |
- `Doctest blocks`_:: |
| 149 |
|
| 150 |
>>> print 'Python-specific usage examples; begun with ">>> "' |
| 151 |
Python-specific usage examples; begun with ">>> " |
| 152 |
>>> print '(cut and pasted from interactive Python sessions)' |
| 153 |
(cut and pasted from interactive Python sessions) |
| 154 |
|
| 155 |
- Two syntaxes for tables_: |
| 156 |
|
| 157 |
1. `Grid tables`_; complete, but complex and verbose:: |
| 158 |
|
| 159 |
+------------------------+------------+----------+ |
| 160 |
| Header row, column 1 | Header 2 | Header 3 | |
| 161 |
+========================+============+==========+ |
| 162 |
| body row 1, column 1 | column 2 | column 3 | |
| 163 |
+------------------------+------------+----------+ |
| 164 |
| body row 2 | Cells may span | |
| 165 |
+------------------------+-----------------------+ |
| 166 |
|
| 167 |
2. `Simple tables`_; easy and compact, but limited:: |
| 168 |
|
| 169 |
==================== ========== ========== |
| 170 |
Header row, column 1 Header 2 Header 3 |
| 171 |
==================== ========== ========== |
| 172 |
body row 1, column 1 column 2 column 3 |
| 173 |
body row 2 Cells may span columns |
| 174 |
==================== ====================== |
| 175 |
|
| 176 |
- `Explicit markup blocks`_ all begin with an explicit block marker, |
| 177 |
two periods and a space: |
| 178 |
|
| 179 |
- Footnotes_:: |
| 180 |
|
| 181 |
.. [1] A footnote contains body elements, consistently |
| 182 |
indented by at least 1 space. |
| 183 |
|
| 184 |
The least indented line sets the reference |
| 185 |
indentation, so this is a nested block quote. |
| 186 |
|
| 187 |
- Citations_:: |
| 188 |
|
| 189 |
.. [CIT2002] Just like a footnote, except the label is |
| 190 |
textual. |
| 191 |
|
| 192 |
- `Hyperlink targets`_:: |
| 193 |
|
| 194 |
.. _Python: https://www.python.org |
| 195 |
|
| 196 |
.. _example: |
| 197 |
|
| 198 |
The "_example" target above points to this paragraph. |
| 199 |
|
| 200 |
- Directives_:: |
| 201 |
|
| 202 |
.. image:: mylogo.png |
| 203 |
|
| 204 |
- `Substitution definitions`_:: |
| 205 |
|
| 206 |
.. |symbol here| image:: symbol.png |
| 207 |
|
| 208 |
- Comments_:: |
| 209 |
|
| 210 |
.. Comments begin with two dots and whitespace. Anything may |
| 211 |
follow, except for the syntax of footnotes/citations, |
| 212 |
hyperlink targets, directives, or substitution definitions. |
| 213 |
|
| 214 |
|
| 215 |
---------------- |
| 216 |
Syntax Details |
| 217 |
---------------- |
| 218 |
|
| 219 |
Descriptions below list "doctree elements" (document tree element |
| 220 |
names; XML DTD generic identifiers) corresponding to syntax |
| 221 |
constructs. For details on the hierarchy of elements, please see `The |
| 222 |
Docutils Document Tree`_ and the `Docutils Generic DTD`_ XML document |
| 223 |
type definition. |
| 224 |
|
| 225 |
|
| 226 |
Whitespace |
| 227 |
========== |
| 228 |
|
| 229 |
:Config setting: tab_width_ |
| 230 |
|
| 231 |
Spaces are recommended for indentation_, but tabs may also be used. |
| 232 |
Tabs will be converted to spaces. Tab stops are at every 8th column |
| 233 |
(processing systems may make this value configurable, Docutils uses the |
| 234 |
`tab_width`_ configuration setting). |
| 235 |
|
| 236 |
Other whitespace characters (form feeds [chr(12)] and vertical tabs |
| 237 |
[chr(11)]) are converted to single spaces before processing. |
| 238 |
|
| 239 |
|
| 240 |
Blank Lines |
| 241 |
----------- |
| 242 |
|
| 243 |
Blank lines are used to separate paragraphs and other elements. |
| 244 |
Multiple successive blank lines are equivalent to a single blank line, |
| 245 |
except within literal blocks (where all whitespace is preserved). |
| 246 |
Blank lines may be omitted when the markup makes element separation |
| 247 |
unambiguous, in conjunction with indentation. The first line of a |
| 248 |
document is treated as if it is preceded by a blank line, and the last |
| 249 |
line of a document is treated as if it is followed by a blank line. |
| 250 |
|
| 251 |
|
| 252 |
Indentation |
| 253 |
----------- |
| 254 |
|
| 255 |
When a paragraph or other construct consists of more than one line of |
| 256 |
text, the lines must be left-aligned:: |
| 257 |
|
| 258 |
This is a paragraph. The lines of |
| 259 |
this paragraph are aligned at the left. |
| 260 |
|
| 261 |
This paragraph has problems. The |
| 262 |
lines are not left-aligned. In addition |
| 263 |
to potential misinterpretation, warning |
| 264 |
and/or error messages will be generated |
| 265 |
by the parser. |
| 266 |
|
| 267 |
*Indentation* is used to indicate -- and is only significant in |
| 268 |
indicating -- block quotes, definitions (in `definition lists`_), |
| 269 |
and local nested content: |
| 270 |
|
| 271 |
- list item content (multi-line contents of list items, and multiple |
| 272 |
body elements within a list item, including nested lists), |
| 273 |
- the content of `literal blocks`_, and |
| 274 |
- the content of `explicit markup blocks`_ (directives, footnotes, ...). |
| 275 |
|
| 276 |
Any text whose indentation is less than that of the current level |
| 277 |
(i.e., unindented text or "dedents") ends the current level of |
| 278 |
indentation. |
| 279 |
|
| 280 |
Since all indentation is significant, the level of indentation must be |
| 281 |
consistent. For example, indentation is the sole markup indicator for |
| 282 |
`block quotes`_:: |
| 283 |
|
| 284 |
This is a top-level paragraph. |
| 285 |
|
| 286 |
This paragraph belongs to a first-level block quote. |
| 287 |
|
| 288 |
Paragraph 2 of the first-level block quote. |
| 289 |
|
| 290 |
.. _reference indentation: |
| 291 |
|
| 292 |
Multiple levels of indentation within a block will result in more |
| 293 |
complex structures. The least indented line of a block sets the |
| 294 |
*reference indentation*:: |
| 295 |
|
| 296 |
This is a top-level paragraph. |
| 297 |
|
| 298 |
This paragraph belongs to a first-level block quote. |
| 299 |
|
| 300 |
This paragraph belongs to a second-level block quote. |
| 301 |
|
| 302 |
Another top-level paragraph. |
| 303 |
|
| 304 |
This paragraph belongs to a second-level block quote. |
| 305 |
|
| 306 |
This paragraph belongs to a first-level block quote. |
| 307 |
The second-level block quote above is inside this |
| 308 |
first-level block quote. |
| 309 |
|
| 310 |
Every block has its own reference indentation:: |
| 311 |
|
| 312 |
This paragraph belongs to a first-level block quote |
| 313 |
because there is no less indented line in the block. |
| 314 |
|
| 315 |
Several constructs begin with a marker, and the body of the construct |
| 316 |
must be indented relative to the marker. For constructs using simple |
| 317 |
markers (`bullet lists`_, `enumerated lists`_), the level of |
| 318 |
indentation of the body is determined by the position of the first |
| 319 |
line of text. For example:: |
| 320 |
|
| 321 |
- This is the first line of a bullet list |
| 322 |
item's paragraph. All lines must align |
| 323 |
relative to the first line. |
| 324 |
|
| 325 |
This indented paragraph is interpreted |
| 326 |
as a block quote. |
| 327 |
|
| 328 |
Another paragraph belonging to the first list item. |
| 329 |
|
| 330 |
Because it is not sufficiently indented, |
| 331 |
this paragraph does not belong to the list |
| 332 |
item (it's a block quote following the list). |
| 333 |
|
| 334 |
The first line of text may start below the marker:: |
| 335 |
|
| 336 |
1. |
| 337 |
This is the first line of an enumeration |
| 338 |
item's paragraph. |
| 339 |
|
| 340 |
This indented paragraph is interpreted |
| 341 |
as a block quote. |
| 342 |
|
| 343 |
This paragraph still belongs to the list |
| 344 |
item |
| 345 |
|
| 346 |
This paragraph ends the list. |
| 347 |
|
| 348 |
The body of `explicit markup blocks`_, `field lists`_, and `option |
| 349 |
lists`_ ends above the first line with the same or less indentation |
| 350 |
than the marker. For example, field lists may have very long markers |
| 351 |
(containing the field names):: |
| 352 |
|
| 353 |
:Hello: This field has a short field name, so aligning |
| 354 |
the field body with the first line is feasible. |
| 355 |
:Long field name: It would be inconvenient to align the |
| 356 |
field body with the left edge of the first line. |
| 357 |
:Number of African swallows required to carry a coconut: |
| 358 |
Sometimes, it is preferable to begin the body |
| 359 |
on the next line. |
| 360 |
|
| 361 |
|
| 362 |
.. _escape: |
| 363 |
|
| 364 |
Escaping Mechanism |
| 365 |
================== |
| 366 |
|
| 367 |
The character set universally available to plaintext documents, 7-bit |
| 368 |
ASCII, is limited. No matter what characters are used for markup, |
| 369 |
they will already have multiple meanings in written text. Therefore |
| 370 |
markup characters will sometimes appear in text without being |
| 371 |
intended as markup. Any serious markup system requires an escaping |
| 372 |
mechanism to override the default meaning of the characters used for |
| 373 |
the markup. In reStructuredText we use the *backslash*, commonly used |
| 374 |
as an escaping character in other domains. |
| 375 |
|
| 376 |
A backslash (``\``) escapes the following character. |
| 377 |
|
| 378 |
* "Escaping" backslash characters are represented by NULL characters in |
| 379 |
the `Document Tree`_ and removed from the output document by the |
| 380 |
Docutils writers_. |
| 381 |
|
| 382 |
* Escaped non-white characters are prevented from playing a role in any |
| 383 |
markup interpretation. The escaped character represents the character |
| 384 |
itself. (A literal backslash can be specified by two backslashes in a |
| 385 |
row -- the first backslash escapes the second. [#caveat]_) |
| 386 |
|
| 387 |
* _`Escaped whitespace` characters are removed from the output document |
| 388 |
together with the escaping backslash. This allows for `character-level |
| 389 |
inline markup`_. |
| 390 |
|
| 391 |
In `URI context` [#uri-context]_, backslash-escaped whitespace |
| 392 |
represents a single space. |
| 393 |
|
| 394 |
Backslashes have no special meaning in `literal context` [#literal-context]_. |
| 395 |
Here, a single backslash represents a literal backslash, without having |
| 396 |
to double up. [#caveat]_ |
| 397 |
|
| 398 |
.. [#caveat] Please note that the reStructuredText specification and |
| 399 |
parser do not address the issue of the representation or extraction of |
| 400 |
text input (how and in what form the text actually *reaches* the |
| 401 |
parser). Backslashes and other characters may serve a |
| 402 |
character-escaping purpose in certain contexts and must be dealt with |
| 403 |
appropriately. For example, Python uses backslashes in string |
| 404 |
literals to escape certain characters. The simplest solution when |
| 405 |
backslashes appear in Python docstrings is to use raw docstrings:: |
| 406 |
|
| 407 |
r"""This is a raw docstring. Backslashes (\) are not touched.""" |
| 408 |
|
| 409 |
.. [#uri-context] In contexts where the parser expects a `URI-reference`_ |
| 410 |
(the link block of `external hyperlink targets`_ or the argument of an |
| 411 |
`"image"`_ or `"figure"`_ directive), whitespace is ignored by default. |
| 412 |
|
| 413 |
.. [#literal-context] |
| 414 |
In *literal context* (`literal blocks`_, `inline literals`_, |
| 415 |
content of the `"code"`_, `"math"`_, and `"raw"`_ directives, |
| 416 |
content of the `:raw:`_ role and `custom roles`_ based on it), |
| 417 |
reStructuredText markup characters lose their semantics |
| 418 |
so there is no reason to escape them. |
| 419 |
|
| 420 |
|
| 421 |
.. _reference name: |
| 422 |
|
| 423 |
Reference Names |
| 424 |
=============== |
| 425 |
|
| 426 |
`Reference names` identify elements for cross-referencing. |
| 427 |
|
| 428 |
.. Note:: References to a target position in external, generated documents |
| 429 |
must use the auto-generated `identifier key`_ which may differ from the |
| 430 |
`reference name` due to restrictions on identifiers/labels in the |
| 431 |
output format. |
| 432 |
|
| 433 |
.. _simple reference name: |
| 434 |
.. _simple reference names: |
| 435 |
|
| 436 |
*Simple reference names* are single words consisting of alphanumerics |
| 437 |
plus isolated (no two adjacent) internal hyphens, underscores, |
| 438 |
periods, colons and plus signs; no whitespace or other characters are |
| 439 |
allowed. Footnote labels (Footnotes_ & `Footnote References`_), citation |
| 440 |
labels (Citations_ & `Citation References`_), `interpreted text`_ roles, |
| 441 |
and some `hyperlink references`_ use the simple reference name syntax. |
| 442 |
|
| 443 |
.. _phrase references: |
| 444 |
|
| 445 |
Reference names using punctuation or whose names are phrases (two or |
| 446 |
more space-separated words) are called *phrase references*. |
| 447 |
Phrase-references are expressed by enclosing the phrase in backquotes |
| 448 |
and treating the backquoted text as a reference name:: |
| 449 |
|
| 450 |
Want to learn about `my favorite programming language`_? |
| 451 |
|
| 452 |
.. _my favorite programming language: https://www.python.org |
| 453 |
|
| 454 |
Simple reference names may also optionally use backquotes. |
| 455 |
|
| 456 |
.. _normalized reference names: |
| 457 |
|
| 458 |
Reference names are whitespace-neutral and |
| 459 |
case-insensitive [#substitution-text]_: |
| 460 |
When resolving reference names internally, |
| 461 |
|
| 462 |
- whitespace is normalized (one or more spaces, horizontal or vertical |
| 463 |
tabs, newlines, carriage returns, or form feeds, are interpreted as |
| 464 |
a single space), and |
| 465 |
|
| 466 |
- case is normalized (all alphabetic characters are converted to |
| 467 |
lowercase). [#substitution-text]_ |
| 468 |
|
| 469 |
For example, the following `hyperlink references`_ are equivalent:: |
| 470 |
|
| 471 |
- `A HYPERLINK`_ |
| 472 |
- `a hyperlink`_ |
| 473 |
- `A |
| 474 |
Hyperlink`_ |
| 475 |
|
| 476 |
Hyperlinks_, footnotes_, and citations_ all share the same namespace |
| 477 |
for reference names. [#substitution-text]_ |
| 478 |
This means that a footnote defined as "``.. [#note]``" can be referred to |
| 479 |
by the `footnote reference`_ ``[#note]_`` as well as a plain `hyperlink |
| 480 |
reference`_ ``note_``. Of course, each type of reference (hyperlink, |
| 481 |
footnote, citation) may be processed and rendered differently. Some |
| 482 |
care should be taken to avoid reference name conflicts. [#]_ |
| 483 |
|
| 484 |
.. [#substitution-text] |
| 485 |
`Substitution references`_ and `substitution definitions`_ |
| 486 |
use a different namespace. Matching is `case-sensitive but forgiving`_. |
| 487 |
|
| 488 |
.. [#] Docutils' rules for handling duplicate reference names are described |
| 489 |
in section `Implicit Hyperlink Targets`_. |
| 490 |
|
| 491 |
|
| 492 |
Document Structure |
| 493 |
================== |
| 494 |
|
| 495 |
.. raw:: html |
| 496 |
|
| 497 |
<style type="text/css"><!-- |
| 498 |
dl.field-list {--field-indent: 10em;} |
| 499 |
--></style> |
| 500 |
|
| 501 |
Document |
| 502 |
-------- |
| 503 |
|
| 504 |
:Doctree element: `\<document>`_ |
| 505 |
|
| 506 |
|
| 507 |
The top-level element of a parsed reStructuredText document is the |
| 508 |
"document" element. After initial parsing, the document element is a |
| 509 |
simple container for a document fragment, consisting of `body |
| 510 |
elements`_, transitions_, and sections_, but lacking a document title |
| 511 |
or other bibliographic elements. The code that calls the parser may |
| 512 |
choose to run one or more optional post-parse transforms_, |
| 513 |
rearranging the document fragment into a complete document with a |
| 514 |
title and possibly other metadata elements (author, date, etc.; see |
| 515 |
`Bibliographic Fields`_). |
| 516 |
|
| 517 |
Document Title |
| 518 |
`````````````` |
| 519 |
|
| 520 |
Specifically, there is no special syntax to indicate a *document title* |
| 521 |
and *subtitle* in reStructuredText. [#]_ |
| 522 |
Instead, a uniquely-adorned top-level `section title`_ can be treated as |
| 523 |
the document title. Similarly, a uniquely-adorned second-level section |
| 524 |
title immediately after the document title can become the document |
| 525 |
subtitle. The rest of the sections are then lifted up a level or two. |
| 526 |
See `A ReStructuredText Primer`__ for examples |
| 527 |
and the `DocTitle transform`_ for details. |
| 528 |
|
| 529 |
.. [#] The `"title"`_ directive sets the document's `metadata title`_ |
| 530 |
that does not become part of the document body. |
| 531 |
|
| 532 |
__ ../../user/rst/quickstart.html#document-title-subtitle |
| 533 |
|
| 534 |
Sections |
| 535 |
-------- |
| 536 |
|
| 537 |
:Doctree elements: `\<section>`_, `\<title>`_ |
| 538 |
|
| 539 |
.. _section title: |
| 540 |
.. _section titles: |
| 541 |
|
| 542 |
Sections are identified through their *titles*, which are marked up with |
| 543 |
adornment: "underlines" below the title text, or underlines and |
| 544 |
matching "overlines" above the title. An underline/overline is a |
| 545 |
single repeated punctuation character that begins in column 1 and |
| 546 |
forms a line extending at least as far as the right edge of the title |
| 547 |
text. [#]_ Specifically, an underline/overline character may be any |
| 548 |
non-alphanumeric printable 7-bit ASCII character [#]_. When an |
| 549 |
overline is used, the length and character used must match the |
| 550 |
underline. Underline-only adornment styles are distinct from |
| 551 |
overline-and-underline styles that use the same character. There may |
| 552 |
be any number of levels of section titles, although some output |
| 553 |
formats may have limits (HTML has 6 levels). |
| 554 |
|
| 555 |
.. [#] The key is the visual length of the title in a mono-spaced font. |
| 556 |
The adornment may need more or less characters than title, if the |
| 557 |
title contains wide__ or combining__ characters. |
| 558 |
|
| 559 |
.. [#] The following are all valid section title adornment |
| 560 |
characters:: |
| 561 |
|
| 562 |
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ |
| 563 |
|
| 564 |
Some characters are more suitable than others. The following are |
| 565 |
recommended:: |
| 566 |
|
| 567 |
= - ` : . ' " ~ ^ _ * + # |
| 568 |
|
| 569 |
__ https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#In_Unicode |
| 570 |
__ https://en.wikipedia.org/wiki/Combining_character |
| 571 |
|
| 572 |
Rather than imposing a fixed number and order of section title |
| 573 |
adornment styles, the order enforced will be the order as encountered. |
| 574 |
The first style encountered will be an outermost title (like HTML <H1>), |
| 575 |
the second style will be a subtitle, the third will be a subsubtitle, |
| 576 |
and so on. |
| 577 |
|
| 578 |
Below are examples of section title styles:: |
| 579 |
|
| 580 |
=============== |
| 581 |
Section Title |
| 582 |
=============== |
| 583 |
|
| 584 |
--------------- |
| 585 |
Section Title |
| 586 |
--------------- |
| 587 |
|
| 588 |
Section Title |
| 589 |
============= |
| 590 |
|
| 591 |
Section Title |
| 592 |
------------- |
| 593 |
|
| 594 |
Section Title |
| 595 |
````````````` |
| 596 |
|
| 597 |
Section Title |
| 598 |
''''''''''''' |
| 599 |
|
| 600 |
Section Title |
| 601 |
............. |
| 602 |
|
| 603 |
Section Title |
| 604 |
~~~~~~~~~~~~~ |
| 605 |
|
| 606 |
Section Title |
| 607 |
************* |
| 608 |
|
| 609 |
Section Title |
| 610 |
+++++++++++++ |
| 611 |
|
| 612 |
Section Title |
| 613 |
^^^^^^^^^^^^^ |
| 614 |
|
| 615 |
When a title has both an underline and an overline, the title text may |
| 616 |
be inset, as in the first two examples above. This is merely |
| 617 |
aesthetic and not significant. Underline-only title text may *not* be |
| 618 |
inset. |
| 619 |
|
| 620 |
A blank line after a title is optional. All text blocks up to the |
| 621 |
next title of the same or higher level are included in a section (or |
| 622 |
subsection, etc.). |
| 623 |
|
| 624 |
.. _title styles: |
| 625 |
|
| 626 |
All section title styles need not be used, nor need any specific |
| 627 |
section title style be used. However, a document must be consistent |
| 628 |
in its use of section titles: once a hierarchy of title styles is |
| 629 |
established, sections must use that hierarchy. [#]_ |
| 630 |
|
| 631 |
Each section title automatically generates a hyperlink target pointing |
| 632 |
to the section. The text of the hyperlink target (the "reference |
| 633 |
name") is the same as that of the section title. See `Implicit |
| 634 |
Hyperlink Targets`_ for a complete description. |
| 635 |
|
| 636 |
Sections may contain `body elements`_, transitions_, and nested |
| 637 |
sections. |
| 638 |
|
| 639 |
.. [#] Directives_ may establish a separate hierarchy of title styles |
| 640 |
for their content. This is handy for directives that include |
| 641 |
content from separate sources, e.g., the directives provided by |
| 642 |
the `"autodoc" Sphinx extension`__. |
| 643 |
|
| 644 |
__ https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html |
| 645 |
|
| 646 |
|
| 647 |
Transitions |
| 648 |
----------- |
| 649 |
|
| 650 |
:Doctree element: `\<transition>`_ |
| 651 |
|
| 652 |
Instead of subheads, extra space or a type ornament between |
| 653 |
paragraphs may be used to mark text divisions or to signal |
| 654 |
changes in subject or emphasis. |
| 655 |
|
| 656 |
(The Chicago Manual of Style, 14th edition, section 1.80) |
| 657 |
|
| 658 |
Transitions are commonly seen in novels and short fiction, as a gap |
| 659 |
spanning one or more lines, with or without a type ornament such as a |
| 660 |
row of asterisks. Transitions separate other body elements. A |
| 661 |
transition should not begin or end a section or document, nor should |
| 662 |
two transitions be immediately adjacent. |
| 663 |
|
| 664 |
The syntax for a transition marker is a horizontal line of 4 or more |
| 665 |
repeated punctuation characters. The syntax is the same as section |
| 666 |
title underlines without title text. Transition markers require blank |
| 667 |
lines before and after:: |
| 668 |
|
| 669 |
Para. |
| 670 |
|
| 671 |
---------- |
| 672 |
|
| 673 |
Para. |
| 674 |
|
| 675 |
Unlike section title underlines, no hierarchy of transition markers is |
| 676 |
enforced, nor do differences in transition markers accomplish |
| 677 |
anything. It is recommended that a single consistent style be used. |
| 678 |
|
| 679 |
The processing system is free to render transitions in output in any |
| 680 |
way it likes. For example, horizontal rules (``<hr>``) in HTML output |
| 681 |
would be an obvious choice. |
| 682 |
|
| 683 |
|
| 684 |
Body Elements |
| 685 |
============= |
| 686 |
|
| 687 |
.. _paragraph: |
| 688 |
|
| 689 |
Paragraphs |
| 690 |
---------- |
| 691 |
|
| 692 |
:Doctree element: `\<paragraph>`_ |
| 693 |
|
| 694 |
Paragraphs consist of blocks of left-aligned text with no markup |
| 695 |
indicating any other body element. Blank lines separate paragraphs |
| 696 |
from each other and from other body elements. Paragraphs may contain |
| 697 |
`inline markup`_. |
| 698 |
|
| 699 |
Syntax diagram:: |
| 700 |
|
| 701 |
+------------------------------+ |
| 702 |
| paragraph | |
| 703 |
| | |
| 704 |
+------------------------------+ |
| 705 |
|
| 706 |
+------------------------------+ |
| 707 |
| paragraph | |
| 708 |
| | |
| 709 |
+------------------------------+ |
| 710 |
|
| 711 |
|
| 712 |
.. _bullet list: |
| 713 |
|
| 714 |
Bullet Lists |
| 715 |
------------ |
| 716 |
|
| 717 |
:Doctree elements: `\<bullet_list>`_, `\<list_item>`_ |
| 718 |
|
| 719 |
A text block which begins with a ``*``, ``+``, ``-``, ``•``, ``‣``, or ``⁃``, |
| 720 |
followed by whitespace, is a bullet list item (a.k.a. "unordered" list |
| 721 |
item). List item bodies must be left-aligned and indented relative to |
| 722 |
the bullet; the text immediately after the bullet determines the |
| 723 |
indentation. For example:: |
| 724 |
|
| 725 |
- This is the first bullet list item. The blank line above the |
| 726 |
first list item is required; blank lines between list items |
| 727 |
(such as below this paragraph) are optional. |
| 728 |
|
| 729 |
- This is the first paragraph in the second item in the list. |
| 730 |
|
| 731 |
This is the second paragraph in the second item in the list. |
| 732 |
The blank line above this paragraph is required. The left edge |
| 733 |
of this paragraph lines up with the paragraph above, both |
| 734 |
indented relative to the bullet. |
| 735 |
|
| 736 |
- This is a sublist. The bullet lines up with the left edge of |
| 737 |
the text blocks above. A sublist is a new list so requires a |
| 738 |
blank line above and below. |
| 739 |
|
| 740 |
- This is the third item of the main list. |
| 741 |
|
| 742 |
This paragraph is not part of the list. |
| 743 |
|
| 744 |
Here are examples of **incorrectly** formatted bullet lists:: |
| 745 |
|
| 746 |
- This first line is fine. |
| 747 |
A blank line is required between list items and paragraphs. |
| 748 |
(Warning) |
| 749 |
|
| 750 |
- The following line appears to be a new sublist, but it is not: |
| 751 |
- This is a paragraph continuation, not a sublist (since there's |
| 752 |
no blank line). This line is also incorrectly indented. |
| 753 |
- Warnings may be issued by the implementation. |
| 754 |
|
| 755 |
Syntax diagram:: |
| 756 |
|
| 757 |
+------+-----------------------+ |
| 758 |
| "- " | list item | |
| 759 |
+------| (body elements)+ | |
| 760 |
+-----------------------+ |
| 761 |
|
| 762 |
|
| 763 |
Enumerated Lists |
| 764 |
---------------- |
| 765 |
|
| 766 |
:Doctree elements: `\<enumerated_list>`_, `\<list_item>`_ |
| 767 |
|
| 768 |
Enumerated lists (a.k.a. "ordered" lists) are similar to bullet lists, |
| 769 |
but use enumerators instead of bullets. An enumerator consists of an |
| 770 |
enumeration sequence member and formatting, followed by whitespace. |
| 771 |
The following *enumeration sequences* are recognized: |
| 772 |
|
| 773 |
- arabic numerals: 1, 2, 3, ... (no upper limit). |
| 774 |
- uppercase alphabet characters: A, B, C, ..., Z. |
| 775 |
- lower-case alphabet characters: a, b, c, ..., z. |
| 776 |
- uppercase Roman numerals: I, II, III, IV, ..., MMMMCMXCIX (4999). |
| 777 |
- lowercase Roman numerals: i, ii, iii, iv, ..., mmmmcmxcix (4999). |
| 778 |
|
| 779 |
In addition, the auto-enumerator, ``#``, may be used to automatically |
| 780 |
enumerate a list. Auto-enumerated lists may begin with explicit |
| 781 |
enumeration, which sets the sequence and start value. |
| 782 |
Fully auto-enumerated lists use arabic numerals and begin with 1. |
| 783 |
|
| 784 |
The following *formatting types* are recognized: |
| 785 |
|
| 786 |
- suffixed with a period: ``1.``, ``A.``, ``a.``, ``I.``, ``i.``. |
| 787 |
- surrounded by parentheses: ``(1)``, ``(A)``, ``(a)``, ``(I)``, ``(i)``. |
| 788 |
- suffixed with a right-parenthesis: ``1)``, ``A)``, ``a)``, ``I)``, ``i)``. |
| 789 |
|
| 790 |
While parsing an enumerated list, a new list will be started whenever: |
| 791 |
|
| 792 |
- An enumerator is encountered which does not have the same format and |
| 793 |
sequence type as the current list (e.g. ``1.``, ``(a)`` produces two |
| 794 |
separate lists). |
| 795 |
|
| 796 |
- The enumerators are not in sequence (e.g., ``1.``, ``3.`` produces two |
| 797 |
separate lists). |
| 798 |
|
| 799 |
It is recommended that the enumerator of the first list item be ordinal-1 |
| 800 |
(``1``, ``A``, ``a``, ``I``, or ``i``). |
| 801 |
Although other start-values will be recognized, they may not be supported |
| 802 |
by the output format. A level-1 [info] system message will be generated |
| 803 |
for any list beginning with a non-ordinal-1 enumerator. |
| 804 |
|
| 805 |
Lists using Roman numerals must begin with ``I``/``i`` or a |
| 806 |
multi-character value, such as ``II`` or ``XV``. Any other |
| 807 |
single-character Roman numeral (``V``, ``X``, ``L``, ``C``, ``D``, ``M``) |
| 808 |
will be interpreted as a letter of the alphabet, not as a Roman numeral. |
| 809 |
Likewise, lists using letters of the alphabet may not begin with |
| 810 |
``I``/``i``, since these are recognized as Roman numeral 1. |
| 811 |
|
| 812 |
The second line of each enumerated list item is checked for validity. |
| 813 |
This is to prevent ordinary paragraphs from being mistakenly |
| 814 |
interpreted as list items, when they happen to begin with text |
| 815 |
identical to enumerators. For example, this text is parsed as an |
| 816 |
ordinary paragraph:: |
| 817 |
|
| 818 |
A. Einstein was a really |
| 819 |
smart dude. |
| 820 |
|
| 821 |
However, ambiguity cannot be avoided if the paragraph consists of only |
| 822 |
one line. This text is parsed as an enumerated list item:: |
| 823 |
|
| 824 |
A. Einstein was a really smart dude. |
| 825 |
|
| 826 |
.. Caution:: |
| 827 |
If a single-line paragraph begins with text identical to an enumerator |
| 828 |
(``A.``, ``1.``, ``(b)``, ``I)``, etc.), the first character will have |
| 829 |
to be escaped in order to have the line parsed as an ordinary paragraph:: |
| 830 |
|
| 831 |
\A. Einstein was a really smart dude. |
| 832 |
|
| 833 |
Alternatively, you can escape the delimiter :: |
| 834 |
|
| 835 |
A\. Einstein was a really smart dude. |
| 836 |
|
| 837 |
or use a literal NO-BREAK SPACE after the initial. |
| 838 |
|
| 839 |
Examples of nested enumerated lists:: |
| 840 |
|
| 841 |
1. Item 1 initial text. |
| 842 |
|
| 843 |
a) Item 1a. |
| 844 |
b) Item 1b. |
| 845 |
|
| 846 |
2. a) Item 2a. |
| 847 |
b) Item 2b. |
| 848 |
|
| 849 |
Example syntax diagram:: |
| 850 |
|
| 851 |
+-------+----------------------+ |
| 852 |
| "1. " | list item | |
| 853 |
+-------| (body elements)+ | |
| 854 |
+----------------------+ |
| 855 |
|
| 856 |
|
| 857 |
Definition Lists |
| 858 |
---------------- |
| 859 |
|
| 860 |
:Doctree elements: `\<definition_list>`_, `\<definition_list_item>`_, |
| 861 |
`\<term>`_, `\<classifier>`_, `\<definition>`_ |
| 862 |
|
| 863 |
Each definition list item contains a term, optional classifiers, and a |
| 864 |
definition. |
| 865 |
|
| 866 |
* A `term` is a simple one-line word or phrase. Escape_ a leading hyphen |
| 867 |
to prevent recognition as an `option list`_ item. |
| 868 |
|
| 869 |
* Optional `classifiers` may follow the term on the same line, each after |
| 870 |
an inline :literal:`\ : \ ` (space, colon, space). |
| 871 |
Inline markup is parsed in the term line before the classifier |
| 872 |
delimiters are recognized. A delimiter will only be recognized if it |
| 873 |
appears outside of any inline markup. |
| 874 |
|
| 875 |
* A `definition` is a block indented relative to the term, and may |
| 876 |
contain multiple paragraphs and other body elements. There may be no |
| 877 |
blank line between a term line and a definition block (this |
| 878 |
distinguishes definition lists from `block quotes`_). Blank lines are |
| 879 |
required before the first and after the last definition list item, but |
| 880 |
are optional in-between. |
| 881 |
|
| 882 |
Example:: |
| 883 |
|
| 884 |
term 1 |
| 885 |
Definition 1. |
| 886 |
|
| 887 |
term 2 |
| 888 |
Definition 2, paragraph 1. |
| 889 |
|
| 890 |
Definition 2, paragraph 2. |
| 891 |
|
| 892 |
term 3 : classifier |
| 893 |
Definition 3. |
| 894 |
|
| 895 |
term 4 : classifier one : classifier two |
| 896 |
Definition 4. |
| 897 |
|
| 898 |
\-term 5 |
| 899 |
Without escaping, this would be an option list item. |
| 900 |
|
| 901 |
A definition list may be used in various ways, including: |
| 902 |
|
| 903 |
- As a dictionary or glossary. The term is the word itself, a |
| 904 |
classifier may be used to indicate the usage of the term (noun, |
| 905 |
verb, etc.), and the definition follows. |
| 906 |
|
| 907 |
- To describe program variables. The term is the variable name, a |
| 908 |
classifier may be used to indicate the type of the variable (string, |
| 909 |
integer, etc.), and the definition describes the variable's use in |
| 910 |
the program. This usage of definition lists supports the classifier |
| 911 |
syntax of Grouch_, a system for describing and enforcing a Python |
| 912 |
object schema. |
| 913 |
|
| 914 |
Syntax diagram:: |
| 915 |
|
| 916 |
+----------------------------+ |
| 917 |
| term [ " : " classifier ]* | |
| 918 |
+--+-------------------------+--+ |
| 919 |
| definition | |
| 920 |
| (body elements)+ | |
| 921 |
+----------------------------+ |
| 922 |
|
| 923 |
|
| 924 |
Field Lists |
| 925 |
----------- |
| 926 |
|
| 927 |
:Doctree elements: `\<field_list>`_, `\<field>`_, |
| 928 |
`\<field_name>`_, `\<field_body>`_ |
| 929 |
|
| 930 |
Field lists are used as part of an extension syntax, such as options |
| 931 |
for directives_, or database-like records meant for further |
| 932 |
processing. They may also be used for two-column table-like |
| 933 |
structures resembling database records (label & data pairs). |
| 934 |
Applications of reStructuredText may recognize field names and |
| 935 |
transform fields or field bodies in certain contexts. For examples, |
| 936 |
see `Bibliographic Fields`_ or `directive options`_ below or the |
| 937 |
`"meta"`_ directive. |
| 938 |
|
| 939 |
.. _field names: |
| 940 |
|
| 941 |
Field lists are mappings from *field names* to *field bodies*, modeled on |
| 942 |
RFC822_ headers. A field name may consist of any characters, but |
| 943 |
colons (``:``) inside of field names must be backslash-escaped |
| 944 |
when followed by whitespace.\ [#]_ |
| 945 |
Inline markup is parsed in field names, but care must be taken when |
| 946 |
using `interpreted text`_ with explicit roles in field names: the role |
| 947 |
must be a suffix to the interpreted text. Field names are |
| 948 |
case-insensitive when further processed or transformed. The field |
| 949 |
name, along with a single colon prefix and suffix, together form the |
| 950 |
field marker. The field marker is followed by whitespace and the |
| 951 |
field body. The field body may contain multiple body elements, |
| 952 |
indented relative to the field marker. The first line after the field |
| 953 |
name marker determines the indentation of the field body. For |
| 954 |
example:: |
| 955 |
|
| 956 |
:Date: 2001-08-16 |
| 957 |
:Version: 1 |
| 958 |
:Authors: - Me |
| 959 |
- Myself |
| 960 |
- I |
| 961 |
:Indentation: Since the field marker may be quite long, the second |
| 962 |
and subsequent lines of the field body do not have to line up |
| 963 |
with the first line, but they must be indented relative to the |
| 964 |
field name marker, and they must line up with each other. |
| 965 |
:Parameter i: integer |
| 966 |
|
| 967 |
The interpretation of individual words in a multi-word field name is |
| 968 |
up to the application. The application may specify a syntax for the |
| 969 |
field name. For example, second and subsequent words may be treated |
| 970 |
as "arguments", quoted phrases may be treated as a single argument, |
| 971 |
and direct support for the "name=value" syntax may be added. |
| 972 |
|
| 973 |
Standard RFC822_ headers cannot be used for this construct because |
| 974 |
they are ambiguous. A word followed by a colon at the beginning of a |
| 975 |
line is common in written text. However, in well-defined contexts |
| 976 |
such as when a field list invariably occurs at the beginning of a |
| 977 |
document (PEPs and email messages), standard RFC822 headers could be |
| 978 |
used. |
| 979 |
|
| 980 |
Syntax diagram (simplified):: |
| 981 |
|
| 982 |
+--------------------+----------------------+ |
| 983 |
| ":" field name ":" | field body | |
| 984 |
+-------+------------+ | |
| 985 |
| (body elements)+ | |
| 986 |
+-----------------------------------+ |
| 987 |
|
| 988 |
.. [#] Up to Docutils 0.14, field markers were not recognized when |
| 989 |
containing a colon. |
| 990 |
|
| 991 |
Bibliographic Fields |
| 992 |
```````````````````` |
| 993 |
|
| 994 |
:Doctree elements: `\<docinfo>`_, `\<address>`_, `\<author>`_, |
| 995 |
`\<authors>`_, `\<contact>`_, `\<copyright>`_, |
| 996 |
`\<date>`_, `\<organization>`_, `\<revision>`_, |
| 997 |
`\<status>`_, `\<topic>`_, `\<version>`_ |
| 998 |
|
| 999 |
When a field list is the document body's first element [#PreBibliographic]_, |
| 1000 |
it may have its fields transformed to bibliographic data |
| 1001 |
by the `DocInfo transform`_. |
| 1002 |
This bibliographic data corresponds to the front matter of a book, |
| 1003 |
such as the title page and copyright page. |
| 1004 |
|
| 1005 |
.. [#PreBibliographic] |
| 1006 |
A `document title`_, header and footer as well as elements that |
| 1007 |
do not show up in the output before the bibliographic fields don't |
| 1008 |
count. See `PreBibliographic Elements`_ for details. |
| 1009 |
|
| 1010 |
Certain registered field names (listed below) are recognized and |
| 1011 |
transformed to the corresponding doctree elements, most becoming child |
| 1012 |
elements of the `\<docinfo>`_ element. No ordering is required of these |
| 1013 |
fields, although they may be rearranged to fit the document structure, |
| 1014 |
as noted. Unless otherwise indicated below, each of the bibliographic |
| 1015 |
elements' field bodies may contain a single paragraph only. Field |
| 1016 |
bodies may be checked for `RCS keywords`_ and cleaned up. Any |
| 1017 |
unrecognized fields will remain as generic fields in the docinfo |
| 1018 |
element. |
| 1019 |
|
| 1020 |
.. _bibliographic field names: |
| 1021 |
|
| 1022 |
The registered bibliographic field names and their corresponding |
| 1023 |
doctree elements are as follows: |
| 1024 |
|
| 1025 |
=================== ================ |
| 1026 |
field name [#i18n]_ doctree element |
| 1027 |
=================== ================ |
| 1028 |
Abstract `\<topic>`_ |
| 1029 |
Address `\<address>`_ |
| 1030 |
Author `\<author>`_ |
| 1031 |
Authors `\<authors>`_ |
| 1032 |
Contact `\<contact>`_ |
| 1033 |
Copyright `\<copyright>`_ |
| 1034 |
Date `\<date>`_ |
| 1035 |
Dedication `\<topic>`_ |
| 1036 |
Organization `\<organization>`_ |
| 1037 |
Revision `\<revision>`_ |
| 1038 |
Status `\<status>`_ |
| 1039 |
Version `\<version>`_ |
| 1040 |
=================== ================ |
| 1041 |
|
| 1042 |
.. compound:: |
| 1043 |
:name: authors |
| 1044 |
|
| 1045 |
The **Authors** field may contain |
| 1046 |
|
| 1047 |
* a single paragraph_ consisting of a list of authors, separated by |
| 1048 |
``;`` or ``,`` [#i18n]_ (the semicolon is checked first, so |
| 1049 |
``Doe, Jane; Doe, John`` will work), |
| 1050 |
* multiple paragraphs_ (one per author), or |
| 1051 |
* a `bullet list`_ whose elements each contain a single paragraph |
| 1052 |
per author. |
| 1053 |
|
| 1054 |
.. attention:: Extracting author names from a single paragraph drops |
| 1055 |
inline markup! To keep, e.g., footnotes or emphasized name parts, |
| 1056 |
use multiple paragraphs or a bullet list. |
| 1057 |
|
| 1058 |
As a convention, use an "Authors" field for authors with common |
| 1059 |
affiliation and separate "Author" fields (each followed by the |
| 1060 |
respective "Organization", "Address", and/or "Contact" fields) for |
| 1061 |
authors with distinct affiliations. |
| 1062 |
There is currently no way to represent the organization or |
| 1063 |
contact info of an individual author in an "Authors" field. |
| 1064 |
|
| 1065 |
In some languages (e.g. Swedish), there is no singular/plural distinction |
| 1066 |
between "Author" and "Authors", so only an "Authors" field is provided, |
| 1067 |
and a single name is interpreted as an "Author". If a single name |
| 1068 |
contains a comma, end it with a semicolon or use a one-item |
| 1069 |
`bullet list`_ to disambiguate:: |
| 1070 |
|
| 1071 |
:Författare: * Larsson, Lars |
| 1072 |
|
| 1073 |
The **Address** field is for a multi-line surface mailing address. |
| 1074 |
Newlines will be preserved. |
| 1075 |
|
| 1076 |
The **Dedication** and **Abstract** fields may contain arbitrary body |
| 1077 |
elements. Only one of each is allowed. They become `\<topic>`_ elements |
| 1078 |
with "Dedication" or "Abstract" titles (or language equivalents) [#i18n]_ |
| 1079 |
immediately following the `\<docinfo>`_ element. |
| 1080 |
|
| 1081 |
**Unregistered/generic fields** may contain one or more paragraphs or |
| 1082 |
arbitrary body elements. To support custom styling, the field name is |
| 1083 |
also added to the `"classes" attribute`_ value after an `identifier |
| 1084 |
normalization`_. |
| 1085 |
|
| 1086 |
.. [#i18n] Docutils supports localised bibliographic field names and |
| 1087 |
author separators. See the language_code_ setting and, for details, |
| 1088 |
`Docutils Internationalization`_ |
| 1089 |
|
| 1090 |
|
| 1091 |
RCS Keywords |
| 1092 |
```````````` |
| 1093 |
|
| 1094 |
`Bibliographic fields`_ recognized by the parser are normally checked |
| 1095 |
for RCS [#]_ keywords and cleaned up [#]_. RCS keywords may be |
| 1096 |
entered into source files as "$keyword$", and once stored under RCS, |
| 1097 |
CVS [#]_, or SVN [#]_, they are expanded to "$keyword: expansion text $". |
| 1098 |
For example, a "Status" field will be transformed to a "status" element:: |
| 1099 |
|
| 1100 |
:Status: $keyword: expansion text $ |
| 1101 |
|
| 1102 |
.. [#] Revision Control System. |
| 1103 |
.. [#] RCS keyword processing can be turned off (unimplemented). |
| 1104 |
.. [#] Concurrent Versions System. CVS uses the same keywords as RCS. |
| 1105 |
.. [#] Subversion Versions System. Uses the same keywords as RCS. |
| 1106 |
|
| 1107 |
Processed, the "status" element's text will become simply "expansion |
| 1108 |
text". The dollar sign delimiters and leading RCS keyword name are |
| 1109 |
removed. |
| 1110 |
|
| 1111 |
The RCS keyword processing only kicks in when the field list is in |
| 1112 |
bibliographic context (first non-comment construct in the document, |
| 1113 |
after a document title if there is one). |
| 1114 |
|
| 1115 |
.. _option list: |
| 1116 |
|
| 1117 |
Option Lists |
| 1118 |
------------ |
| 1119 |
|
| 1120 |
:Doctree elements: `\<option_list>`_, `\<option_list_item>`_, |
| 1121 |
`\<option_group>`_, `\<option>`_, `\<option_string>`_, |
| 1122 |
`\<option_argument>`_, `\<description>`_ |
| 1123 |
|
| 1124 |
Option lists map a program's command-line options to descriptions |
| 1125 |
documenting them. For example:: |
| 1126 |
|
| 1127 |
-a Output all. |
| 1128 |
-c arg Output just arg. |
| 1129 |
--long Output all day long. |
| 1130 |
/V A VMS/DOS-style option. |
| 1131 |
|
| 1132 |
-p This option has two paragraphs in the description. |
| 1133 |
This is the first. |
| 1134 |
|
| 1135 |
This is the second. |
| 1136 |
Blank lines may be omitted between options |
| 1137 |
(as above) or left in (as here and below). |
| 1138 |
|
| 1139 |
--very-long-option A VMS-style option. Note the adjustment |
| 1140 |
for the required two spaces. |
| 1141 |
|
| 1142 |
--an-even-longer-option |
| 1143 |
The description can also start on the next line. |
| 1144 |
|
| 1145 |
-2, --two This option has two variants. |
| 1146 |
|
| 1147 |
-f FILE, --file=FILE These two options are synonyms; both have |
| 1148 |
arguments. |
| 1149 |
|
| 1150 |
-f <[path]file> Option argument placeholders must start with |
| 1151 |
a letter or be wrapped in angle brackets. |
| 1152 |
|
| 1153 |
-d <src dest> Angle brackets are also required if an option |
| 1154 |
expects more than one argument. |
| 1155 |
|
| 1156 |
There are several types of options recognized by reStructuredText: |
| 1157 |
|
| 1158 |
- Short POSIX options consist of one dash and an option letter. |
| 1159 |
- Long POSIX options consist of two dashes and an option word; some |
| 1160 |
systems use a single dash. |
| 1161 |
- Old GNU-style "plus" options consist of one plus and an option |
| 1162 |
letter ("plus" options are deprecated now, their use discouraged). |
| 1163 |
- DOS/VMS options consist of a slash and an option letter or word. |
| 1164 |
|
| 1165 |
Please note that both POSIX-style and DOS/VMS-style options may be |
| 1166 |
used by DOS or Windows software. These and other variations are |
| 1167 |
sometimes used mixed together. The names above have been chosen for |
| 1168 |
convenience only. |
| 1169 |
|
| 1170 |
The syntax for short and long POSIX options is based on the syntax |
| 1171 |
supported by Python's getopt.py_ module, which implements an option |
| 1172 |
parser similar to the `GNU libc getopt_long()`_ function but with some |
| 1173 |
restrictions. There are many variant option systems, and |
| 1174 |
reStructuredText option lists do not support all of them. |
| 1175 |
|
| 1176 |
Although long POSIX and DOS/VMS option words may be allowed to be |
| 1177 |
truncated by the operating system or the application when used on the |
| 1178 |
command line, reStructuredText option lists do not show or support |
| 1179 |
this with any special syntax. The complete option word should be |
| 1180 |
given, supported by notes about truncation if and when applicable. |
| 1181 |
|
| 1182 |
Options may be followed by an argument placeholder, whose role and |
| 1183 |
syntax should be explained in the description text. |
| 1184 |
Either a space or an equals sign may be used as a delimiter between long |
| 1185 |
options and option argument placeholders; |
| 1186 |
short options (``-`` or ``+`` prefix only) use a space or omit the delimiter. |
| 1187 |
Option arguments may take one of two forms: |
| 1188 |
|
| 1189 |
- Begins with a letter (``[a-zA-Z]``) and subsequently consists of |
| 1190 |
letters, numbers, underscores and hyphens (``[a-zA-Z0-9_-]``). |
| 1191 |
- Begins with an open-angle-bracket (``<``) and ends with a |
| 1192 |
close-angle-bracket (``>``); any characters except angle brackets |
| 1193 |
are allowed internally. |
| 1194 |
|
| 1195 |
Multiple option "synonyms" may be listed, sharing a single |
| 1196 |
description. They must be separated by comma-space. |
| 1197 |
|
| 1198 |
There must be at least two spaces between the option(s) and the |
| 1199 |
description (which can also start on the next line). The description |
| 1200 |
may contain multiple body elements. |
| 1201 |
The first line after the option marker determines the indentation of the |
| 1202 |
description. As with other types of lists, blank lines are required |
| 1203 |
before the first option list item and after the last, but are optional |
| 1204 |
between option entries. |
| 1205 |
|
| 1206 |
Syntax diagram (simplified):: |
| 1207 |
|
| 1208 |
+----------------------------+-------------+ |
| 1209 |
| option [" " argument] " " | description | |
| 1210 |
+-------+--------------------+ | |
| 1211 |
| (body elements)+ | |
| 1212 |
+----------------------------------+ |
| 1213 |
|
| 1214 |
|
| 1215 |
Literal Blocks |
| 1216 |
-------------- |
| 1217 |
|
| 1218 |
:Doctree element: `\<literal_block>`_ |
| 1219 |
|
| 1220 |
A paragraph consisting of two colons (``::``) signifies that the |
| 1221 |
following text block(s) comprise a literal block. The literal block |
| 1222 |
must either be indented or quoted (see below). No markup processing |
| 1223 |
is done within a literal block. It is left as-is, and is typically |
| 1224 |
rendered in a monospaced typeface:: |
| 1225 |
|
| 1226 |
This is a typical paragraph. An indented literal block follows. |
| 1227 |
|
| 1228 |
:: |
| 1229 |
|
| 1230 |
for a in [5,4,3,2,1]: # this is program code, shown as-is |
| 1231 |
print a |
| 1232 |
print "it's..." |
| 1233 |
# a literal block continues until the indentation ends |
| 1234 |
|
| 1235 |
This text has returned to the indentation of the first paragraph, |
| 1236 |
is outside of the literal block, and is therefore treated as an |
| 1237 |
ordinary paragraph. |
| 1238 |
|
| 1239 |
The paragraph containing only ``::`` will be completely removed from the |
| 1240 |
output; no empty paragraph will remain. |
| 1241 |
|
| 1242 |
As a convenience, the ``::`` is also recognized at the end of any paragraph. |
| 1243 |
If immediately preceded by whitespace, both colons will be removed |
| 1244 |
from the output (this is the "partially minimized" form). When text |
| 1245 |
immediately precedes the ``::``, *one* colon will be removed from the |
| 1246 |
output, leaving only one colon visible (i.e., ``::`` will be replaced by |
| 1247 |
``:``; this is the "fully minimized" form). |
| 1248 |
|
| 1249 |
In other words, these are all equivalent (please pay attention to the |
| 1250 |
colons after "Paragraph"): |
| 1251 |
|
| 1252 |
1. Expanded form:: |
| 1253 |
|
| 1254 |
Paragraph: |
| 1255 |
|
| 1256 |
:: |
| 1257 |
|
| 1258 |
Literal block |
| 1259 |
|
| 1260 |
2. Partially minimized form:: |
| 1261 |
|
| 1262 |
Paragraph: :: |
| 1263 |
|
| 1264 |
Literal block |
| 1265 |
|
| 1266 |
3. Fully minimized form:: |
| 1267 |
|
| 1268 |
Paragraph:: |
| 1269 |
|
| 1270 |
Literal block |
| 1271 |
|
| 1272 |
All whitespace (including line breaks, but excluding minimum |
| 1273 |
indentation for indented literal blocks) is preserved. Blank lines |
| 1274 |
are required before and after a literal block, but these blank lines |
| 1275 |
are not included as part of the literal block. |
| 1276 |
|
| 1277 |
|
| 1278 |
Indented Literal Blocks |
| 1279 |
``````````````````````` |
| 1280 |
|
| 1281 |
Indented literal blocks are indicated by indentation relative to the |
| 1282 |
surrounding text (leading whitespace on each line). The minimum |
| 1283 |
indentation will be removed from each line of an indented literal |
| 1284 |
block. The literal block need not be contiguous; blank lines are |
| 1285 |
allowed between sections of indented text. The literal block ends |
| 1286 |
with the end of the indentation. |
| 1287 |
|
| 1288 |
Syntax diagram:: |
| 1289 |
|
| 1290 |
+------------------------------+ |
| 1291 |
| paragraph | |
| 1292 |
| (ends with "::") | |
| 1293 |
+------------------------------+ |
| 1294 |
+---------------------------+ |
| 1295 |
| indented literal block | |
| 1296 |
+---------------------------+ |
| 1297 |
|
| 1298 |
|
| 1299 |
Quoted Literal Blocks |
| 1300 |
````````````````````` |
| 1301 |
|
| 1302 |
Quoted literal blocks are unindented contiguous blocks of text where |
| 1303 |
each line begins with the same non-alphanumeric printable 7-bit ASCII |
| 1304 |
character [#]_. A blank line ends a quoted literal block. The |
| 1305 |
quoting characters are preserved in the processed document. |
| 1306 |
|
| 1307 |
.. [#] |
| 1308 |
The following are all valid quoting characters:: |
| 1309 |
|
| 1310 |
! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ |
| 1311 |
|
| 1312 |
Note that these are the same characters as are valid for title |
| 1313 |
adornment of sections_. |
| 1314 |
|
| 1315 |
Possible uses include literate programming in Haskell and email |
| 1316 |
quoting:: |
| 1317 |
|
| 1318 |
John Doe wrote:: |
| 1319 |
|
| 1320 |
>> Great idea! |
| 1321 |
> |
| 1322 |
> Why didn't I think of that? |
| 1323 |
|
| 1324 |
You just did! ;-) |
| 1325 |
|
| 1326 |
Syntax diagram:: |
| 1327 |
|
| 1328 |
+------------------------------+ |
| 1329 |
| paragraph | |
| 1330 |
| (ends with "::") | |
| 1331 |
+------------------------------+ |
| 1332 |
+------------------------------+ |
| 1333 |
| ">" per-line-quoted | |
| 1334 |
| ">" contiguous literal block | |
| 1335 |
+------------------------------+ |
| 1336 |
|
| 1337 |
|
| 1338 |
Line Blocks |
| 1339 |
----------- |
| 1340 |
|
| 1341 |
:Doctree elements: `\<line_block>`_, `\<line>`_ |
| 1342 |
|
| 1343 |
Line blocks are useful for address blocks, verse (poetry, song |
| 1344 |
lyrics), and unadorned lists, where the structure of lines is |
| 1345 |
significant. Line blocks are groups of lines beginning with vertical |
| 1346 |
bar (``|``) prefixes. Each vertical bar prefix indicates a new line, so |
| 1347 |
line breaks are preserved. Initial indents are also significant, |
| 1348 |
resulting in a nested structure. Inline markup is supported. |
| 1349 |
Continuation lines are wrapped portions of long lines; they begin with |
| 1350 |
a space in place of the vertical bar. The left edge of a continuation |
| 1351 |
line must be indented, but need not be aligned with the left edge of |
| 1352 |
the text above it. A line block ends with a blank line. |
| 1353 |
|
| 1354 |
This example illustrates continuation lines:: |
| 1355 |
|
| 1356 |
| Lend us a couple of bob till Thursday. |
| 1357 |
| I'm absolutely skint. |
| 1358 |
| But I'm expecting a postal order and I can pay you back |
| 1359 |
as soon as it comes. |
| 1360 |
| Love, Ewan. |
| 1361 |
|
| 1362 |
This example illustrates the nesting of line blocks, indicated by the |
| 1363 |
initial indentation of new lines:: |
| 1364 |
|
| 1365 |
Take it away, Eric the Orchestra Leader! |
| 1366 |
|
| 1367 |
| A one, two, a one two three four |
| 1368 |
| |
| 1369 |
| Half a bee, philosophically, |
| 1370 |
| must, *ipso facto*, half not be. |
| 1371 |
| But half the bee has got to be, |
| 1372 |
| *vis a vis* its entity. D'you see? |
| 1373 |
| |
| 1374 |
| But can a bee be said to be |
| 1375 |
| or not to be an entire bee, |
| 1376 |
| when half the bee is not a bee, |
| 1377 |
| due to some ancient injury? |
| 1378 |
| |
| 1379 |
| Singing... |
| 1380 |
|
| 1381 |
Syntax diagram:: |
| 1382 |
|
| 1383 |
+------+-----------------------+ |
| 1384 |
| "| " | line | |
| 1385 |
+------| continuation line | |
| 1386 |
+-----------------------+ |
| 1387 |
|
| 1388 |
|
| 1389 |
Block Quotes |
| 1390 |
------------ |
| 1391 |
|
| 1392 |
:Doctree elements: `\<block_quote>`_, `\<attribution>`_ |
| 1393 |
|
| 1394 |
A text block that is indented relative to the preceding text, without |
| 1395 |
preceding markup indicating it to be a literal block or other content, |
| 1396 |
is a block quote. All markup processing (for body elements and inline |
| 1397 |
markup) continues within the block quote:: |
| 1398 |
|
| 1399 |
This is an ordinary paragraph, introducing a block quote. |
| 1400 |
|
| 1401 |
"It is my business to know things. That is my trade." |
| 1402 |
|
| 1403 |
-- Sherlock Holmes |
| 1404 |
|
| 1405 |
A block quote may end with an _`attribution`: a paragraph beginning with |
| 1406 |
``--``, ``---``, or a true em-dash, flush left within the block quote. If |
| 1407 |
the attribution consists of multiple lines, the left edges of the |
| 1408 |
second and subsequent lines must align. |
| 1409 |
|
| 1410 |
Multiple block quotes may occur consecutively if terminated with |
| 1411 |
attributions. |
| 1412 |
|
| 1413 |
Unindented paragraph. |
| 1414 |
|
| 1415 |
Block quote 1. |
| 1416 |
|
| 1417 |
-- Attribution 1 |
| 1418 |
|
| 1419 |
Block quote 2. |
| 1420 |
|
| 1421 |
`Empty comments`_ may be used to explicitly terminate preceding |
| 1422 |
constructs that would otherwise consume a block quote:: |
| 1423 |
|
| 1424 |
* List item. |
| 1425 |
|
| 1426 |
.. |
| 1427 |
|
| 1428 |
Block quote 3. |
| 1429 |
|
| 1430 |
Empty comments may also be used to separate block quotes:: |
| 1431 |
|
| 1432 |
Block quote 4. |
| 1433 |
|
| 1434 |
.. |
| 1435 |
|
| 1436 |
Block quote 5. |
| 1437 |
|
| 1438 |
Blank lines are required before and after a block quote, but these |
| 1439 |
blank lines are not included as part of the block quote. |
| 1440 |
|
| 1441 |
Syntax diagram:: |
| 1442 |
|
| 1443 |
+------------------------------+ |
| 1444 |
| (current level of | |
| 1445 |
| indentation) | |
| 1446 |
+------------------------------+ |
| 1447 |
+---------------------------+ |
| 1448 |
| block quote | |
| 1449 |
| (body elements)+ | |
| 1450 |
| | |
| 1451 |
| -- attribution text | |
| 1452 |
| (optional) | |
| 1453 |
+---------------------------+ |
| 1454 |
|
| 1455 |
|
| 1456 |
Doctest Blocks |
| 1457 |
-------------- |
| 1458 |
|
| 1459 |
:Doctree element: `\<doctest_block>`_ |
| 1460 |
|
| 1461 |
Doctest blocks are interactive Python sessions cut-and-pasted into |
| 1462 |
docstrings. They are meant to illustrate usage by example, and |
| 1463 |
provide an elegant and powerful testing environment via the `doctest |
| 1464 |
module`_ in the Python standard library. |
| 1465 |
|
| 1466 |
Doctest blocks are text blocks which begin with the Python interactive |
| 1467 |
interpreter main prompt (``>>>`` followed by a space) and end with |
| 1468 |
a blank line. Doctest blocks are treated as a special case of literal |
| 1469 |
blocks, without requiring the literal block syntax. If both are present, |
| 1470 |
the literal block syntax takes priority over Doctest block syntax:: |
| 1471 |
|
| 1472 |
This is an ordinary paragraph. |
| 1473 |
|
| 1474 |
>>> print 'this is a Doctest block' |
| 1475 |
this is a Doctest block |
| 1476 |
|
| 1477 |
The following is a literal block:: |
| 1478 |
|
| 1479 |
>>> This is not recognized as a doctest block by |
| 1480 |
reStructuredText. It *will* be recognized by the doctest |
| 1481 |
module, though! |
| 1482 |
|
| 1483 |
Indentation is not required for doctest blocks. |
| 1484 |
|
| 1485 |
|
| 1486 |
Tables |
| 1487 |
------ |
| 1488 |
|
| 1489 |
:Doctree elements: `\<table>`_, `\<tgroup>`_, `\<colspec>`_, `\<thead>`_, |
| 1490 |
`\<tbody>`_, `\<row>`_, `\<entry>`_ |
| 1491 |
|
| 1492 |
ReStructuredText provides two syntax variants for delineating table |
| 1493 |
cells: `Grid Tables`_ and `Simple Tables`_. Tables are also generated by |
| 1494 |
the `"csv-table"`_ and `"list-table"`_ directives. The `"table"`_ directive |
| 1495 |
is used to add a table title, caption, or specify options. |
| 1496 |
|
| 1497 |
As with other body elements, blank lines are required before and after |
| 1498 |
tables. Tables' left edges should align with the left edge of |
| 1499 |
preceding text blocks; if indented, the table is considered to be part |
| 1500 |
of a block quote. |
| 1501 |
|
| 1502 |
Once isolated, each table cell is treated as a miniature document; the |
| 1503 |
top and bottom cell boundaries act as delimiting blank lines. Each |
| 1504 |
cell contains zero or more body elements. Cell contents may include |
| 1505 |
left and/or right margins, which are removed before processing. |
| 1506 |
|
| 1507 |
|
| 1508 |
Grid Tables |
| 1509 |
``````````` |
| 1510 |
|
| 1511 |
Grid tables provide a complete table representation via grid-like |
| 1512 |
"ASCII art". Grid tables allow arbitrary cell contents (body |
| 1513 |
elements), and both row and column spans. However, grid tables can be |
| 1514 |
cumbersome to produce, especially for simple data sets. The `Emacs |
| 1515 |
table mode`_ is a tool that allows easy editing of grid tables, in |
| 1516 |
Emacs. See `Simple Tables`_ for a simpler (but limited) |
| 1517 |
representation. |
| 1518 |
|
| 1519 |
Grid tables are described with a visual grid made up of the characters |
| 1520 |
``-``, ``=``, ``|``, and ``+``. |
| 1521 |
The hyphen (``-``) is used for horizontal lines (row separators). |
| 1522 |
The equals sign (``=``) may be used to separate optional header rows |
| 1523 |
from the table body (not supported by the `Emacs table mode`_). |
| 1524 |
The vertical bar (``|``) is used for vertical lines (column separators). |
| 1525 |
The plus sign (``+``) is used for intersections of horizontal and |
| 1526 |
vertical lines. Example:: |
| 1527 |
|
| 1528 |
+------------------------+------------+----------+----------+ |
| 1529 |
| Header row, column 1 | Header 2 | Header 3 | Header 4 | |
| 1530 |
| (header rows optional) | | | | |
| 1531 |
+========================+============+==========+==========+ |
| 1532 |
| body row 1, column 1 | column 2 | column 3 | column 4 | |
| 1533 |
+------------------------+------------+----------+----------+ |
| 1534 |
| body row 2 | Cells may span columns. | |
| 1535 |
+------------------------+------------+---------------------+ |
| 1536 |
| body row 3 | Cells may | - Table cells | |
| 1537 |
+------------------------+ span rows. | - contain | |
| 1538 |
| body row 4 | | - body elements. | |
| 1539 |
+------------------------+------------+---------------------+ |
| 1540 |
|
| 1541 |
Some care must be taken with grid tables to avoid undesired |
| 1542 |
interactions with cell text in rare cases. For example, the following |
| 1543 |
table contains a cell in row 2 spanning from column 2 to column 4:: |
| 1544 |
|
| 1545 |
+--------------+----------+-----------+-----------+ |
| 1546 |
| row 1, col 1 | column 2 | column 3 | column 4 | |
| 1547 |
+--------------+----------+-----------+-----------+ |
| 1548 |
| row 2 | | |
| 1549 |
+--------------+----------+-----------+-----------+ |
| 1550 |
| row 3 | | | | |
| 1551 |
+--------------+----------+-----------+-----------+ |
| 1552 |
|
| 1553 |
If a vertical bar is used in the text of that cell, it could have |
| 1554 |
unintended effects if accidentally aligned with column boundaries:: |
| 1555 |
|
| 1556 |
+--------------+----------+-----------+-----------+ |
| 1557 |
| row 1, col 1 | column 2 | column 3 | column 4 | |
| 1558 |
+--------------+----------+-----------+-----------+ |
| 1559 |
| row 2 | Use the command ``ls | more``. | |
| 1560 |
+--------------+----------+-----------+-----------+ |
| 1561 |
| row 3 | | | | |
| 1562 |
+--------------+----------+-----------+-----------+ |
| 1563 |
|
| 1564 |
Several solutions are possible. All that is needed is to break the |
| 1565 |
continuity of the cell outline rectangle. One possibility is to shift |
| 1566 |
the text by adding an extra space before:: |
| 1567 |
|
| 1568 |
+--------------+----------+-----------+-----------+ |
| 1569 |
| row 1, col 1 | column 2 | column 3 | column 4 | |
| 1570 |
+--------------+----------+-----------+-----------+ |
| 1571 |
| row 2 | Use the command ``ls | more``. | |
| 1572 |
+--------------+----------+-----------+-----------+ |
| 1573 |
| row 3 | | | | |
| 1574 |
+--------------+----------+-----------+-----------+ |
| 1575 |
|
| 1576 |
Another possibility is to add an extra line to row 2:: |
| 1577 |
|
| 1578 |
+--------------+----------+-----------+-----------+ |
| 1579 |
| row 1, col 1 | column 2 | column 3 | column 4 | |
| 1580 |
+--------------+----------+-----------+-----------+ |
| 1581 |
| row 2 | Use the command ``ls | more``. | |
| 1582 |
| | | |
| 1583 |
+--------------+----------+-----------+-----------+ |
| 1584 |
| row 3 | | | | |
| 1585 |
+--------------+----------+-----------+-----------+ |
| 1586 |
|
| 1587 |
|
| 1588 |
Simple Tables |
| 1589 |
````````````` |
| 1590 |
|
| 1591 |
Simple tables provide a compact and easy to type but limited |
| 1592 |
row-oriented table representation for simple data sets. Cell contents |
| 1593 |
are typically single paragraphs, although arbitrary body elements may |
| 1594 |
be represented in most cells. Simple tables allow multi-line rows (in |
| 1595 |
all but the first column) and column spans, but not row spans. See |
| 1596 |
`Grid Tables`_ above for a complete table representation. |
| 1597 |
|
| 1598 |
Simple tables are described with horizontal borders made up of ``=`` and |
| 1599 |
``-`` characters. The equals sign (``=``) is used for top and bottom |
| 1600 |
table borders, and to separate optional header rows from the table |
| 1601 |
body. The hyphen (``-``) is used to indicate column spans in a single |
| 1602 |
row by underlining the joined columns, and may optionally be used to |
| 1603 |
explicitly and/or visually separate rows. |
| 1604 |
|
| 1605 |
A simple table begins with a top border of equals signs with one or |
| 1606 |
more spaces at each column boundary (two or more spaces recommended). |
| 1607 |
Regardless of spans, the top border *must* fully describe all table |
| 1608 |
columns. There must be at least two columns in the table (to |
| 1609 |
differentiate it from section headers). The top border may be |
| 1610 |
followed by header rows, and the last of the optional header rows is |
| 1611 |
underlined with ``=``, again with spaces at column boundaries. There |
| 1612 |
may not be a blank line below the header row separator; it would be |
| 1613 |
interpreted as the bottom border of the table. The bottom boundary of |
| 1614 |
the table consists of ``=`` underlines, also with spaces at column |
| 1615 |
boundaries. For example, here is a truth table, a three-column table |
| 1616 |
with one header row and four body rows:: |
| 1617 |
|
| 1618 |
===== ===== ======= |
| 1619 |
A B A and B |
| 1620 |
===== ===== ======= |
| 1621 |
False False False |
| 1622 |
True False False |
| 1623 |
False True False |
| 1624 |
True True True |
| 1625 |
===== ===== ======= |
| 1626 |
|
| 1627 |
Underlines of ``-`` may be used to indicate column spans by "filling in" |
| 1628 |
column margins to join adjacent columns. Column span underlines must |
| 1629 |
be complete (they must cover all columns) and align with established |
| 1630 |
column boundaries. Text lines containing column span underlines may |
| 1631 |
not contain any other text. A column span underline applies only to |
| 1632 |
one row immediately above it. For example, here is a table with a |
| 1633 |
column span in the header:: |
| 1634 |
|
| 1635 |
===== ===== ====== |
| 1636 |
Inputs Output |
| 1637 |
------------ ------ |
| 1638 |
A B A or B |
| 1639 |
===== ===== ====== |
| 1640 |
False False False |
| 1641 |
True False True |
| 1642 |
False True True |
| 1643 |
True True True |
| 1644 |
===== ===== ====== |
| 1645 |
|
| 1646 |
Each line of text must contain spaces at column boundaries, except |
| 1647 |
where cells have been joined by column spans. Each line of text |
| 1648 |
starts a new row, except when there is a blank cell in the first |
| 1649 |
column. In that case, that line of text is parsed as a continuation |
| 1650 |
line. For this reason, cells in the first column of new rows (*not* |
| 1651 |
continuation lines) *must* contain some text; blank cells would lead |
| 1652 |
to a misinterpretation (but see the tip below). Also, this mechanism |
| 1653 |
limits cells in the first column to only one line of text. Use `grid |
| 1654 |
tables`_ if this limitation is unacceptable. |
| 1655 |
|
| 1656 |
.. Tip:: |
| 1657 |
|
| 1658 |
To start a new row in a simple table without text in the first |
| 1659 |
column in the processed output, use one of these: |
| 1660 |
|
| 1661 |
* an empty comment (``..``), which may be omitted from the processed |
| 1662 |
output (see Comments_ below) |
| 1663 |
|
| 1664 |
* a backslash escape followed by a space |
| 1665 |
(:literal:`\\ \ `), see `Escaping Mechanism`_ above. |
| 1666 |
|
| 1667 |
Underlines of ``-`` may also be used to visually separate rows, even if |
| 1668 |
there are no column spans. This is especially useful in long tables, |
| 1669 |
where rows are many lines long. |
| 1670 |
|
| 1671 |
Blank lines are permitted within simple tables. Their interpretation |
| 1672 |
depends on the context. Blank lines *between* rows are ignored. |
| 1673 |
Blank lines *within* multi-line rows may separate paragraphs or other |
| 1674 |
body elements within cells. |
| 1675 |
|
| 1676 |
The rightmost column is unbounded; text may continue past the edge of |
| 1677 |
the table (as indicated by the table borders). However, it is |
| 1678 |
recommended that borders be made long enough to contain the entire |
| 1679 |
text. |
| 1680 |
|
| 1681 |
The following example illustrates continuation lines (row 2 consists |
| 1682 |
of two lines of text, and four lines for row 3), a blank line |
| 1683 |
separating paragraphs (row 3, column 2), text extending past the right |
| 1684 |
edge of the table, and a new row which will have no text in the first |
| 1685 |
column in the processed output (row 4):: |
| 1686 |
|
| 1687 |
===== ===== |
| 1688 |
col 1 col 2 |
| 1689 |
===== ===== |
| 1690 |
1 Second column of row 1. |
| 1691 |
2 Second column of row 2. |
| 1692 |
Second line of paragraph. |
| 1693 |
3 - Second column of row 3. |
| 1694 |
|
| 1695 |
- Second item in bullet |
| 1696 |
list (row 3, column 2). |
| 1697 |
\ Row 4; column 1 will be empty. |
| 1698 |
===== ===== |
| 1699 |
|
| 1700 |
|
| 1701 |
Explicit Markup Blocks |
| 1702 |
---------------------- |
| 1703 |
|
| 1704 |
The explicit markup syntax is used for footnotes_, citations_, |
| 1705 |
`hyperlink targets`_, directives_, `substitution definitions`_, |
| 1706 |
and comments_. |
| 1707 |
|
| 1708 |
An explicit markup block is a text block: |
| 1709 |
|
| 1710 |
- whose first line begins with ``..`` followed by whitespace |
| 1711 |
(the *explicit markup start*), |
| 1712 |
- whose second and subsequent lines (if any) are indented |
| 1713 |
relative to the first, and |
| 1714 |
- which ends before an unindented line. |
| 1715 |
|
| 1716 |
Explicit markup blocks are analogous to field list items. |
| 1717 |
The maximum common indentation is always removed from the second and |
| 1718 |
subsequent lines of the block body. Therefore, if the first construct |
| 1719 |
fits in one line and the indentation of the first and second |
| 1720 |
constructs should differ, the first construct should not begin on the |
| 1721 |
same line as the explicit markup start. |
| 1722 |
|
| 1723 |
Blank lines are required between explicit markup blocks and other |
| 1724 |
elements, but are optional between explicit markup blocks where |
| 1725 |
unambiguous. |
| 1726 |
|
| 1727 |
|
| 1728 |
.. _footnote: |
| 1729 |
|
| 1730 |
Footnotes |
| 1731 |
````````` |
| 1732 |
|
| 1733 |
:Doctree elements: `\<footnote>`_, `\<label>`_ |
| 1734 |
:Config settings: `footnote_references <footnote_references setting_>`__ |
| 1735 |
:See also: `footnote references`_ |
| 1736 |
|
| 1737 |
Each footnote consists of an explicit markup start (:literal:`.. \ `), |
| 1738 |
a left square bracket, the footnote label, a right square bracket, and |
| 1739 |
whitespace, followed by indented body elements. |
| 1740 |
A _`footnote label` can be: |
| 1741 |
|
| 1742 |
- a decimal integer (manually `numbered footnotes`_), |
| 1743 |
|
| 1744 |
- a single ``#`` (denoting `auto-numbered footnotes`_), |
| 1745 |
|
| 1746 |
- a ``#`` followed by a simple `reference name`_ |
| 1747 |
(auto-numbered footnotes with `autonumber label`_), or |
| 1748 |
|
| 1749 |
- a single ``*`` (denoting `auto-symbol footnotes`_). |
| 1750 |
|
| 1751 |
The footnote content (body elements) must be consistently indented |
| 1752 |
and left-aligned. The first body element within a |
| 1753 |
footnote may often begin on the same line as the footnote label. |
| 1754 |
However, if the first element fits on one line and the indentation of |
| 1755 |
the remaining elements differ, the first element must begin on the |
| 1756 |
line after the footnote label. Otherwise, the difference in |
| 1757 |
indentation will not be detected. |
| 1758 |
|
| 1759 |
Here is a manually numbered footnote:: |
| 1760 |
|
| 1761 |
.. [1] Body elements go here. |
| 1762 |
|
| 1763 |
Footnotes may occur anywhere in the document, not only at the end. |
| 1764 |
Where and how they appear in the processed output depends on the |
| 1765 |
processing system. |
| 1766 |
|
| 1767 |
Syntax diagram:: |
| 1768 |
|
| 1769 |
+-------+-------------------------+ |
| 1770 |
| ".. " | "[" label "]" footnote | |
| 1771 |
+-------+ | |
| 1772 |
| (body elements)+ | |
| 1773 |
+-------------------------+ |
| 1774 |
|
| 1775 |
|
| 1776 |
Numbered Footnotes |
| 1777 |
.................. |
| 1778 |
|
| 1779 |
`Numbered footnotes` use decimal numbers as label. The number may |
| 1780 |
be specified in the source or automatically assigned. |
| 1781 |
Numbered footnotes are assigned a `reference name`_; |
| 1782 |
they can be referred to more than once, with a `footnote reference`_ |
| 1783 |
or `hyperlink reference`_:: |
| 1784 |
|
| 1785 |
The footnote above can be referred to with 1_ or [1]_. |
| 1786 |
|
| 1787 |
Auto-Numbered Footnotes |
| 1788 |
''''''''''''''''''''''' |
| 1789 |
|
| 1790 |
A number sign (``#``) may be used as the first character of a footnote |
| 1791 |
label to request automatic numbering of the footnote or footnote |
| 1792 |
reference:: |
| 1793 |
|
| 1794 |
Footnotes may be auto-numbered. [#]_ |
| 1795 |
|
| 1796 |
.. [#] This is an auto-numbered footnote. |
| 1797 |
|
| 1798 |
The first footnote to request automatic numbering is assigned the |
| 1799 |
label "1", the second is assigned the label "2", and so on (assuming |
| 1800 |
there is no conflict with another reference name; see also |
| 1801 |
`Mixed Manual and Auto-Numbered Footnotes`_ below). |
| 1802 |
|
| 1803 |
.. _autonumber label: |
| 1804 |
|
| 1805 |
If the footnote label is a single ``#``, the assigned number is also used |
| 1806 |
as reference name. |
| 1807 |
A custom reference name can be specified appending a `simple reference |
| 1808 |
name`_ to the number sign to form an *autonumber label*. |
| 1809 |
For example:: |
| 1810 |
|
| 1811 |
If [#note]_ is the first footnote reference, it will |
| 1812 |
show up as "[1]". We can refer to it again as [#note]_ |
| 1813 |
and again see "[1]". We can also refer to it as note_ |
| 1814 |
(an ordinary internal hyperlink reference). |
| 1815 |
|
| 1816 |
.. [#note] This is the footnote with reference name "note". |
| 1817 |
|
| 1818 |
The numbering is determined by the order of the footnotes, not by the |
| 1819 |
order of the references. |
| 1820 |
Auto-numbered footnotes and footnote references without autonumber label |
| 1821 |
must be in the same relative order but need not alternate in lock-step. |
| 1822 |
For example:: |
| 1823 |
|
| 1824 |
[#]_ is a reference to footnote 1, |
| 1825 |
and [#]_ is a reference to footnote 2. |
| 1826 |
|
| 1827 |
.. [#] This is footnote 1. |
| 1828 |
.. [#] This is footnote 2. |
| 1829 |
.. [#] This is footnote 3. |
| 1830 |
|
| 1831 |
[#]_ is a reference to footnote 3. |
| 1832 |
|
| 1833 |
Special care must be taken if footnotes themselves contain |
| 1834 |
auto-numbered footnote references, or if multiple references are made |
| 1835 |
in close proximity. Footnotes and references are noted in the order |
| 1836 |
they are encountered in the document, which is not necessarily the |
| 1837 |
same as the order in which a person would read them. |
| 1838 |
|
| 1839 |
|
| 1840 |
Mixed Manual and Auto-Numbered Footnotes |
| 1841 |
'''''''''''''''''''''''''''''''''''''''' |
| 1842 |
|
| 1843 |
Manual and automatic footnote numbering may both be used within a |
| 1844 |
single document, although the results may not be expected. Manual |
| 1845 |
numbering takes priority. Only unused footnote numbers are assigned |
| 1846 |
to auto-numbered footnotes. The following example should be |
| 1847 |
illustrative:: |
| 1848 |
|
| 1849 |
[2]_ will be "2" (manually numbered), |
| 1850 |
[#]_ will be "3" (anonymous auto-numbered), and |
| 1851 |
[#label]_ will be "1" (labeled auto-numbered). |
| 1852 |
|
| 1853 |
.. [2] This footnote is labeled manually, so its number is fixed. |
| 1854 |
|
| 1855 |
.. [#label] This autonumber-labeled footnote will be labeled "1". |
| 1856 |
It is the first auto-numbered footnote and no other footnote |
| 1857 |
with label "1" exists. The order of the footnotes is used to |
| 1858 |
determine numbering, not the order of the footnote references. |
| 1859 |
|
| 1860 |
.. [#] This footnote will be labeled "3". It is the second |
| 1861 |
auto-numbered footnote, but footnote label "2" is already used. |
| 1862 |
|
| 1863 |
|
| 1864 |
Auto-Symbol Footnotes |
| 1865 |
..................... |
| 1866 |
|
| 1867 |
An asterisk (``*``) may be used as footnote label to request automatic |
| 1868 |
symbol generation for footnotes and footnote references. The asterisk |
| 1869 |
must be the only character in the label. For example:: |
| 1870 |
|
| 1871 |
Here is a symbolic footnote reference: [*]_. |
| 1872 |
|
| 1873 |
.. [*] This is the footnote. |
| 1874 |
|
| 1875 |
A transform will insert symbols as labels into corresponding footnotes |
| 1876 |
and footnote references. The number of references must be equal to |
| 1877 |
the number of footnotes. One symbol footnote cannot have multiple |
| 1878 |
references. |
| 1879 |
|
| 1880 |
The standard Docutils system uses the following symbols for |
| 1881 |
footnote marks: [#]_ |
| 1882 |
|
| 1883 |
- asterisk/star (``*``) |
| 1884 |
- dagger (``†``, U+02020) |
| 1885 |
- double dagger (``‡``, U+02021) |
| 1886 |
- section mark (``§``, U+000A7) |
| 1887 |
- pilcrow or paragraph mark (``¶``, U+000B6) |
| 1888 |
- number sign (``#``) |
| 1889 |
- spade suit (``♠``, U+02660) |
| 1890 |
- heart suit (``♥``, U+02665) |
| 1891 |
- diamond suit (``♦``, U+02666) |
| 1892 |
- club suit (``♣``, U+02663) |
| 1893 |
|
| 1894 |
.. [#] This list was inspired by the list of symbols for "Note |
| 1895 |
Reference Marks" in The Chicago Manual of Style, 14th edition, |
| 1896 |
section 12.51. "Parallels" (``||``) were given in CMoS instead of |
| 1897 |
the pilcrow. The last four symbols (the card suits) were added |
| 1898 |
arbitrarily. |
| 1899 |
|
| 1900 |
If more than ten symbols are required, the same sequence will be |
| 1901 |
reused, doubled and then tripled, and so on (``**`` etc.). |
| 1902 |
|
| 1903 |
.. Note:: When using auto-symbol footnotes, the choice of output |
| 1904 |
encoding is important. Many of the symbols used are not |
| 1905 |
encodable in 8-bit text encodings such as Latin-1 (ISO 8859-1). |
| 1906 |
The use of UTF-8 for the output encoding is recommended. |
| 1907 |
An alternative for HTML and XML output is to use the |
| 1908 |
"xmlcharrefreplace" `output encoding error handler`_. |
| 1909 |
|
| 1910 |
|
| 1911 |
Citations |
| 1912 |
````````` |
| 1913 |
|
| 1914 |
:Doctree element: `\<citation>`_ |
| 1915 |
:See also: `citation references`_ |
| 1916 |
|
| 1917 |
Citations are identical to manually numbered footnotes_ except that they use |
| 1918 |
non-numeric labels such as ``[note]`` or ``[GVR2001]``. Citation |
| 1919 |
labels are simple `reference names`_ (case-insensitive single words |
| 1920 |
consisting of alphanumerics plus internal hyphens, underscores, and |
| 1921 |
periods; no whitespace). Citations may be rendered separately and |
| 1922 |
differently from footnotes. For example:: |
| 1923 |
|
| 1924 |
Here is a citation reference: [CIT2002]_. |
| 1925 |
|
| 1926 |
.. [CIT2002] This is the citation. It's just like a footnote, |
| 1927 |
except the label is textual. |
| 1928 |
|
| 1929 |
|
| 1930 |
.. _explicit hyperlink targets: |
| 1931 |
.. _hyperlink target: |
| 1932 |
|
| 1933 |
Hyperlink Targets |
| 1934 |
````````````````` |
| 1935 |
|
| 1936 |
:Doctree element: `\<target>`_ |
| 1937 |
:See also: | `hyperlink references`_ |
| 1938 |
| `embedded URIs and aliases`_ |
| 1939 |
| `inline internal targets`_ |
| 1940 |
|
| 1941 |
These are also called *explicit hyperlink targets*, to differentiate |
| 1942 |
them from `implicit hyperlink targets`_ defined below. |
| 1943 |
|
| 1944 |
Hyperlink targets identify a location within or outside of a document, |
| 1945 |
which may be linked to by `hyperlink references`_. |
| 1946 |
|
| 1947 |
Hyperlink targets may be named or anonymous. *Named hyperlink targets* |
| 1948 |
consist of an explicit markup start (:literal:`.. \ `), an underscore, |
| 1949 |
the `reference name`_ (no trailing underscore), a colon, whitespace, and |
| 1950 |
a link block:: |
| 1951 |
|
| 1952 |
.. _hyperlink-name: link-block |
| 1953 |
|
| 1954 |
Reference names are whitespace-neutral and case-insensitive. See |
| 1955 |
`Reference Names`_ for details and examples. |
| 1956 |
|
| 1957 |
*Anonymous hyperlink targets* consist of an explicit markup start |
| 1958 |
(:literal:`.. \ `), two underscores, a colon, whitespace, and |
| 1959 |
a link block; there is no reference name:: |
| 1960 |
|
| 1961 |
.. __: anonymous-hyperlink-target-link-block |
| 1962 |
|
| 1963 |
An alternate syntax for anonymous hyperlinks consists of two |
| 1964 |
underscores, a space, and a link block:: |
| 1965 |
|
| 1966 |
__ anonymous-hyperlink-target-link-block |
| 1967 |
|
| 1968 |
See `Anonymous Hyperlinks`_ below. |
| 1969 |
|
| 1970 |
There are three types of hyperlink targets: internal, external, and |
| 1971 |
indirect. |
| 1972 |
|
| 1973 |
1. _`Internal hyperlink targets` have empty link blocks. They provide |
| 1974 |
an end point allowing a hyperlink to connect one place to another |
| 1975 |
within a document. An internal hyperlink target points to the |
| 1976 |
element following the target. [#]_ For example:: |
| 1977 |
|
| 1978 |
Clicking on this internal hyperlink will take us to the target_ |
| 1979 |
below. |
| 1980 |
|
| 1981 |
.. _target: |
| 1982 |
|
| 1983 |
The hyperlink target above points to this paragraph. |
| 1984 |
|
| 1985 |
Internal hyperlink targets may be "chained". Multiple adjacent |
| 1986 |
internal hyperlink targets all point to the same element:: |
| 1987 |
|
| 1988 |
.. _target1: |
| 1989 |
.. _target2: |
| 1990 |
|
| 1991 |
The targets "target1" and "target2" are synonyms; they both |
| 1992 |
point to this paragraph. |
| 1993 |
|
| 1994 |
If the element "pointed to" is an external hyperlink target (with a |
| 1995 |
URI in its link block; see #2 below) the URI from the external |
| 1996 |
hyperlink target is propagated to the internal hyperlink targets; |
| 1997 |
they will all "point to" the same URI. There is no need to |
| 1998 |
duplicate a URI. For example, all three of the following hyperlink |
| 1999 |
targets refer to the same URI:: |
| 2000 |
|
| 2001 |
.. _Python DOC-SIG mailing list archive: |
| 2002 |
.. _archive: |
| 2003 |
.. _Doc-SIG: https://mail.python.org/pipermail/doc-sig/ |
| 2004 |
|
| 2005 |
An inline form of internal hyperlink target is available; see |
| 2006 |
`Inline Internal Targets`_. |
| 2007 |
|
| 2008 |
.. [#] Works also, if the internal hyperlink target is "nested" at the |
| 2009 |
end of an indented text block. This behaviour allows setting targets |
| 2010 |
to individual list items (except the first, as a preceding internal |
| 2011 |
target applies to the list as a whole):: |
| 2012 |
|
| 2013 |
* bullet list |
| 2014 |
|
| 2015 |
.. _`second item`: |
| 2016 |
|
| 2017 |
* second item, with hyperlink target. |
| 2018 |
|
| 2019 |
|
| 2020 |
2. _`External hyperlink targets` have a URI-reference_ or email address |
| 2021 |
in their link blocks. For example, take the following input:: |
| 2022 |
|
| 2023 |
See the Python_ home page for info. |
| 2024 |
|
| 2025 |
`Write to me`_ with your questions. |
| 2026 |
|
| 2027 |
.. _Python: https://www.python.org |
| 2028 |
.. _Write to me: [email protected] |
| 2029 |
|
| 2030 |
After processing into HTML, the hyperlinks might be expressed as:: |
| 2031 |
|
| 2032 |
See the <a href="https://www.python.org">Python</a> home page |
| 2033 |
for info. |
| 2034 |
|
| 2035 |
<a href="mailto:[email protected]">Write to me</a> with your |
| 2036 |
questions. |
| 2037 |
|
| 2038 |
An external hyperlink's URI may begin on the same line as the |
| 2039 |
explicit markup start and target name, or it may begin in an |
| 2040 |
indented text block immediately following, with no intervening |
| 2041 |
blank lines. If there are multiple lines in the link block, they |
| 2042 |
are concatenated. Any unescaped whitespace is removed (whitespace is |
| 2043 |
permitted to allow for line wrapping). The following external |
| 2044 |
hyperlink targets are equivalent:: |
| 2045 |
|
| 2046 |
.. _one-liner: https://docutils.sourceforge.io/rst.html |
| 2047 |
|
| 2048 |
.. _starts-on-this-line: https:// |
| 2049 |
docutils.sourceforge.net/rst.html |
| 2050 |
|
| 2051 |
.. _entirely-below: |
| 2052 |
https://docutils. |
| 2053 |
sourceforge.net/rst.html |
| 2054 |
|
| 2055 |
Escaped whitespace is preserved as intentional spaces, e.g.:: |
| 2056 |
|
| 2057 |
.. _reference: ../local\ path\ with\ spaces.html |
| 2058 |
|
| 2059 |
If an external hyperlink target's URI contains an underscore as its |
| 2060 |
last character, it must be escaped to avoid being mistaken for an |
| 2061 |
indirect hyperlink target:: |
| 2062 |
|
| 2063 |
This link_ refers to a file called ``underscore_``. |
| 2064 |
|
| 2065 |
.. _link: underscore\_ |
| 2066 |
|
| 2067 |
It is possible (although not generally recommended) to include URIs |
| 2068 |
directly within hyperlink references. See `Embedded URIs and Aliases`_ |
| 2069 |
below. |
| 2070 |
|
| 2071 |
3. _`Indirect hyperlink targets` have a hyperlink reference in their |
| 2072 |
link blocks. In the following example, target "one" indirectly |
| 2073 |
references whatever target "two" references, and target "two" |
| 2074 |
references target "three", an internal hyperlink target. In |
| 2075 |
effect, all three reference the same thing:: |
| 2076 |
|
| 2077 |
.. _one: two_ |
| 2078 |
.. _two: three_ |
| 2079 |
.. _three: |
| 2080 |
|
| 2081 |
Just as with `hyperlink references`_ anywhere else in a document, |
| 2082 |
if a phrase-reference is used in the link block it must be enclosed |
| 2083 |
in backquotes. As with `external hyperlink targets`_, the link |
| 2084 |
block of an indirect hyperlink target may begin on the same line as |
| 2085 |
the explicit markup start or the next line. It may also be split |
| 2086 |
over multiple lines, in which case the lines are joined with |
| 2087 |
whitespace before being normalized. |
| 2088 |
|
| 2089 |
For example, the following indirect hyperlink targets are |
| 2090 |
equivalent:: |
| 2091 |
|
| 2092 |
.. _one-liner: `A HYPERLINK`_ |
| 2093 |
.. _entirely-below: |
| 2094 |
`a hyperlink`_ |
| 2095 |
.. _split: `A |
| 2096 |
Hyperlink`_ |
| 2097 |
|
| 2098 |
It is possible to include an alias directly within hyperlink |
| 2099 |
references. See `Embedded URIs and Aliases`_ below. |
| 2100 |
|
| 2101 |
If the reference name contains any colons, either: |
| 2102 |
|
| 2103 |
- the phrase must be enclosed in backquotes:: |
| 2104 |
|
| 2105 |
.. _`FAQTS: Computers: Programming: Languages: Python`: |
| 2106 |
http://python.faqts.com/ |
| 2107 |
|
| 2108 |
- or the colon(s) must be backslash-escaped in the link target:: |
| 2109 |
|
| 2110 |
.. _Chapter One\: "Tadpole Days": |
| 2111 |
|
| 2112 |
It's not easy being green... |
| 2113 |
|
| 2114 |
See `Implicit Hyperlink Targets`_ below for the resolution of |
| 2115 |
duplicate reference names. |
| 2116 |
|
| 2117 |
Syntax diagram:: |
| 2118 |
|
| 2119 |
+-------+----------------------+ |
| 2120 |
| ".. " | "_" name ":" link | |
| 2121 |
+-------+ block | |
| 2122 |
| | |
| 2123 |
+----------------------+ |
| 2124 |
|
| 2125 |
|
| 2126 |
.. _anonymous: |
| 2127 |
|
| 2128 |
Anonymous Hyperlinks |
| 2129 |
.................... |
| 2130 |
|
| 2131 |
The `World Wide Web Consortium`_ recommends in its `HTML Techniques |
| 2132 |
for Web Content Accessibility Guidelines`_ that authors should |
| 2133 |
"clearly identify the target of each link." Hyperlink references |
| 2134 |
should be as verbose as possible, but duplicating a verbose hyperlink |
| 2135 |
name in the target is onerous and error-prone. *Anonymous hyperlinks* |
| 2136 |
are designed to allow convenient verbose hyperlink references, and are |
| 2137 |
analogous to `auto-numbered footnotes`_. They are particularly useful |
| 2138 |
in short or one-off documents. However, this feature is easily abused |
| 2139 |
and can result in unreadable plaintext and/or unmaintainable |
| 2140 |
documents. Caution is advised. |
| 2141 |
|
| 2142 |
Anonymous `hyperlink references`_ are specified with two underscores |
| 2143 |
instead of one:: |
| 2144 |
|
| 2145 |
See `the web site of my favorite programming language`__. |
| 2146 |
|
| 2147 |
Anonymous `hyperlink targets`_ begin with ``.. __:``, no reference name |
| 2148 |
is required or allowed:: |
| 2149 |
|
| 2150 |
.. __: https://www.python.org |
| 2151 |
|
| 2152 |
As a convenient alternative, anonymous targets may begin with |
| 2153 |
two underscores only:: |
| 2154 |
|
| 2155 |
__ https://www.python.org |
| 2156 |
|
| 2157 |
.. _anonymous matching: |
| 2158 |
|
| 2159 |
The order of anonymous hyperlink references |
| 2160 |
and targets within the document is significant: the first anonymous |
| 2161 |
reference will link to the first anonymous target. The number of |
| 2162 |
anonymous hyperlink references in a document must match the number of |
| 2163 |
anonymous targets. |
| 2164 |
|
| 2165 |
For readability, it is recommended that targets be |
| 2166 |
kept close to references. Take care when editing text containing |
| 2167 |
anonymous references; adding, removing, and rearranging references |
| 2168 |
require attention to the order of corresponding targets. |
| 2169 |
|
| 2170 |
|
| 2171 |
Directives |
| 2172 |
`````````` |
| 2173 |
|
| 2174 |
:Doctree elements: depend on the directive |
| 2175 |
|
| 2176 |
Directives are an extension mechanism for reStructuredText, a way of |
| 2177 |
adding support for new constructs without adding new primary syntax |
| 2178 |
(directives may support additional syntax locally). All standard |
| 2179 |
directives (those implemented and registered in the reference |
| 2180 |
reStructuredText parser) are described in the `reStructuredText |
| 2181 |
Directives`_ document, and are always available. Any other directives |
| 2182 |
are domain-specific, and may require special action to make them |
| 2183 |
available when processing the document. |
| 2184 |
|
| 2185 |
For example, the `"image"`_ directive is used to include an image:: |
| 2186 |
|
| 2187 |
.. image:: mylogo.jpeg |
| 2188 |
|
| 2189 |
A graphic with a caption may be included with the `"figure"`_ directive:: |
| 2190 |
|
| 2191 |
.. figure:: larch.png |
| 2192 |
|
| 2193 |
The larch. |
| 2194 |
|
| 2195 |
An `"admonition"`_ (note, caution, etc.) contains other body elements:: |
| 2196 |
|
| 2197 |
.. note:: This is a paragraph |
| 2198 |
|
| 2199 |
- Here is a bullet list. |
| 2200 |
|
| 2201 |
Directives are indicated by an explicit markup start (:literal:`.. \ `) |
| 2202 |
followed by the directive type, two colons, and whitespace (together called |
| 2203 |
the *directive marker*). Directive types are case-insensitive single |
| 2204 |
words (alphanumerics plus isolated internal hyphens, underscores, |
| 2205 |
plus signs, colons, and periods; no whitespace). Two colons are used |
| 2206 |
after the directive type for these reasons: |
| 2207 |
|
| 2208 |
- Two colons are distinctive, and unlikely to be used in common text. |
| 2209 |
|
| 2210 |
- Two colons avoids clashes with common comment text like:: |
| 2211 |
|
| 2212 |
.. Danger: modify at your own risk! |
| 2213 |
|
| 2214 |
- If an implementation of reStructuredText does not recognize a |
| 2215 |
directive (i.e., the directive-handler is not installed), a level-3 |
| 2216 |
(error) system message is generated, and the entire directive block |
| 2217 |
(including the directive itself) will be included as a literal |
| 2218 |
block. Thus ``::`` is a natural choice. |
| 2219 |
|
| 2220 |
The directive block consists of any text on the first line of the |
| 2221 |
directive after the directive marker, and any subsequent indented |
| 2222 |
text. The interpretation of the directive block is up to the |
| 2223 |
directive code. There are three logical parts to the directive block: |
| 2224 |
|
| 2225 |
1. Directive arguments. |
| 2226 |
2. Directive options. |
| 2227 |
3. Directive content. |
| 2228 |
|
| 2229 |
Individual directives can employ any combination of these parts. |
| 2230 |
Directive arguments can be filesystem paths, URLs, title text, etc. |
| 2231 |
_`Directive options` are indicated using `field lists`_; the field names |
| 2232 |
and contents are directive-specific. Arguments and options must form |
| 2233 |
a contiguous block beginning on the first or second line of the |
| 2234 |
directive; a blank line indicates the beginning of the directive |
| 2235 |
content block. If either arguments and/or options are employed by the |
| 2236 |
directive, a blank line must separate them from the directive content. |
| 2237 |
The "figure" directive employs all three parts:: |
| 2238 |
|
| 2239 |
.. figure:: larch.png |
| 2240 |
:scale: 50 |
| 2241 |
|
| 2242 |
The larch. |
| 2243 |
|
| 2244 |
Simple directives may not require any content. If a directive that |
| 2245 |
does not employ a content block is followed by indented text anyway, |
| 2246 |
it is an error. If a block quote should immediately follow a |
| 2247 |
directive, use an empty comment in-between (see Comments_ below). |
| 2248 |
|
| 2249 |
Actions taken in response to directives and the interpretation of text |
| 2250 |
in the directive content block or subsequent text block(s) are |
| 2251 |
directive-dependent. See `reStructuredText Directives`_ for details. |
| 2252 |
|
| 2253 |
Directives are meant for the arbitrary processing of their contents, |
| 2254 |
which can be transformed into something possibly unrelated to the |
| 2255 |
original text. It may also be possible for directives to be used as |
| 2256 |
pragmas, to modify the behavior of the parser, such as to experiment |
| 2257 |
with alternate syntax. There is no parser support for this |
| 2258 |
functionality at present; if a reasonable need for pragma directives |
| 2259 |
is found, they may be supported. |
| 2260 |
|
| 2261 |
Directives do not generate "directive" elements; they are a *parser |
| 2262 |
construct* only, and have no intrinsic meaning outside of |
| 2263 |
reStructuredText. Instead, the parser will transform recognized |
| 2264 |
directives into (possibly specialized) document elements. Unknown |
| 2265 |
directives will trigger level-3 (error) system messages. |
| 2266 |
|
| 2267 |
Syntax diagram:: |
| 2268 |
|
| 2269 |
+-------+-------------------------------+ |
| 2270 |
| ".. " | directive type "::" directive | |
| 2271 |
+-------+ block | |
| 2272 |
| | |
| 2273 |
+-------------------------------+ |
| 2274 |
|
| 2275 |
|
| 2276 |
Substitution Definitions |
| 2277 |
```````````````````````` |
| 2278 |
|
| 2279 |
:Doctree element: `\<substitution_definition>`_ |
| 2280 |
:See also: `substitution references`_ |
| 2281 |
|
| 2282 |
Substitution definitions are indicated by an explicit markup start |
| 2283 |
(:literal:`.. \ `) followed by a vertical bar, the substitution text, another |
| 2284 |
vertical bar, whitespace, and the definition block. Substitution text |
| 2285 |
may not begin or end with whitespace. A substitution definition block |
| 2286 |
contains an embedded `inline-compatible directive`_ (such as "image" or |
| 2287 |
"replace") without the leading dots. For example:: |
| 2288 |
|
| 2289 |
The |biohazard| symbol must be used on containers used to |
| 2290 |
dispose of medical waste. |
| 2291 |
|
| 2292 |
.. |biohazard| image:: biohazard.png |
| 2293 |
|
| 2294 |
It is an error for a substitution definition block to directly or |
| 2295 |
indirectly contain a circular substitution reference. |
| 2296 |
|
| 2297 |
`Substitution references`_ are replaced in-line by the processed |
| 2298 |
contents of the corresponding definition (linked by matching |
| 2299 |
substitution text). Matches are _`case-sensitive but forgiving`; if no |
| 2300 |
exact match is found, a case-insensitive comparison is attempted. |
| 2301 |
|
| 2302 |
Substitution definitions allow the power and flexibility of |
| 2303 |
block-level directives_ to be shared by inline text. They are a way |
| 2304 |
to include arbitrarily complex inline structures within text, while |
| 2305 |
keeping the details out of the flow of text. They are the equivalent |
| 2306 |
of SGML/XML's named entities or programming language macros. |
| 2307 |
|
| 2308 |
Without the substitution mechanism, every time someone wants an |
| 2309 |
application-specific new inline structure, they would have to petition |
| 2310 |
for a syntax change. In combination with existing directive syntax, |
| 2311 |
any inline structure can be coded without new syntax (except possibly |
| 2312 |
a new directive). |
| 2313 |
|
| 2314 |
Syntax diagram:: |
| 2315 |
|
| 2316 |
+-------+-----------------------------------------------------+ |
| 2317 |
| ".. " | "|" substitution text "| " directive type "::" data | |
| 2318 |
+-------+ directive block | |
| 2319 |
| | |
| 2320 |
+-----------------------------------------------------+ |
| 2321 |
|
| 2322 |
|
| 2323 |
.. _inline-compatible directive: |
| 2324 |
|
| 2325 |
The following *inline-compatible directives* are implemented in Docutils: |
| 2326 |
|
| 2327 |
:`"date"`_: inserts the current local date. |
| 2328 |
|
| 2329 |
:`"image"`_: can be used for block-level images as well as in a |
| 2330 |
substitution definition for `inline images`_. |
| 2331 |
|
| 2332 |
:`"raw"`_: can be used in block-level context as well as in a |
| 2333 |
substitution definition. |
| 2334 |
|
| 2335 |
:`"replace"`_: allows simple macro substitution. |
| 2336 |
It also provides a workaround__ for the still missing support of |
| 2337 |
nested inline markup. |
| 2338 |
|
| 2339 |
__ directives.html#hyperlink-workaround |
| 2340 |
|
| 2341 |
:`"unicode"`_: converts Unicode character codes to characters. |
| 2342 |
|
| 2343 |
Applications may find other use cases for the substitution mechanism. |
| 2344 |
The following are ideas that have not been implemented in Docutils. |
| 2345 |
|
| 2346 |
Objects |
| 2347 |
Substitution references may be used to associate ambiguous text |
| 2348 |
with a unique object identifier. |
| 2349 |
|
| 2350 |
For example, many sites may wish to implement an inline "user" |
| 2351 |
directive:: |
| 2352 |
|
| 2353 |
|Michael| and |Jon| are our widget-wranglers. |
| 2354 |
|
| 2355 |
.. |Michael| user:: mjones |
| 2356 |
.. |Jon| user:: jhl |
| 2357 |
|
| 2358 |
Depending on the needs of the site, this may be used to index the |
| 2359 |
document for later searching, to hyperlink the inline text in |
| 2360 |
various ways (mailto, homepage, mouseover Javascript with profile |
| 2361 |
and contact information, etc.), or to customize presentation of |
| 2362 |
the text (include username in the inline text, include an icon |
| 2363 |
image with a link next to the text, make the text bold or a |
| 2364 |
different color, etc.). |
| 2365 |
|
| 2366 |
The same approach can be used in documents which frequently refer |
| 2367 |
to a particular type of objects with unique identifiers but |
| 2368 |
ambiguous common names. Movies, albums, books, photos, court |
| 2369 |
cases, and laws are possible. For example:: |
| 2370 |
|
| 2371 |
|The Transparent Society| offers a fascinating alternate view |
| 2372 |
on privacy issues. |
| 2373 |
|
| 2374 |
.. |The Transparent Society| book:: isbn=0738201448 |
| 2375 |
|
| 2376 |
Classes or functions, in contexts where the module or class names |
| 2377 |
are unclear and/or interpreted text cannot be used, are another |
| 2378 |
possibility:: |
| 2379 |
|
| 2380 |
4XSLT has the convenience method |runString|, so you don't |
| 2381 |
have to mess with DOM objects if all you want is the |
| 2382 |
transformed output. |
| 2383 |
|
| 2384 |
.. |runString| function:: module=xml.xslt class=Processor |
| 2385 |
|
| 2386 |
.. @@@ Inline styling is better served with "custom interpreted text". |
| 2387 |
|
| 2388 |
Styles [#]_ |
| 2389 |
Substitution references may be used to associate inline text with |
| 2390 |
an externally defined presentation style:: |
| 2391 |
|
| 2392 |
Even |the text in Texas| is big. |
| 2393 |
|
| 2394 |
.. |the text in Texas| style:: big |
| 2395 |
|
| 2396 |
The style name may be meaningful in the context of some particular |
| 2397 |
output format (CSS class name for HTML output, LaTeX style name |
| 2398 |
for LaTeX, etc), or may be ignored for other output formats (such |
| 2399 |
as plaintext). |
| 2400 |
|
| 2401 |
.. @@@ This needs to be rethought & rewritten or removed: |
| 2402 |
|
| 2403 |
Interpreted text is unsuitable for this purpose because the set |
| 2404 |
of style names cannot be predefined - it is the domain of the |
| 2405 |
content author, not the author of the parser and output |
| 2406 |
formatter - and there is no way to associate a style name |
| 2407 |
argument with an interpreted text style role. Also, it may be |
| 2408 |
desirable to use the same mechanism for styling blocks:: |
| 2409 |
|
| 2410 |
.. style:: motto |
| 2411 |
At Bob's Underwear Shop, we'll do anything to get in |
| 2412 |
your pants. |
| 2413 |
|
| 2414 |
.. style:: disclaimer |
| 2415 |
All rights reversed. Reprint what you like. |
| 2416 |
|
| 2417 |
.. [#] There may be sufficient need for a "style" mechanism to |
| 2418 |
warrant simpler syntax such as an extension to the interpreted |
| 2419 |
text role syntax. The substitution mechanism is cumbersome for |
| 2420 |
simple text styling. |
| 2421 |
|
| 2422 |
Templates |
| 2423 |
Inline markup may be used for later processing by a template |
| 2424 |
engine. For example, a Zope_ author might write:: |
| 2425 |
|
| 2426 |
Welcome back, |name|! |
| 2427 |
|
| 2428 |
.. |name| tal:: replace user/getUserName |
| 2429 |
|
| 2430 |
After processing, this ZPT output would result:: |
| 2431 |
|
| 2432 |
Welcome back, |
| 2433 |
<span tal:replace="user/getUserName">name</span>! |
| 2434 |
|
| 2435 |
Zope would then transform this to something like "Welcome back, |
| 2436 |
David!" during a session with an actual user. |
| 2437 |
|
| 2438 |
|
| 2439 |
Comments |
| 2440 |
```````` |
| 2441 |
|
| 2442 |
:Doctree element: `\<comment>`_ |
| 2443 |
:Config setting: strip_comments_ |
| 2444 |
|
| 2445 |
`Explicit markup blocks`_ that are not recognized as citations_, |
| 2446 |
directives_, footnotes_, `hyperlink targets`_, or `substitution |
| 2447 |
definitions`_ will be processed as a comment element. |
| 2448 |
|
| 2449 |
.. tip:: To ensure that none of the other explicit markup constructs |
| 2450 |
is recognized, leave the ``..`` on a line by itself. |
| 2451 |
|
| 2452 |
Arbitrary indented text may be used on the lines following the explicit |
| 2453 |
markup start:: |
| 2454 |
|
| 2455 |
.. This is a comment |
| 2456 |
.. |
| 2457 |
_so: is this! |
| 2458 |
.. |
| 2459 |
[and] this! |
| 2460 |
.. |
| 2461 |
this:: too! |
| 2462 |
.. |
| 2463 |
|even| this:: ! |
| 2464 |
|
| 2465 |
.. [this] however, is a citation. |
| 2466 |
|
| 2467 |
Apart from removing the maximum common indentation, no further processing |
| 2468 |
is done on the content; a comment contains a single "text blob". |
| 2469 |
Depending on the output formatter, comments may be removed from the |
| 2470 |
processed output. In Docutils, the strip_comments_ configuration setting |
| 2471 |
triggers the removal of comment elements from the document tree. |
| 2472 |
|
| 2473 |
Syntax diagram:: |
| 2474 |
|
| 2475 |
+-------+----------------------+ |
| 2476 |
| ".. " | comment | |
| 2477 |
+-------+ block | |
| 2478 |
| | |
| 2479 |
+----------------------+ |
| 2480 |
|
| 2481 |
Empty Comments |
| 2482 |
.............. |
| 2483 |
|
| 2484 |
An explicit markup start followed by a blank line and nothing else |
| 2485 |
(apart from whitespace) is an "_`empty comment`". It serves to |
| 2486 |
terminate a preceding construct, and does **not** consume any indented |
| 2487 |
text following. To have a block quote follow a list or any indented |
| 2488 |
construct, insert an unindented empty comment in-between:: |
| 2489 |
|
| 2490 |
This is |
| 2491 |
a definition list. |
| 2492 |
|
| 2493 |
.. |
| 2494 |
|
| 2495 |
This is a block quote. |
| 2496 |
|
| 2497 |
|
| 2498 |
Inline Markup |
| 2499 |
============= |
| 2500 |
|
| 2501 |
In reStructuredText, inline markup applies to words or phrases within |
| 2502 |
a text block. The same whitespace and punctuation that serves to |
| 2503 |
delimit words in written text is used to delimit the inline markup |
| 2504 |
syntax constructs (see the `inline markup recognition rules`_ for |
| 2505 |
details). The text within inline markup may not begin or end with |
| 2506 |
whitespace. Arbitrary `character-level inline markup`_ is supported |
| 2507 |
although not encouraged. Inline markup cannot be nested. |
| 2508 |
|
| 2509 |
There are nine inline markup constructs. Five of the constructs use |
| 2510 |
identical start-strings and end-strings to indicate the markup: |
| 2511 |
|
| 2512 |
- emphasis_: ``*`` |
| 2513 |
- `strong emphasis`_: ``**`` |
| 2514 |
- `interpreted text`_: ````` |
| 2515 |
- `inline literals`_: `````` |
| 2516 |
- `substitution references`_: ``|`` |
| 2517 |
|
| 2518 |
Three constructs use different start-strings and end-strings: |
| 2519 |
|
| 2520 |
- `inline internal targets`_: ``_``` and ````` |
| 2521 |
- `footnote references`_: ``[`` and ``]_`` |
| 2522 |
- `hyperlink references`_: ````` and ```_`` (phrases), or just a |
| 2523 |
trailing ``_`` (single words) |
| 2524 |
|
| 2525 |
`Standalone hyperlinks`_ are recognized implicitly, and use no extra |
| 2526 |
markup. |
| 2527 |
|
| 2528 |
Inline comments are not supported. |
| 2529 |
|
| 2530 |
|
| 2531 |
Inline markup recognition rules |
| 2532 |
------------------------------- |
| 2533 |
|
| 2534 |
:Config setting: character_level_inline_markup_ |
| 2535 |
|
| 2536 |
Inline markup start-strings and end-strings are only recognized if |
| 2537 |
the following conditions are met: |
| 2538 |
|
| 2539 |
1. Inline markup start-strings must be immediately followed by |
| 2540 |
non-whitespace. |
| 2541 |
|
| 2542 |
2. Inline markup end-strings must be immediately preceded by |
| 2543 |
non-whitespace. |
| 2544 |
|
| 2545 |
3. The inline markup end-string must be separated by at least one |
| 2546 |
character from the start-string. |
| 2547 |
|
| 2548 |
4. Both, inline markup start-string and end-string must not be preceded by |
| 2549 |
an unescaped backslash (except for the end-string of `inline literals`_). |
| 2550 |
See `Escaping Mechanism`_ above for details. |
| 2551 |
|
| 2552 |
5. If an inline markup start-string is immediately preceded by one of the |
| 2553 |
ASCII characters ``' " < ( [ {`` or a similar |
| 2554 |
non-ASCII character [#openers]_, it must not be followed by the |
| 2555 |
corresponding closing character from ``' " > ) ] }`` or a similar |
| 2556 |
non-ASCII character [#closers]_. (For quotes, matching characters can |
| 2557 |
be any of the `quotation marks in international usage`_.) |
| 2558 |
|
| 2559 |
If the configuration setting character_level_inline_markup_ is False |
| 2560 |
(default), additional conditions apply to the characters "around" the |
| 2561 |
inline markup: |
| 2562 |
|
| 2563 |
6. Inline markup start-strings must start a text block or be |
| 2564 |
immediately preceded by |
| 2565 |
|
| 2566 |
* whitespace, |
| 2567 |
* one of the ASCII characters ``- : / ' " < ( [ {`` |
| 2568 |
* or a similar non-ASCII punctuation character. [#pre-chars]_ |
| 2569 |
|
| 2570 |
7. Inline markup end-strings must end a text block or be immediately |
| 2571 |
followed by |
| 2572 |
|
| 2573 |
* whitespace, |
| 2574 |
* one of the ASCII characters ``- . , : ; ! ? \ / ' " ) ] } >`` |
| 2575 |
* or a similar non-ASCII punctuation character. [#post-chars]_ |
| 2576 |
|
| 2577 |
.. [#openers] `Unicode categories`_ `Ps` (Open), `Pi` (Initial quote), |
| 2578 |
or `Pf` (Final quote). [#uni-version]_ |
| 2579 |
.. [#closers] Unicode categories `Pe` (Close), `Pi` (Initial quote), |
| 2580 |
or `Pf` (Final quote). [#uni-version]_ |
| 2581 |
.. [#pre-chars] Unicode categories `Ps` (Open), `Pi` (Initial quote), |
| 2582 |
`Pf` (Final quote), `Pd` (Dash), or `Po` (Other). [#uni-version]_ |
| 2583 |
.. [#post-chars] Unicode categories `Pe` (Close), `Pi` (Initial quote), |
| 2584 |
`Pf` (Final quote), `Pd` (Dash), or `Po` (Other). [#uni-version]_ |
| 2585 |
|
| 2586 |
.. [#uni-version] The category of some characters changed with the |
| 2587 |
development of the Unicode standard. |
| 2588 |
Docutils 0.13 … 0.21 uses `Unicode version 5.2.0`_. |
| 2589 |
|
| 2590 |
.. _Unicode categories: |
| 2591 |
https://www.unicode.org/Public/5.1.0/ucd/UCD.html#General_Category_Values |
| 2592 |
.. _Unicode version 5.2.0: https://www.unicode.org/Public/5.2.0/ |
| 2593 |
.. _quotation marks in international usage: |
| 2594 |
https://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage |
| 2595 |
|
| 2596 |
The inline markup recognition rules were devised to allow 90% of non-markup |
| 2597 |
uses of ``*``, `````, ``_``, and ``|`` without escaping. For example, none |
| 2598 |
of the following terms are recognized as containing inline markup strings: |
| 2599 |
|
| 2600 |
- 2 * x a ** b (* BOM32_* ` `` _ __ | (breaks rule 1) |
| 2601 |
- || (breaks rule 3) |
| 2602 |
- "*" '|' (*) [*] {*} <*> |
| 2603 |
‘*’ ‚*‘ ‘*‚ ’*’ ‚*’ |
| 2604 |
“*” „*“ “*„ ”*” „*” |
| 2605 |
»*« ›*‹ «*» »*» ›*› (breaks rule 5) |
| 2606 |
- 2*x a**b O(N**2) e**(x*y) f(x)*f(y) a|b file*.* |
| 2607 |
__init__ __init__() (breaks rule 6) |
| 2608 |
|
| 2609 |
No escaping is required inside the following inline markup examples: |
| 2610 |
|
| 2611 |
- ``*2 * x *a **b *.rst*`` (breaks rule 2; renders as "*2 * x *a **b *.rst*") |
| 2612 |
- ``*2*x a**b O(N**2) e**(x*y) f(x)*f(y) a*(1+2)*`` |
| 2613 |
(breaks rule 7; renders as "*2*x a**b O(N**2) e**(x*y) f(x)*f(y) a*(1+2)*") |
| 2614 |
|
| 2615 |
It may be desirable to use `inline literals`_ for some of these anyhow, |
| 2616 |
especially if they represent code snippets. It's a judgment call. |
| 2617 |
|
| 2618 |
The following terms *do* require either literal-quoting or escaping to avoid |
| 2619 |
misinterpretation:: |
| 2620 |
|
| 2621 |
*4, class_, *args, **kwargs, `TeX-quoted', *ML, *.rst |
| 2622 |
|
| 2623 |
In most use cases, `inline literals`_ or `literal blocks`_ are the best |
| 2624 |
choice (by default, this also selects a monospaced font). Alternatively, the |
| 2625 |
inline markup characters can be escaped:: |
| 2626 |
|
| 2627 |
\*4, class\_, \*args, \**kwargs, \`TeX-quoted', \*ML, \*.rst |
| 2628 |
|
| 2629 |
|
| 2630 |
For languages that don't use whitespace between words (e.g. Japanese or |
| 2631 |
Chinese) it is recommended to set character_level_inline_markup_ to True |
| 2632 |
and escape inline markup characters in case of non-markup use. |
| 2633 |
The examples breaking rules 6 and 7 above show which constructs may need |
| 2634 |
special attention. |
| 2635 |
|
| 2636 |
|
| 2637 |
Recognition order |
| 2638 |
----------------- |
| 2639 |
|
| 2640 |
Inline markup delimiter characters are used for multiple constructs, |
| 2641 |
so to avoid ambiguity there must be a specific recognition order for |
| 2642 |
each character. The inline markup recognition order is as follows: |
| 2643 |
|
| 2644 |
- Asterisks: `Strong emphasis`_ (``**``) is recognized before emphasis_ |
| 2645 |
(``*``). |
| 2646 |
|
| 2647 |
- Backquotes: `Inline literals`_ (``````), `inline internal targets`_ |
| 2648 |
(leading ``_```, trailing `````), are mutually independent, and are |
| 2649 |
recognized before phrase `hyperlink references`_ (leading `````, |
| 2650 |
trailing ```_``) and `interpreted text`_ (`````). |
| 2651 |
|
| 2652 |
- Trailing underscores: Footnote references (``[`` + label + ``]_``) and |
| 2653 |
simple `hyperlink references`_ (name + trailing ``_``) are mutually |
| 2654 |
independent. |
| 2655 |
|
| 2656 |
- Vertical bars: `Substitution references`_ (``|``) are independently |
| 2657 |
recognized. |
| 2658 |
|
| 2659 |
- `Standalone hyperlinks`_ are the last to be recognized. |
| 2660 |
|
| 2661 |
|
| 2662 |
Character-Level Inline Markup |
| 2663 |
----------------------------- |
| 2664 |
|
| 2665 |
:Config setting: character_level_inline_markup_ |
| 2666 |
|
| 2667 |
It is possible to mark up individual characters within a word with |
| 2668 |
backslash escapes (see `Escaping Mechanism`_ above). Backslash |
| 2669 |
escapes can be used to allow arbitrary text to immediately follow |
| 2670 |
inline markup:: |
| 2671 |
|
| 2672 |
Python ``list``\s use square bracket syntax. |
| 2673 |
|
| 2674 |
The backslash will disappear from the processed document. The word |
| 2675 |
"list" will appear as inline literal text, and the letter "s" will |
| 2676 |
immediately follow it as normal text, with no space in-between. |
| 2677 |
|
| 2678 |
Arbitrary text may immediately precede inline markup using |
| 2679 |
backslash-escaped whitespace:: |
| 2680 |
|
| 2681 |
Possible in *re*\ ``Structured``\ *Text*, though not encouraged. |
| 2682 |
|
| 2683 |
The backslashes and spaces separating "re", "Structured", and "Text" |
| 2684 |
above will disappear from the processed document. |
| 2685 |
|
| 2686 |
.. CAUTION:: |
| 2687 |
|
| 2688 |
The use of backslash-escapes for character-level inline markup is |
| 2689 |
not encouraged. Such use is ugly and detrimental to the |
| 2690 |
unprocessed document's readability. Please use this feature |
| 2691 |
sparingly and only where absolutely necessary. |
| 2692 |
|
| 2693 |
In Docutils, you may relax the `inline markup recognition rules`_ with |
| 2694 |
the character_level_inline_markup_ setting, however this may in turn |
| 2695 |
lead to false positives. |
| 2696 |
|
| 2697 |
|
| 2698 |
Emphasis |
| 2699 |
-------- |
| 2700 |
|
| 2701 |
:Doctree element: `\<emphasis>`_ |
| 2702 |
:Start/End string: ``*`` |
| 2703 |
:Standard role: `:emphasis:`_ |
| 2704 |
|
| 2705 |
Text enclosed by single asterisk characters is emphasized:: |
| 2706 |
|
| 2707 |
This is *emphasized text*. |
| 2708 |
|
| 2709 |
Emphasized text is typically displayed in italics. |
| 2710 |
|
| 2711 |
|
| 2712 |
Strong Emphasis |
| 2713 |
--------------- |
| 2714 |
|
| 2715 |
:Doctree element: `\<strong>`_ |
| 2716 |
:Start/End string: ``**`` |
| 2717 |
:Standard role: `:strong:`_ |
| 2718 |
|
| 2719 |
Text enclosed by double-asterisks is emphasized strongly:: |
| 2720 |
|
| 2721 |
This is **strong text**. |
| 2722 |
|
| 2723 |
Strongly emphasized text is typically displayed in boldface. |
| 2724 |
|
| 2725 |
|
| 2726 |
Interpreted Text |
| 2727 |
---------------- |
| 2728 |
|
| 2729 |
:Doctree element: depends on the explicit or implicit role and |
| 2730 |
processing |
| 2731 |
:Start/End string: `````\ |
| 2732 |
:Configuration: `"default-role"`_ directive |
| 2733 |
:See also: `reStructuredText Interpreted Text Roles`_ |
| 2734 |
|
| 2735 |
Interpreted text is text that is meant to be related, indexed, linked, |
| 2736 |
summarized, or otherwise processed, but the text itself is typically |
| 2737 |
left alone. Interpreted text is enclosed by single backquote |
| 2738 |
characters:: |
| 2739 |
|
| 2740 |
This is `interpreted text`. |
| 2741 |
|
| 2742 |
The *role* of the interpreted text determines how the text is |
| 2743 |
interpreted. The role may be inferred implicitly (as above; the |
| 2744 |
*default role* is used) or indicated explicitly, using a role marker. |
| 2745 |
A role marker consists of a colon, the role name, and another colon. |
| 2746 |
A role name is a single word consisting of alphanumerics plus isolated |
| 2747 |
internal hyphens, underscores, plus signs, colons, and periods; |
| 2748 |
no whitespace or other characters are allowed. A role marker is |
| 2749 |
either a prefix or a suffix to the interpreted text, whichever reads |
| 2750 |
better; it's up to the author:: |
| 2751 |
|
| 2752 |
:role:`interpreted text` |
| 2753 |
|
| 2754 |
`interpreted text`:role: |
| 2755 |
|
| 2756 |
Interpreted text allows extensions to the available inline descriptive |
| 2757 |
markup constructs. To `emphasis`_, `strong emphasis`_, `inline |
| 2758 |
literals`_, and `hyperlink references`_, we can add "title-reference", |
| 2759 |
"index-entry", "acronym", "class", "red", "blinking" or anything else |
| 2760 |
we want (as long as it is a `simple reference name`_). |
| 2761 |
Only pre-determined roles are recognized; unknown roles will |
| 2762 |
generate errors. |
| 2763 |
|
| 2764 |
A core set of *standard roles* is implemented in the |
| 2765 |
reference parser; see `reStructuredText Interpreted Text Roles`_ for |
| 2766 |
individual descriptions. The `"role" directive`_ can be used to define |
| 2767 |
custom interpreted text roles. In addition, applications may support |
| 2768 |
specialized roles. The *default role* (used for interpreted text without |
| 2769 |
role marker) can be set with the `"default-role"`_ directive. |
| 2770 |
|
| 2771 |
In `field lists`_, care must be taken when using interpreted text with |
| 2772 |
explicit roles in field names: the role must be a suffix to the |
| 2773 |
interpreted text. The following are recognized as field list items:: |
| 2774 |
|
| 2775 |
:`field name`:code:: interpreted text with explicit role as suffix |
| 2776 |
|
| 2777 |
:a `complex`:code:\ field name: a backslash-escaped space |
| 2778 |
is necessary |
| 2779 |
|
| 2780 |
The following are **not** recognized as field list items:: |
| 2781 |
|
| 2782 |
::code:`not a field name`: paragraph with interpreted text |
| 2783 |
|
| 2784 |
:\ :code:`not a field name`: paragraph with interpreted text |
| 2785 |
|
| 2786 |
Edge cases:: |
| 2787 |
|
| 2788 |
:field\:`name`: interpreted text (standard role) requires |
| 2789 |
escaping the leading colon in a field name |
| 2790 |
|
| 2791 |
:field:\`name`: not interpreted text |
| 2792 |
|
| 2793 |
|
| 2794 |
Inline Literals |
| 2795 |
--------------- |
| 2796 |
|
| 2797 |
:Doctree element: `\<literal>`_ |
| 2798 |
:Start/End string: ``````\ |
| 2799 |
:Standard role: `:literal:`_ |
| 2800 |
:See also: `:code:`_ |
| 2801 |
|
| 2802 |
Text enclosed by double-backquotes is treated as inline literals:: |
| 2803 |
|
| 2804 |
This text is an example of ``inline literals``. |
| 2805 |
|
| 2806 |
Inline literals may contain any characters except two adjacent |
| 2807 |
backquotes in an end-string context (according to the recognition |
| 2808 |
rules above). No markup interpretation (including backslash-escape |
| 2809 |
interpretation) is done within inline literals. |
| 2810 |
|
| 2811 |
Line breaks and sequences of whitespace characters |
| 2812 |
are *not* protected in inline literals. |
| 2813 |
Although a reStructuredText parser will preserve them in its output, |
| 2814 |
the final representation of the processed document depends on the |
| 2815 |
output formatter, thus the preservation of whitespace cannot be |
| 2816 |
guaranteed. If the preservation of line breaks and/or other |
| 2817 |
whitespace is important, `literal blocks`_ should be used. |
| 2818 |
|
| 2819 |
Inline literals or the `:code:`_ role are useful for short code snippets. |
| 2820 |
For example:: |
| 2821 |
|
| 2822 |
The regular expression ``[+-]?(\d+(\.\d*)?|\.\d+)`` matches |
| 2823 |
floating-point numbers (without exponents). |
| 2824 |
|
| 2825 |
|
| 2826 |
.. _hyperlink reference: |
| 2827 |
|
| 2828 |
Hyperlink References |
| 2829 |
-------------------- |
| 2830 |
|
| 2831 |
.. class:: compact |
| 2832 |
|
| 2833 |
:Doctree element: `\<reference>`_ |
| 2834 |
:Start/End strings: |
| 2835 |
.. table:: |
| 2836 |
:class: borderless |
| 2837 |
:widths: grid |
| 2838 |
|
| 2839 |
=================== ========== ======== ========= |
| 2840 |
reference type name start end |
| 2841 |
=================== ========== ======== ========= |
| 2842 |
named simple_ none ``_`` |
| 2843 |
.. phrase_ `````\ ```_`` |
| 2844 |
anonymous_ simple none ``__`` |
| 2845 |
.. phrase `````\ ```__`` |
| 2846 |
=================== ========== ======== ========= |
| 2847 |
|
| 2848 |
:See also: `hyperlink targets`_ |
| 2849 |
|
| 2850 |
.. _simple: `simple reference names`_ |
| 2851 |
.. _phrase: `phrase references`_ |
| 2852 |
|
| 2853 |
Hyperlink references are indicated by a trailing underscore (``_``) |
| 2854 |
except for `standalone hyperlinks`_ which are recognized |
| 2855 |
independently. The underscore can be thought of as a right-pointing |
| 2856 |
arrow. The trailing underscores point away from hyperlink references, |
| 2857 |
and the leading underscores point toward `hyperlink targets`_. |
| 2858 |
|
| 2859 |
.. _hyperlinks: |
| 2860 |
|
| 2861 |
*Hyperlinks* consist of two parts: |
| 2862 |
|
| 2863 |
1. In the text body, there is a *reference*, a `reference name`_ with a |
| 2864 |
trailing underscore (or two underscores for `anonymous hyperlinks`_):: |
| 2865 |
|
| 2866 |
See the Python_ home page for info. |
| 2867 |
|
| 2868 |
2. A matching *target* must exist in the document. |
| 2869 |
It may be embedded (see below) or exist somewhere else in the document |
| 2870 |
(`explicit hyperlink targets`_, `implicit hyperlink targets`_, |
| 2871 |
`inline internal targets`_, directives_ with `"name" option`_, |
| 2872 |
citations_, or `numbered footnotes`_). |
| 2873 |
|
| 2874 |
*Named* hyperlinks match reference and target by their `reference names`_. |
| 2875 |
*Anonymous* hyperlinks match references to targets by their |
| 2876 |
`order within the document`__. |
| 2877 |
|
| 2878 |
__ `anonymous matching`_ |
| 2879 |
|
| 2880 |
|
| 2881 |
Embedded URIs and Aliases |
| 2882 |
````````````````````````` |
| 2883 |
|
| 2884 |
:Doctree elements: `\<reference>`_, `\<target>`_ |
| 2885 |
:Start/End strings: ``<`` ``>`` |
| 2886 |
(only recognized inside `hyperlink references`_) |
| 2887 |
|
| 2888 |
A hyperlink reference may directly embed a target URI or an "alias" |
| 2889 |
hyperlink reference within angle brackets as follows:: |
| 2890 |
|
| 2891 |
See the `Python home page <https://www.python.org>`_ for info. |
| 2892 |
|
| 2893 |
This `link <Python home page_>`_ is an alias to the link above. |
| 2894 |
|
| 2895 |
This is equivalent to:: |
| 2896 |
|
| 2897 |
See the `Python home page`_ for info. |
| 2898 |
|
| 2899 |
This link_ is an alias to the link above. |
| 2900 |
|
| 2901 |
.. _Python home page: https://www.python.org |
| 2902 |
.. _link: `Python home page`_ |
| 2903 |
|
| 2904 |
The bracketed URI must be preceded by whitespace and be the last text |
| 2905 |
before the end string. |
| 2906 |
|
| 2907 |
With a single trailing underscore, the reference is *named* |
| 2908 |
and generates an `implicit hyperlink target`_. |
| 2909 |
|
| 2910 |
With two trailing underscores, the reference is anonymous_ |
| 2911 |
and the link text cannot be re-used as reference name. |
| 2912 |
These are "one-off" hyperlinks. For example:: |
| 2913 |
|
| 2914 |
`RFC 2396 <https://www.rfc-editor.org/rfc/rfc2396.txt>`__ and `RFC |
| 2915 |
2732 <https://www.rfc-editor.org/rfc/rfc2732.txt>`__ together |
| 2916 |
define the syntax of URIs. |
| 2917 |
|
| 2918 |
is equivalent to:: |
| 2919 |
|
| 2920 |
`RFC 2396`__ and `RFC 2732`__ together define the syntax of URIs. |
| 2921 |
|
| 2922 |
__ https://www.rfc-editor.org/rfc/rfc2396.txt |
| 2923 |
__ https://www.rfc-editor.org/rfc/rfc2732.txt |
| 2924 |
|
| 2925 |
`Standalone hyperlinks`_ are treated as URIs, even if they end with an |
| 2926 |
underscore like in the example of a Python function documentation:: |
| 2927 |
|
| 2928 |
`__init__ <http:example.py.html#__init__>`__ |
| 2929 |
|
| 2930 |
If a target URI that is not recognized as `standalone hyperlink`_ happens |
| 2931 |
to end with an underscore, this needs to be backslash-escaped to avoid |
| 2932 |
being parsed as hyperlink reference. For example :: |
| 2933 |
|
| 2934 |
Use the `source <parrots.rst\_>`__. |
| 2935 |
|
| 2936 |
creates an anonymous reference to the file ``parrots.rst_``. |
| 2937 |
|
| 2938 |
If the reference text happens to end with angle-bracketed text that is |
| 2939 |
*not* a URI or hyperlink reference, at least one angle-bracket needs to |
| 2940 |
be backslash-escaped or an escaped space should follow. For example, here |
| 2941 |
are three references to titles describing a tag:: |
| 2942 |
|
| 2943 |
See `HTML Element: \<a>`_, `HTML Element: <b\>`_, and |
| 2944 |
`HTML Element: <c>\ `_. |
| 2945 |
|
| 2946 |
The reference text may also be omitted, in which case the URI will be |
| 2947 |
duplicated for use as the reference text. This is useful for |
| 2948 |
URI-references_ where the address or file name is also the desired |
| 2949 |
reference text:: |
| 2950 |
|
| 2951 |
See `<a_named_relative_link>`_ or |
| 2952 |
`<an_anonymous_relative_link>`__ for details. |
| 2953 |
|
| 2954 |
.. CAUTION:: |
| 2955 |
|
| 2956 |
This construct offers easy authoring and maintenance of hyperlinks |
| 2957 |
at the expense of general readability. Inline URIs, especially |
| 2958 |
long ones, inevitably interrupt the natural flow of text. For |
| 2959 |
documents meant to be read in source form, the use of independent |
| 2960 |
block-level `hyperlink targets`_ is **strongly recommended**. The |
| 2961 |
embedded URI construct is most suited to documents intended *only* |
| 2962 |
to be read in processed form. |
| 2963 |
|
| 2964 |
|
| 2965 |
Inline Internal Targets |
| 2966 |
------------------------ |
| 2967 |
|
| 2968 |
:Doctree element: `\<target>`_ |
| 2969 |
:Start/End strings: ``_``` ````` |
| 2970 |
:See also: `hyperlink targets`_ |
| 2971 |
|
| 2972 |
Inline internal targets are the equivalent of explicit `internal |
| 2973 |
hyperlink targets`_, but may appear within running text. The syntax |
| 2974 |
begins with an underscore and a backquote, is followed by a hyperlink |
| 2975 |
name or phrase, and ends with a backquote. Inline internal targets |
| 2976 |
may not be anonymous. |
| 2977 |
|
| 2978 |
For example, the following paragraph contains a hyperlink target named |
| 2979 |
"Norwegian Blue":: |
| 2980 |
|
| 2981 |
Oh yes, the _`Norwegian Blue`. What's, um, what's wrong with it? |
| 2982 |
|
| 2983 |
See `Implicit Hyperlink Targets`_ for the resolution of duplicate |
| 2984 |
reference names. |
| 2985 |
|
| 2986 |
|
| 2987 |
.. _footnote reference: |
| 2988 |
|
| 2989 |
Footnote References |
| 2990 |
------------------- |
| 2991 |
|
| 2992 |
.. class:: field-indent-12em |
| 2993 |
|
| 2994 |
:Doctree element: `\<footnote_reference>`_ |
| 2995 |
:Start/End string: ``[`` ``]_`` |
| 2996 |
:Config settings: `footnote_references <footnote_references setting_>`__ |
| 2997 |
trim_footnote_reference_space_ |
| 2998 |
:See also: footnotes_ |
| 2999 |
|
| 3000 |
A *footnote reference* consists of a square-bracketed |
| 3001 |
`footnote label`_ followed by a trailing underscore. |
| 3002 |
For example:: |
| 3003 |
|
| 3004 |
Please RTFM [1]_. [#]_ |
| 3005 |
|
| 3006 |
.. [1] Read The Fine Manual |
| 3007 |
.. [#] Life is too short for man pages, |
| 3008 |
and occasionally much too short without them. |
| 3009 |
|
| 3010 |
`Inline markup recognition rules`_ may require whitespace in front of the |
| 3011 |
footnote reference. To remove the whitespace from the output, use an |
| 3012 |
escaped whitespace character (see `Escaping Mechanism`_) or set the |
| 3013 |
trim_footnote_reference_space_ configuration setting. |
| 3014 |
Leading whitespace is removed by default, if the `footnote_references |
| 3015 |
setting`_ is "superscript". |
| 3016 |
|
| 3017 |
|
| 3018 |
Citation References |
| 3019 |
------------------- |
| 3020 |
|
| 3021 |
:Doctree element: `\<citation_reference>`_ |
| 3022 |
:Start/End string: ``[`` ``]_`` |
| 3023 |
:See also: citations_ |
| 3024 |
|
| 3025 |
Each citation reference consists of a square-bracketed label followed by |
| 3026 |
a trailing underscore. Citation labels are simple `reference names`_. |
| 3027 |
|
| 3028 |
For example:: |
| 3029 |
|
| 3030 |
Here is a citation reference: [CIT2002]_. |
| 3031 |
|
| 3032 |
|
| 3033 |
Substitution References |
| 3034 |
----------------------- |
| 3035 |
|
| 3036 |
:Doctree elements: `\<substitution_reference>`_, `\<reference>`_ |
| 3037 |
:Start/End string: ``|`` (optionally followed by ``_`` or ``__``). |
| 3038 |
|
| 3039 |
:See also: `substitution definitions`_ |
| 3040 |
|
| 3041 |
Vertical bars are used to bracket the substitution reference text. A |
| 3042 |
substitution reference may also be a `hyperlink reference`_ by appending |
| 3043 |
a ``_`` (named) or ``__`` (anonymous_) suffix; the substitution text is |
| 3044 |
used for the reference text in the named case. |
| 3045 |
|
| 3046 |
The processing system replaces substitution references with the |
| 3047 |
processed contents of the corresponding `substitution definitions`_ |
| 3048 |
(which see for the definition of "correspond"). Substitution |
| 3049 |
definitions produce inline-compatible elements. |
| 3050 |
|
| 3051 |
Examples:: |
| 3052 |
|
| 3053 |
This is a simple |substitution reference|. It will be |
| 3054 |
replaced by the processing system. |
| 3055 |
|
| 3056 |
This is a combination |substitution and hyperlink reference|_. |
| 3057 |
In addition to being replaced, the replacement text or element |
| 3058 |
will refer to the "substitution and hyperlink reference" target. |
| 3059 |
|
| 3060 |
|
| 3061 |
.. _standalone hyperlink: |
| 3062 |
|
| 3063 |
Standalone Hyperlinks |
| 3064 |
--------------------- |
| 3065 |
|
| 3066 |
:Doctree element: `\<reference>`_ |
| 3067 |
:Start/End string: none |
| 3068 |
|
| 3069 |
A URI [#URI]_ or standalone email address within a text block is treated |
| 3070 |
as a general external hyperlink with the URI rsp. address itself as the |
| 3071 |
link's text. For example:: |
| 3072 |
|
| 3073 |
See https://www.python.org. |
| 3074 |
|
| 3075 |
would be marked up in HTML as:: |
| 3076 |
|
| 3077 |
See <a href="https://www.python.org">https://www.python.org</a>. |
| 3078 |
|
| 3079 |
Two forms of standalone hyperlinks are recognized: |
| 3080 |
|
| 3081 |
1. URIs with known schemes |
| 3082 |
(per the `Official IANA Registry of URI Schemes`_ |
| 3083 |
and the W3C's `Retired Index of WWW Addressing Schemes`_). |
| 3084 |
Examples:: |
| 3085 |
|
| 3086 |
tel:+48-816-555-1212 |
| 3087 |
urn:isbn:0-486-27557-4 |
| 3088 |
news:comp.infosystems.www.servers.unix |
| 3089 |
https://[email protected]:123/forum/questions/?tag=networking&order=newest#top |
| 3090 |
|
| 3091 |
With queries, fragments, and %-escape sequences, URIs can become quite |
| 3092 |
complicated. A reStructuredText parser must be able to recognize any |
| 3093 |
URI, as defined in RFC3936. |
| 3094 |
|
| 3095 |
2. Standalone email addresses, which are treated as if they were |
| 3096 |
URIs with a "mailto:" scheme. Example:: |
| 3097 |
|
| 3098 |
[email protected] |
| 3099 |
|
| 3100 |
Punctuation at the end of a URI is not considered part of the URI, |
| 3101 |
unless the URI is terminated by a closing angle bracket (``>``). |
| 3102 |
Backslashes may be used in URIs to escape markup characters, |
| 3103 |
specifically asterisks (``*``) and underscores (``_``) which are valid URI |
| 3104 |
characters (see `Escaping Mechanism`_ above). |
| 3105 |
|
| 3106 |
.. [#URI] Uniform Resource Identifier. URIs are a general form of |
| 3107 |
URLs (Uniform Resource Locators). For the syntax of URIs see |
| 3108 |
RFC3986_. |
| 3109 |
|
| 3110 |
|
| 3111 |
.. _implicit hyperlink target: |
| 3112 |
|
| 3113 |
Implicit Hyperlink Targets |
| 3114 |
========================== |
| 3115 |
|
| 3116 |
:Doctree elements: `\<section>`_, `\<target>`_ |
| 3117 |
|
| 3118 |
Implicit hyperlink targets are generated by `section titles`_ |
| 3119 |
and named hyperlink references with `embedded URIs and aliases`_. |
| 3120 |
They may also be generated by extension constructs. |
| 3121 |
Implicit hyperlink targets behave identically to `explicit hyperlink |
| 3122 |
targets`_ except in case of duplicate reference names. |
| 3123 |
|
| 3124 |
.. _name conflicts: |
| 3125 |
|
| 3126 |
Ambiguity due to different objects with the same `reference name`_ is |
| 3127 |
avoided by the following procedure: |
| 3128 |
|
| 3129 |
#. Duplicate external__ or indirect__ hyperlink targets that refer to |
| 3130 |
the same URI or hyperlink reference do not conflict. One target |
| 3131 |
is invalidated_ and an INFO [#level]_ system message inserted. |
| 3132 |
|
| 3133 |
__ `external hyperlink targets`_ |
| 3134 |
__ `indirect hyperlink targets`_ |
| 3135 |
|
| 3136 |
#. `Explicit hyperlink targets`_, citations_, `numbered footnotes`_, |
| 3137 |
and directives_ with `"name" option`_ |
| 3138 |
override any implicit targets having the same reference name. |
| 3139 |
The implicit hyperlink target is invalidated_, |
| 3140 |
and an INFO [#level]_ system message inserted. |
| 3141 |
|
| 3142 |
#. Duplicate implicit hyperlink targets are both invalidated_, |
| 3143 |
and INFO [#level]_ system messages inserted. |
| 3144 |
For example, if two or more sections |
| 3145 |
have the same title (such as "Introduction" subsections of a |
| 3146 |
rigidly-structured document), there will be duplicate implicit |
| 3147 |
hyperlink targets. |
| 3148 |
|
| 3149 |
#. Duplicate `explicit hyperlink targets`_ (or other objects with |
| 3150 |
the same reference name) are both invalidated_, and WARNING [#level]_ |
| 3151 |
system messages inserted. |
| 3152 |
|
| 3153 |
The parser returns a set of *unique* hyperlink targets. The calling |
| 3154 |
software (such as Docutils_) can warn of unresolvable links, giving |
| 3155 |
reasons for the messages. |
| 3156 |
|
| 3157 |
.. [#level] See `Error Handling`__ in PEP 258 for a description of |
| 3158 |
system message levels. |
| 3159 |
|
| 3160 |
__ ../../peps/pep-0258.html#error-handling |
| 3161 |
|
| 3162 |
|
| 3163 |
Measures and Units |
| 3164 |
================== |
| 3165 |
|
| 3166 |
*Measures* consist of a positive floating point number in standard |
| 3167 |
(non-scientific) notation and an optional unit, possibly separated |
| 3168 |
by one or more spaces. |
| 3169 |
|
| 3170 |
Measures are only supported where explicitly mentioned in the reference |
| 3171 |
manuals (`directive option`_ values of type "length__" or "percentage__"). |
| 3172 |
In the `document tree`_, they are stored in attributes of type `measure`_. |
| 3173 |
|
| 3174 |
It is up to the processing system to provide a fallback/workaround |
| 3175 |
or raise an error if the output format does not support a unit |
| 3176 |
(or values without unit). |
| 3177 |
For the behaviour of the Docutils writers, see the `writer documentation`_. |
| 3178 |
|
| 3179 |
.. _directive option: `directive options`_ |
| 3180 |
__ directives.html#length |
| 3181 |
__ directives.html#percentage |
| 3182 |
|
| 3183 |
|
| 3184 |
Length Units |
| 3185 |
------------ |
| 3186 |
|
| 3187 |
The reStructuredText parser supports the `length units in CSS3`_. [#]_ |
| 3188 |
Unit identifiers are case-sensitive (in contrast to CSS): |
| 3189 |
|
| 3190 |
.. class:: align-center |
| 3191 |
|
| 3192 |
==== ======================= ================================== |
| 3193 |
em the element's font size |
| 3194 |
---- ----------------------------------------------------------- |
| 3195 |
ex x-height of the element's font |
| 3196 |
---- ----------------------------------------------------------- |
| 3197 |
ch width of the “0” (ZERO, U+0030) glyph in the element’s font |
| 3198 |
---- ----------------------------------------------------------- |
| 3199 |
rem font size of the root element |
| 3200 |
---- ----------------------------------------------------------- |
| 3201 |
vw 1% of the viewport (or paper) width |
| 3202 |
---- ----------------------------------------------------------- |
| 3203 |
vh 1% of the viewport (or paper) height |
| 3204 |
---- ----------------------------------------------------------- |
| 3205 |
vmin 1% of the viewport’s smaller dimension |
| 3206 |
---- ----------------------------------------------------------- |
| 3207 |
vmax 1% of the viewport’s larger dimension |
| 3208 |
---- ----------------------------------------------------------- |
| 3209 |
cm centimeters 1 cm = 10 mm |
| 3210 |
mm millimeters 1 mm = 1/1000 m |
| 3211 |
Q quarter-millimeters 1 Q = 1/4 mm [#]_ |
| 3212 |
in inches 1 in = 25.4 mm = 96 px |
| 3213 |
pc picas 1 pc = 1/6 in = 12 pt |
| 3214 |
pt points 1 pt = 1/72 in |
| 3215 |
px pixels 1 px = 3/4 pt = 1/96 in [#]_ |
| 3216 |
==== ======================= ================================== |
| 3217 |
|
| 3218 |
The following are all valid length values: 1.5em, 20 mm, .5 in, 42. |
| 3219 |
|
| 3220 |
.. [#] Up to Docutils 0.21, support was restricted to the |
| 3221 |
`length units in CSS2`_. |
| 3222 |
.. [#] The unit "Q" is common in Japanese typesetting. |
| 3223 |
.. [#] In LaTeX, the default definition is 1 px = 1 pt = 1/72 in |
| 3224 |
(cf. section `Length units <../../user/latex.html#length-units>`__ |
| 3225 |
in the LaTeX writer documentation). |
| 3226 |
|
| 3227 |
.. _length units in CSS2: |
| 3228 |
https://www.w3.org/TR/CSS2/syndata.html#length-units |
| 3229 |
.. _length units in CSS3: https://www.w3.org/TR/css-values-3/#lengths |
| 3230 |
.. _XSL units: https://www.w3.org/TR/xsl/#d0e5752 |
| 3231 |
|
| 3232 |
|
| 3233 |
Percentage Unit |
| 3234 |
--------------- |
| 3235 |
|
| 3236 |
Percentage values have a percent sign (``%``) as unit. Percentage |
| 3237 |
values are relative to other values, depending on the context in which |
| 3238 |
they occur. |
| 3239 |
|
| 3240 |
|
| 3241 |
---------------- |
| 3242 |
Error Handling |
| 3243 |
---------------- |
| 3244 |
|
| 3245 |
:Doctree elements: `\<system_message>`_, `\<problematic>`_ |
| 3246 |
|
| 3247 |
Markup errors are handled according to the specification in |
| 3248 |
`PEP 258`_. |
| 3249 |
|
| 3250 |
|
| 3251 |
.. References |
| 3252 |
========== |
| 3253 |
.. internal |
| 3254 |
-------- |
| 3255 |
.. _reStructuredText: https://docutils.sourceforge.io/rst.html |
| 3256 |
.. _Docutils: https://docutils.sourceforge.io/ |
| 3257 |
|
| 3258 |
.. _writer documentation: ../../index.html#writer-specific |
| 3259 |
|
| 3260 |
.. _character_level_inline_markup: |
| 3261 |
../../user/config.html#character-level-inline-markup |
| 3262 |
.. _footnote_references setting: |
| 3263 |
../../user/config.html#footnote-references |
| 3264 |
.. _language_code: ../../user/config.html#language-code |
| 3265 |
.. _output encoding error handler: |
| 3266 |
../../user/config.html#output-encoding-error-handler |
| 3267 |
.. _strip_comments: ../../user/config.html#strip-comments |
| 3268 |
.. _tab_width: ../../user/config.html#tab-width |
| 3269 |
.. _trim_footnote_reference_space: |
| 3270 |
../../user/config.html#trim-footnote-reference-space |
| 3271 |
|
| 3272 |
.. _reStructuredText Directives: directives.html |
| 3273 |
.. _"admonition": directives.html#admonitions |
| 3274 |
.. _"code": directives.html#code |
| 3275 |
.. _"csv-table": directives.html#csv-table |
| 3276 |
.. _"date": directives.html#date |
| 3277 |
.. _"default-role": directives.html#default-role |
| 3278 |
.. _"figure": directives.html#figure |
| 3279 |
.. _identifier normalization: directives.html#identifier-normalization |
| 3280 |
.. _"image": directives.html#image |
| 3281 |
.. _"list-table": directives.html#list-table |
| 3282 |
.. _"math": directives.html#math |
| 3283 |
.. _"meta": directives.html#metadata |
| 3284 |
.. _"name" option: directives.html#name |
| 3285 |
.. _"raw": directives.html#raw |
| 3286 |
.. _"replace": directives.html#replace |
| 3287 |
.. _"role" directive: directives.html#custom-interpreted-text-roles |
| 3288 |
.. _"table": directives.html#table |
| 3289 |
.. _"title": directives.html#metadata-document-title |
| 3290 |
.. _"unicode": directives.html#unicode |
| 3291 |
.. _custom roles: directives.html#role |
| 3292 |
.. _inline images: directives.html#inline-images |
| 3293 |
|
| 3294 |
.. _reStructuredText Interpreted Text Roles: roles.html |
| 3295 |
.. _`:code:`: roles.html#code |
| 3296 |
.. _`:emphasis:`: roles.html#emphasis |
| 3297 |
.. _`:literal:`: roles.html#literal |
| 3298 |
.. _`:raw:`: roles.html#raw |
| 3299 |
.. _`:strong:`: roles.html#strong |
| 3300 |
|
| 3301 |
.. _Document Tree: |
| 3302 |
.. _The Docutils Document Tree: ../doctree.html |
| 3303 |
.. _`<address>`: ../doctree.html#address |
| 3304 |
.. _`<attribution>`: ../doctree.html#attribution |
| 3305 |
.. _`<author>`: ../doctree.html#author |
| 3306 |
.. _`<authors>`: ../doctree.html#authors |
| 3307 |
.. _`<block_quote>`: ../doctree.html#block-quote |
| 3308 |
.. _`<bullet_list>`: ../doctree.html#bullet-list |
| 3309 |
.. _`<citation>`: ../doctree.html#citation |
| 3310 |
.. _`<citation_reference>`: ../doctree.html#citation-reference |
| 3311 |
.. _`<classifier>`: ../doctree.html#classifier |
| 3312 |
.. _`<colspec>`: ../doctree.html#colspec |
| 3313 |
.. _`<comment>`: ../doctree.html#comment |
| 3314 |
.. _`<contact>`: ../doctree.html#contact |
| 3315 |
.. _`<copyright>`: ../doctree.html#copyright |
| 3316 |
.. _`<date>`: ../doctree.html#date |
| 3317 |
.. _`<definition>`: ../doctree.html#definition |
| 3318 |
.. _`<definition_list>`: ../doctree.html#definition-list |
| 3319 |
.. _`<definition_list_item>`: ../doctree.html#definition-list-item |
| 3320 |
.. _`<description>`: ../doctree.html#description |
| 3321 |
.. _`<docinfo>`: ../doctree.html#docinfo |
| 3322 |
.. _`<doctest_block>`: ../doctree.html#doctest-block |
| 3323 |
.. _`<document>`: ../doctree.html#document |
| 3324 |
.. _`<entry>`: ../doctree.html#entry |
| 3325 |
.. _`<emphasis>`: ../doctree.html#emphasis |
| 3326 |
.. _`<enumerated_list>`: ../doctree.html#enumerated-list |
| 3327 |
.. _`<field>`: ../doctree.html#field |
| 3328 |
.. _`<field_body>`: ../doctree.html#field-body |
| 3329 |
.. _`<field_list>`: ../doctree.html#field-list |
| 3330 |
.. _`<field_name>`: ../doctree.html#field-name |
| 3331 |
.. _`<footnote>`: ../doctree.html#footnote |
| 3332 |
.. _`<footnote_reference>`: ../doctree.html#footnote-reference |
| 3333 |
.. _`<label>`: ../doctree.html#label |
| 3334 |
.. _`<line>`: ../doctree.html#line |
| 3335 |
.. _`<line_block>`: ../doctree.html#line-block |
| 3336 |
.. _`<list_item>`: ../doctree.html#list-item |
| 3337 |
.. _`<literal>`: ../doctree.html#literal |
| 3338 |
.. _`<literal_block>`: ../doctree.html#literal-block |
| 3339 |
.. _`<option>`: ../doctree.html#option |
| 3340 |
.. _`<option_argument>`: ../doctree.html#option-argument |
| 3341 |
.. _`<option_group>`: ../doctree.html#option-group |
| 3342 |
.. _`<option_list>`: ../doctree.html#option-list |
| 3343 |
.. _`<option_list_item>`: ../doctree.html#option-list-item |
| 3344 |
.. _`<option_string>`: ../doctree.html#option-string |
| 3345 |
.. _`<organization>`: ../doctree.html#organization |
| 3346 |
.. _`<paragraph>`: ../doctree.html#paragraph |
| 3347 |
.. _`<problematic>`: ../doctree.html#problematic |
| 3348 |
.. _`<reference>`: ../doctree.html#reference |
| 3349 |
.. _`<revision>`: ../doctree.html#revision |
| 3350 |
.. _`<row>`: ../doctree.html#row |
| 3351 |
.. _`<section>`: ../doctree.html#section |
| 3352 |
.. _`<status>`: ../doctree.html#status |
| 3353 |
.. _`<strong>`: ../doctree.html#strong |
| 3354 |
.. _`<substitution_definition>`: ../doctree.html#substitution-definition |
| 3355 |
.. _`<substitution_reference>`: ../doctree.html#substitution-reference |
| 3356 |
.. _`<system_message>`: ../doctree.html#system-message |
| 3357 |
.. _`<table>`: ../doctree.html#table |
| 3358 |
.. _`<target>`: ../doctree.html#target |
| 3359 |
.. _`<tbody>`: ../doctree.html#tbody |
| 3360 |
.. _`<term>`: ../doctree.html#term |
| 3361 |
.. _`<tgroup>`: ../doctree.html#tgroup |
| 3362 |
.. _`<thead>`: ../doctree.html#thead |
| 3363 |
.. _`<title>`: ../doctree.html#title |
| 3364 |
.. _`<topic>`: ../doctree.html#topic |
| 3365 |
.. _`<transition>`: ../doctree.html#transition |
| 3366 |
.. _`<version>`: ../doctree.html#version |
| 3367 |
.. _"classes" attribute: ../doctree.html#classes |
| 3368 |
.. _identifier key: ../doctree.html#identifiers |
| 3369 |
.. _invalidated: ../doctree.html#reference-name-removal |
| 3370 |
.. _`measure`: ../doctree.html#measure |
| 3371 |
.. _metadata title: ../doctree.html#title-attribute |
| 3372 |
|
| 3373 |
.. _Docutils Generic DTD: ../docutils.dtd |
| 3374 |
|
| 3375 |
.. _Docutils Internationalization: ../../howto/i18n.html |
| 3376 |
|
| 3377 |
.. _PEP 258: ../../peps/pep-0258.html |
| 3378 |
.. _writer: |
| 3379 |
.. _writers: ../../peps/pep-0258.html#writers |
| 3380 |
|
| 3381 |
.. _transforms: ../../api/transforms.html |
| 3382 |
.. _DocTitle transform: ../../api/transforms.html#doctitle |
| 3383 |
.. _DocInfo transform: ../../api/transforms.html#docinfo |
| 3384 |
.. _PreBibliographic Elements: |
| 3385 |
../../api/transforms.html#prebibliographic-elements |
| 3386 |
|
| 3387 |
.. external |
| 3388 |
-------- |
| 3389 |
.. _doctest module: https://docs.python.org/3/library/doctest.html |
| 3390 |
.. _Emacs table mode: http://table.sourceforge.net/ |
| 3391 |
.. _getopt.py: https://docs.python.org/3/library/getopt.html |
| 3392 |
.. _GNU libc getopt_long(): |
| 3393 |
https://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html |
| 3394 |
.. _Grouch: http://www.mems-exchange.org/software/grouch/ |
| 3395 |
.. _HTML Techniques for Web Content Accessibility Guidelines: |
| 3396 |
https://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text |
| 3397 |
.. _Official IANA Registry of URI Schemes: |
| 3398 |
http://www.iana.org/assignments/uri-schemes |
| 3399 |
.. _Retired Index of WWW Addressing Schemes: |
| 3400 |
https://www.w3.org/Addressing/schemes.html |
| 3401 |
.. _RFC822: https://www.rfc-editor.org/rfc/rfc822 |
| 3402 |
.. _RFC3986: https://www.rfc-editor.org/rfc/rfc3986 |
| 3403 |
.. _URI-references: |
| 3404 |
.. _URI-reference: https://www.rfc-editor.org/rfc/rfc3986.html#section-4.1 |
| 3405 |
.. _World Wide Web Consortium: https://www.w3.org/ |
| 3406 |
.. _Zope: http://www.zope.com/ |
| 3407 |
|
| 3408 |
|
| 3409 |
.. Emacs settings |
| 3410 |
|
| 3411 |
Local Variables: |
| 3412 |
mode: indented-text |
| 3413 |
mode: rst |
| 3414 |
indent-tabs-mode: nil |
| 3415 |
sentence-end-double-space: t |
| 3416 |
fill-column: 70 |
| 3417 |
End: |