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