| 1 |
.. This is a comment. Note how any initial comments are moved by |
| 2 |
transforms to after the document title, subtitle, and docinfo. |
| 3 |
|
| 4 |
.. _doctitle: |
| 5 |
|
| 6 |
================================ |
| 7 |
reStructuredText Test Document |
| 8 |
================================ |
| 9 |
|
| 10 |
.. Above is the document title, and below is the subtitle. |
| 11 |
They are transformed from section titles after parsing. |
| 12 |
|
| 13 |
.. _subtitle: |
| 14 |
|
| 15 |
-------------------------------- |
| 16 |
Examples of Syntax Constructs |
| 17 |
-------------------------------- |
| 18 |
|
| 19 |
.. bibliographic fields (which also require a transform): |
| 20 |
|
| 21 |
:Author: David Goodger |
| 22 |
:Address: 123 Example Street |
| 23 |
Example, EX Canada |
| 24 |
A1B 2C3 |
| 25 |
:Contact: [email protected] |
| 26 |
:Authors: Me; Myself; I |
| 27 |
:organization: humankind |
| 28 |
:date: Now, or yesterday. Or maybe even *before* yesterday. |
| 29 |
:status: This is a "work in progress" |
| 30 |
:revision: is managed by a version control system. |
| 31 |
:version: 1 |
| 32 |
:copyright: This document has been placed in the public domain. You |
| 33 |
may do with it as you wish. You may copy, modify, |
| 34 |
redistribute, reattribute, sell, buy, rent, lease, |
| 35 |
destroy, or improve it, quote it at length, excerpt, |
| 36 |
incorporate, collate, fold, staple, or mutilate it, or do |
| 37 |
anything else to it that your or anyone else's heart |
| 38 |
desires. |
| 39 |
:field name: This is a "generic bibliographic field". |
| 40 |
:field name "2": |
| 41 |
Generic bibliographic fields may contain multiple body elements. |
| 42 |
|
| 43 |
Like this. |
| 44 |
|
| 45 |
:Dedication: |
| 46 |
|
| 47 |
For Docutils users & co-developers. |
| 48 |
|
| 49 |
:abstract: |
| 50 |
|
| 51 |
This is a test document, containing at least one example of each |
| 52 |
reStructuredText construct. |
| 53 |
|
| 54 |
.. raw:: latex |
| 55 |
|
| 56 |
\pagebreak[4] % start ToC on new page |
| 57 |
|
| 58 |
.. contents:: Table of Contents |
| 59 |
.. section-numbering:: |
| 60 |
|
| 61 |
|
| 62 |
Structural Elements |
| 63 |
=================== |
| 64 |
|
| 65 |
Section Title |
| 66 |
------------- |
| 67 |
Section Subtitle |
| 68 |
```````````````` |
| 69 |
|
| 70 |
Lone subsections are converted to a section subtitle by a transform |
| 71 |
activated with the ``--section-subtitles`` command line option or the |
| 72 |
``sectsubtitle-xform`` configuration value. |
| 73 |
|
| 74 |
Empty Section |
| 75 |
------------- |
| 76 |
|
| 77 |
Transitions |
| 78 |
----------- |
| 79 |
|
| 80 |
Here's a transition: |
| 81 |
|
| 82 |
--------- |
| 83 |
|
| 84 |
It divides the section. Transitions may also occur between sections: |
| 85 |
|
| 86 |
--------- |
| 87 |
|
| 88 |
Body Elements |
| 89 |
============= |
| 90 |
|
| 91 |
Paragraphs |
| 92 |
---------- |
| 93 |
|
| 94 |
A paragraph. |
| 95 |
|
| 96 |
Inline Markup |
| 97 |
````````````` |
| 98 |
|
| 99 |
Paragraphs contain text and may contain inline markup: *emphasis*, |
| 100 |
**strong emphasis**, ``inline literals``, standalone hyperlinks |
| 101 |
(http://www.python.org), external hyperlinks (Python_), internal |
| 102 |
cross-references (example_), external hyperlinks with embedded URIs |
| 103 |
(`Python web site <http://www.python.org>`__), `anonymous hyperlink |
| 104 |
references`__ (`a second reference`__), footnote references (manually |
| 105 |
numbered [1]_, anonymous auto-numbered [#]_, labeled auto-numbered |
| 106 |
[#label]_, or symbolic [*]_), citation references (see [CIT2002]_), |
| 107 |
substitution references (|example| & |
| 108 |
a *trimmed heart* ``(U+2665):`` |heart|), and _`inline hyperlink targets` |
| 109 |
(see Targets_ below for a reference back to here). Character-level |
| 110 |
inline markup is also possible (although exceedingly ugly!) in *re*\ |
| 111 |
``Structured``\ *Text*. Problems are indicated by |problematic| text |
| 112 |
(generated by processing errors; this one is intentional). Here is a |
| 113 |
reference to the doctitle_ and the subtitle_. |
| 114 |
|
| 115 |
__ http://www.python.org/ |
| 116 |
__ https://docutils.sourceforge.io/ |
| 117 |
|
| 118 |
The default role for interpreted text is `Title Reference`. Here are |
| 119 |
some explicit interpreted text roles: a PEP reference (:PEP:`287`); an |
| 120 |
RFC reference (:RFC:`2822`); an abbreviation (:ab:`abb.`), an acronym |
| 121 |
(:ac:`reST`), code (:code:`print "hello world"`); a :sub:`subscript`; |
| 122 |
a :sup:`superscript` and explicit roles for :title:`Docutils`' |
| 123 |
:emphasis:`standard` :strong:`inline` :literal:`markup`. |
| 124 |
|
| 125 |
.. DO NOT RE-WRAP THE FOLLOWING PARAGRAPH! |
| 126 |
|
| 127 |
Let's test wrapping and whitespace significance in inline literals: |
| 128 |
``This is an example of --inline-literal --text, --including some-- |
| 129 |
strangely--hyphenated-words. Adjust-the-width-of-your-browser-window |
| 130 |
to see how the text is wrapped. -- ---- -------- Now note the |
| 131 |
spacing between the words of this sentence (words |
| 132 |
should be grouped in pairs).`` |
| 133 |
|
| 134 |
If the ``--pep-references`` option was supplied, there should be a |
| 135 |
live link to PEP 258 here. |
| 136 |
|
| 137 |
Bullet Lists |
| 138 |
------------ |
| 139 |
|
| 140 |
- A bullet list |
| 141 |
|
| 142 |
+ Nested bullet list. |
| 143 |
+ Nested item 2. |
| 144 |
|
| 145 |
- Item 2. |
| 146 |
|
| 147 |
Paragraph 2 of item 2. |
| 148 |
|
| 149 |
* Nested bullet list. |
| 150 |
* Nested item 2. |
| 151 |
|
| 152 |
- Third level. |
| 153 |
- Item 2. |
| 154 |
|
| 155 |
* Nested item 3. |
| 156 |
|
| 157 |
* This nested list should be compacted by the HTML writer. |
| 158 |
|
| 159 |
.. _target: |
| 160 |
|
| 161 |
.. Even if this item contains a target and a comment. |
| 162 |
|
| 163 |
Enumerated Lists |
| 164 |
---------------- |
| 165 |
|
| 166 |
1. Arabic numerals. |
| 167 |
|
| 168 |
a) lower alpha) |
| 169 |
|
| 170 |
(i) (lower roman) |
| 171 |
|
| 172 |
A. upper alpha. |
| 173 |
|
| 174 |
I) upper roman) |
| 175 |
|
| 176 |
2. Lists that don't start at 1: |
| 177 |
|
| 178 |
3. Three |
| 179 |
|
| 180 |
4. Four |
| 181 |
|
| 182 |
C. C |
| 183 |
|
| 184 |
D. D |
| 185 |
|
| 186 |
iii. iii |
| 187 |
|
| 188 |
iv. iv |
| 189 |
|
| 190 |
Definition Lists |
| 191 |
---------------- |
| 192 |
|
| 193 |
Term |
| 194 |
Definition |
| 195 |
Term : classifier |
| 196 |
Definition paragraph 1. |
| 197 |
|
| 198 |
Definition paragraph 2. |
| 199 |
Term |
| 200 |
Definition |
| 201 |
Term : classifier one : classifier two |
| 202 |
Definition |
| 203 |
|
| 204 |
Field Lists |
| 205 |
----------- |
| 206 |
|
| 207 |
:what: Field lists map field names to field bodies, like database |
| 208 |
records. They are often part of an extension syntax. They are |
| 209 |
an unambiguous variant of RFC 2822 fields. |
| 210 |
|
| 211 |
:how arg1 arg2: |
| 212 |
|
| 213 |
The field marker is a colon, the field name, and a colon. |
| 214 |
|
| 215 |
The field body may contain one or more body elements, indented |
| 216 |
relative to the field marker. |
| 217 |
|
| 218 |
:credits: |
| 219 |
|
| 220 |
.. class:: credits |
| 221 |
|
| 222 |
This paragraph has the `credits` class set. (This is actually not |
| 223 |
about credits but just for ensuring that the class attribute |
| 224 |
doesn't get stripped away.) |
| 225 |
|
| 226 |
Option Lists |
| 227 |
------------ |
| 228 |
|
| 229 |
For listing command-line options: |
| 230 |
|
| 231 |
-a command-line option "a" |
| 232 |
-b file options can have arguments |
| 233 |
and long descriptions |
| 234 |
--long options can be long, too |
| 235 |
--input=file long options can also have arguments |
| 236 |
/V DOS/VMS-style option |
| 237 |
|
| 238 |
--very-long-option |
| 239 |
The description can also start on the next line. |
| 240 |
|
| 241 |
The description may contain multiple body elements, |
| 242 |
regardless of where it starts. |
| 243 |
|
| 244 |
-x, -y, -z Multiple options are an "option group". |
| 245 |
-v, --verbose Commonly-seen: short & long options. |
| 246 |
-1 file, --one=file, --two file |
| 247 |
Multiple options with arguments. |
| 248 |
-f <[path]file> Option argumens must start with a letter |
| 249 |
or be wrapped in angle brackets. |
| 250 |
-d <src dest> Angle brackets are also required if an |
| 251 |
option expects more than one argument. |
| 252 |
|
| 253 |
There must be at least two spaces between the option and the |
| 254 |
description. |
| 255 |
|
| 256 |
Literal Blocks |
| 257 |
-------------- |
| 258 |
|
| 259 |
Literal blocks are indicated with a double-colon ("::") at the end of |
| 260 |
the preceding paragraph (over there ``-->``). They can be indented:: |
| 261 |
|
| 262 |
if literal_block: |
| 263 |
text = 'is left as-is' |
| 264 |
spaces_and_linebreaks = 'are preserved' |
| 265 |
markup_processing = None |
| 266 |
|
| 267 |
Or they can be quoted without indentation:: |
| 268 |
|
| 269 |
>> Great idea! |
| 270 |
> |
| 271 |
> Why didn't I think of that? |
| 272 |
|
| 273 |
Line Blocks |
| 274 |
----------- |
| 275 |
|
| 276 |
This section tests line blocks. Line blocks are body elements which |
| 277 |
consist of lines and other line blocks. Nested line blocks cause |
| 278 |
indentation. |
| 279 |
|
| 280 |
| This is a line block. It ends with a blank line. |
| 281 |
| New lines begin with a vertical bar ("|"). |
| 282 |
| Line breaks and initial indent are significant, and preserved. |
| 283 |
| Continuation lines are also possible. A long line that is intended |
| 284 |
to wrap should begin with a space in place of the vertical bar. |
| 285 |
| The left edge of a continuation line need not be aligned with |
| 286 |
the left edge of the text above it. |
| 287 |
|
| 288 |
| This is a second line block. |
| 289 |
| |
| 290 |
| Blank lines are permitted internally, but they must begin with a "|". |
| 291 |
|
| 292 |
Another line block, surrounded by paragraphs: |
| 293 |
|
| 294 |
| And it's no good waiting by the window |
| 295 |
| It's no good waiting for the sun |
| 296 |
| Please believe me, the things you dream of |
| 297 |
| They don't fall in the lap of no-one |
| 298 |
|
| 299 |
Take it away, Eric the Orchestra Leader! |
| 300 |
|
| 301 |
| A one, two, a one two three four |
| 302 |
| |
| 303 |
| Half a bee, philosophically, |
| 304 |
| must, *ipso facto*, half not be. |
| 305 |
| But half the bee has got to be, |
| 306 |
| *vis a vis* its entity. D'you see? |
| 307 |
| |
| 308 |
| But can a bee be said to be |
| 309 |
| or not to be an entire bee, |
| 310 |
| when half the bee is not a bee, |
| 311 |
| due to some ancient injury? |
| 312 |
| |
| 313 |
| Singing... |
| 314 |
|
| 315 |
A line block, like the following poem by Christian Morgenstern, can |
| 316 |
also be centre-aligned: |
| 317 |
|
| 318 |
.. class:: language-de align-center |
| 319 |
|
| 320 |
| **Die Trichter** |
| 321 |
| |
| 322 |
| Zwei Trichter wandeln durch die Nacht. |
| 323 |
| Durch ihres Rumpfs verengten Schacht |
| 324 |
| fließt weißes Mondlicht |
| 325 |
| still und heiter |
| 326 |
| auf ihren |
| 327 |
| Waldweg |
| 328 |
| u. s. |
| 329 |
| w. |
| 330 |
| |
| 331 |
|
| 332 |
Block Quotes |
| 333 |
------------ |
| 334 |
|
| 335 |
Block quotes consist of indented body elements: |
| 336 |
|
| 337 |
My theory by A. Elk. Brackets Miss, brackets. This theory goes |
| 338 |
as follows and begins now. All brontosauruses are thin at one |
| 339 |
end, much much thicker in the middle and then thin again at the |
| 340 |
far end. That is my theory, it is mine, and belongs to me and I |
| 341 |
own it, and what it is too. |
| 342 |
|
| 343 |
-- Anne Elk (Miss) |
| 344 |
|
| 345 |
The language of a quote (like any other object) can be specified by |
| 346 |
a class attribute: |
| 347 |
|
| 348 |
.. class:: language-fr |
| 349 |
|
| 350 |
.. |
| 351 |
|
| 352 |
ReStructuredText est un langage de balisage léger utilisé |
| 353 |
notamment dans la documentation du langage Python. |
| 354 |
|
| 355 |
Doctest Blocks |
| 356 |
-------------- |
| 357 |
|
| 358 |
>>> print 'Python-specific usage examples; begun with ">>>"' |
| 359 |
Python-specific usage examples; begun with ">>>" |
| 360 |
>>> print '(cut and pasted from interactive Python sessions)' |
| 361 |
(cut and pasted from interactive Python sessions) |
| 362 |
|
| 363 |
Footnotes |
| 364 |
--------- |
| 365 |
|
| 366 |
.. [1] A footnote contains body elements, consistently indented by at |
| 367 |
least 1 space. |
| 368 |
|
| 369 |
This is the footnote's second paragraph. |
| 370 |
|
| 371 |
.. [#label] Footnotes may be numbered, either manually (as in [1]_) or |
| 372 |
automatically using a "#"-prefixed label. This footnote has a |
| 373 |
label so it can be referred to from multiple places, both as a |
| 374 |
footnote reference ([#label]_) and as a `hyperlink reference`__. |
| 375 |
|
| 376 |
__ label_ |
| 377 |
|
| 378 |
.. [#] This footnote is numbered automatically and anonymously using a |
| 379 |
label of "#" only. |
| 380 |
|
| 381 |
This is the second paragraph. |
| 382 |
|
| 383 |
And this is the third paragraph. |
| 384 |
|
| 385 |
.. [*] Footnotes may also use symbols, specified with a "*" label. |
| 386 |
Here's a reference to the next footnote: [*]_. |
| 387 |
|
| 388 |
.. [*] This footnote shows the next symbol in the sequence. |
| 389 |
|
| 390 |
.. [4] Here's an unreferenced footnote, with a reference to a |
| 391 |
nonexistent footnote: [5]_. |
| 392 |
|
| 393 |
Citations |
| 394 |
--------- |
| 395 |
|
| 396 |
.. [CIT2002] Citations are text-labeled footnotes. They may be |
| 397 |
rendered separately and differently from footnotes. |
| 398 |
|
| 399 |
Here's a reference to the above, [CIT2002]_, and a [nonexistent]_ |
| 400 |
citation. |
| 401 |
|
| 402 |
.. _Another Target: |
| 403 |
|
| 404 |
Targets |
| 405 |
------- |
| 406 |
|
| 407 |
.. _example: |
| 408 |
|
| 409 |
This paragraph is pointed to by the explicit "example" target. A |
| 410 |
reference can be found under `Inline Markup`_, above. `Inline |
| 411 |
hyperlink targets`_ are also possible. |
| 412 |
|
| 413 |
Section headers are implicit targets, referred to by name. See |
| 414 |
Targets_, which is a subsection of `Body Elements`_. |
| 415 |
|
| 416 |
Explicit external targets are interpolated into references such as |
| 417 |
"Python_". |
| 418 |
|
| 419 |
.. _Python: http://www.python.org/ |
| 420 |
|
| 421 |
Targets may be indirect and anonymous. Thus `this phrase`__ may also |
| 422 |
refer to the Targets_ section. |
| 423 |
|
| 424 |
__ Targets_ |
| 425 |
|
| 426 |
Here's a `hyperlink reference without a target`_, which generates an |
| 427 |
error. |
| 428 |
|
| 429 |
Duplicate Target Names |
| 430 |
`````````````````````` |
| 431 |
|
| 432 |
Duplicate names in section headers or other implicit targets will |
| 433 |
generate "info" (level-1) system messages. Duplicate names in |
| 434 |
explicit targets will generate "warning" (level-2) system messages. |
| 435 |
|
| 436 |
Duplicate Target Names |
| 437 |
`````````````````````` |
| 438 |
|
| 439 |
Since there are two "Duplicate Target Names" section headers, we |
| 440 |
cannot uniquely refer to either of them by name. If we try to (like |
| 441 |
this: `Duplicate Target Names`_), an error is generated. |
| 442 |
|
| 443 |
Directives |
| 444 |
---------- |
| 445 |
|
| 446 |
.. contents:: :local: |
| 447 |
|
| 448 |
These are just a sample of the many reStructuredText Directives. For |
| 449 |
others, please see `reStructuredText Directives`__. |
| 450 |
|
| 451 |
__ https://docutils.sourceforge.io/docs/ref/rst/directives.html |
| 452 |
|
| 453 |
Document Parts |
| 454 |
`````````````` |
| 455 |
|
| 456 |
An example of the "contents" directive can be seen above this section |
| 457 |
(a local, untitled table of contents_) and at the beginning of the |
| 458 |
document (a document-wide `table of contents`_). |
| 459 |
|
| 460 |
Images and Figures |
| 461 |
`````````````````` |
| 462 |
|
| 463 |
An image directive (also clickable -- a hyperlink reference): |
| 464 |
|
| 465 |
.. image:: ../../../docs/user/rst/images/title.png |
| 466 |
:class: class1 class2 |
| 467 |
:target: directives_ |
| 468 |
:width: 70% |
| 469 |
|
| 470 |
Image with multiple IDs: |
| 471 |
|
| 472 |
.. _image target 1: |
| 473 |
.. _image target 2: |
| 474 |
.. _image target 3: |
| 475 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 476 |
|
| 477 |
A centered image: |
| 478 |
|
| 479 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 480 |
:align: center |
| 481 |
|
| 482 |
A left-aligned image: |
| 483 |
|
| 484 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 485 |
:align: left |
| 486 |
|
| 487 |
This paragraph might flow around the image. |
| 488 |
The specific behavior depends upon the style sheet and |
| 489 |
the browser or rendering software used. |
| 490 |
|
| 491 |
A right-aligned image: |
| 492 |
|
| 493 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 494 |
:align: right |
| 495 |
|
| 496 |
This paragraph might flow around the image. |
| 497 |
The specific behavior depends upon the style sheet and |
| 498 |
the browser or rendering software used. |
| 499 |
|
| 500 |
For inline images see `Substitution Definitions`_. |
| 501 |
|
| 502 |
Image size: |
| 503 |
|
| 504 |
An image 2 em wide: |
| 505 |
|
| 506 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 507 |
:width: 2 em |
| 508 |
|
| 509 |
An image 2 cm wide and 15 pixel high: |
| 510 |
|
| 511 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 512 |
:width: 2cm |
| 513 |
:height: 15 px |
| 514 |
|
| 515 |
Relative units allow adaption of the image to the screen or paper size. |
| 516 |
An image occupying 50% of the line width: |
| 517 |
|
| 518 |
.. image:: ../../../docs/user/rst/images/title.png |
| 519 |
:width: 50% |
| 520 |
|
| 521 |
A *figure* is an image with a caption and/or a legend. With page-based output |
| 522 |
media, figures might float to a different position if this helps the page |
| 523 |
layout. |
| 524 |
|
| 525 |
.. figure:: ../../../docs/user/rst/images/title.png |
| 526 |
:figclass: figclass1 figclass2 |
| 527 |
:class: class1 class2 |
| 528 |
:alt: reStructuredText, the markup syntax |
| 529 |
:target: https://docutils.sourceforge.io/rst.html |
| 530 |
:width: 258 |
| 531 |
|
| 532 |
Plaintext markup syntax and parser system. |
| 533 |
|
| 534 |
+------------+-----------------------------------------------+ |
| 535 |
| re | Revised, revisited, based on 're' module. | |
| 536 |
+------------+-----------------------------------------------+ |
| 537 |
| Structured | Structure-enhanced text, structuredtext. | |
| 538 |
+------------+-----------------------------------------------+ |
| 539 |
| Text | Well it is, isn't it? | |
| 540 |
+------------+-----------------------------------------------+ |
| 541 |
|
| 542 |
This paragraph is also part of the legend. |
| 543 |
|
| 544 |
A left-aligned figure, 70% wide: |
| 545 |
|
| 546 |
.. figure:: ../../../docs/user/rst/images/biohazard.png |
| 547 |
:figclass: figclass1 figclass2 |
| 548 |
:class: class1 class2 |
| 549 |
:alt: reStructuredText, the markup syntax |
| 550 |
:align: left |
| 551 |
:width: 40 px |
| 552 |
:figwidth: 70 % |
| 553 |
|
| 554 |
.. class:: captionclass1 captionclass2 |
| 555 |
.. _caption-label: |
| 556 |
|
| 557 |
This is the caption. |
| 558 |
|
| 559 |
This is the legend. |
| 560 |
|
| 561 |
The legend may consist of several paragraphs. |
| 562 |
|
| 563 |
This paragraph might flow around the figure. |
| 564 |
|
| 565 |
The specific behavior depends upon the style sheet and the browser or |
| 566 |
rendering software used. |
| 567 |
|
| 568 |
A centred figure, 40% wide: |
| 569 |
|
| 570 |
.. figure:: ../../../docs/user/rst/images/biohazard.png |
| 571 |
:align: center |
| 572 |
:width: 40 px |
| 573 |
:figwidth: 40% |
| 574 |
|
| 575 |
This is the caption. |
| 576 |
|
| 577 |
This is the legend. |
| 578 |
|
| 579 |
The legend may consist of several paragraphs. |
| 580 |
|
| 581 |
This paragraph might flow around the figure. |
| 582 |
|
| 583 |
The specific behavior depends upon the style sheet and the browser or |
| 584 |
rendering software used. |
| 585 |
|
| 586 |
A right-aligned figure: |
| 587 |
|
| 588 |
.. figure:: ../../../docs/user/rst/images/biohazard.png |
| 589 |
:align: right |
| 590 |
:width: 40 px |
| 591 |
|
| 592 |
This is the caption. |
| 593 |
|
| 594 |
This is the legend. |
| 595 |
|
| 596 |
The legend may consist of several paragraphs. |
| 597 |
|
| 598 |
This paragraph might flow around the figure. The specific behavior depends |
| 599 |
upon the style sheet and the browser or rendering software used. |
| 600 |
|
| 601 |
|
| 602 |
Tables |
| 603 |
`````` |
| 604 |
|
| 605 |
Tables may be given titles and additional arguments with the *table* |
| 606 |
directive: |
| 607 |
|
| 608 |
.. Table:: left-aligned table |
| 609 |
:align: left |
| 610 |
|
| 611 |
===== ===== |
| 612 |
A not A |
| 613 |
===== ===== |
| 614 |
False True |
| 615 |
True False |
| 616 |
===== ===== |
| 617 |
|
| 618 |
.. Table:: center-aligned table |
| 619 |
:align: center |
| 620 |
|
| 621 |
===== ===== |
| 622 |
A not A |
| 623 |
===== ===== |
| 624 |
False True |
| 625 |
True False |
| 626 |
===== ===== |
| 627 |
|
| 628 |
.. Table:: right-aligned table |
| 629 |
:align: right |
| 630 |
|
| 631 |
===== ===== |
| 632 |
A not A |
| 633 |
===== ===== |
| 634 |
False True |
| 635 |
True False |
| 636 |
===== ===== |
| 637 |
|
| 638 |
With the "widths" argument "auto" (or "class" value "colwidths-auto"), |
| 639 |
column widths are determined by the backend (if supported by the |
| 640 |
writer/backend). |
| 641 |
|
| 642 |
.. _target1: |
| 643 |
.. _target2: |
| 644 |
|
| 645 |
.. table:: |
| 646 |
:widths: auto |
| 647 |
|
| 648 |
======= ======= ========== |
| 649 |
A B A or B |
| 650 |
======= ======= ========== |
| 651 |
False False False |
| 652 |
True False True |
| 653 |
False True True |
| 654 |
True True True |
| 655 |
======= ======= ========== |
| 656 |
|
| 657 |
|
| 658 |
Admonitions |
| 659 |
``````````` |
| 660 |
|
| 661 |
.. Attention:: Directives at large. |
| 662 |
|
| 663 |
.. Caution:: |
| 664 |
|
| 665 |
Don't take any wooden nickels. |
| 666 |
|
| 667 |
.. DANGER:: Mad scientist at work! |
| 668 |
|
| 669 |
.. Error:: Does not compute. |
| 670 |
|
| 671 |
.. Hint:: It's bigger than a bread box. |
| 672 |
|
| 673 |
.. Important:: |
| 674 |
- Wash behind your ears. |
| 675 |
- Clean up your room. |
| 676 |
- Call your mother. |
| 677 |
- Back up your data. |
| 678 |
|
| 679 |
.. Note:: This is a note. |
| 680 |
|
| 681 |
.. Tip:: 15% if the service is good. |
| 682 |
|
| 683 |
.. WARNING:: Strong prose may provoke extreme mental exertion. |
| 684 |
Reader discretion is strongly advised. |
| 685 |
|
| 686 |
.. admonition:: And, by the way... |
| 687 |
|
| 688 |
You can make up your own admonition too. |
| 689 |
|
| 690 |
.. _Docutils: https://docutils.sourceforge.io/ |
| 691 |
|
| 692 |
Topics, Sidebars, and Rubrics |
| 693 |
````````````````````````````` |
| 694 |
|
| 695 |
*Sidebars* are like miniature, parallel documents. |
| 696 |
|
| 697 |
.. sidebar:: Optional Sidebar Title |
| 698 |
:subtitle: Optional Subtitle |
| 699 |
|
| 700 |
This is a sidebar. It is for text outside the flow of the main |
| 701 |
text. |
| 702 |
|
| 703 |
.. rubric:: This is a rubric inside a sidebar |
| 704 |
|
| 705 |
Sidebars often appear beside the main text with a border and a different |
| 706 |
background or font color. |
| 707 |
|
| 708 |
A *topic* is like a block quote with a title, or a self-contained section |
| 709 |
with no subsections. |
| 710 |
|
| 711 |
.. topic:: Topic Title |
| 712 |
|
| 713 |
This is a topic. |
| 714 |
|
| 715 |
A *rubric* is like an informal heading that doesn't correspond to the |
| 716 |
document's structure. It is typically highlighted in red (hence the name). |
| 717 |
|
| 718 |
.. rubric:: This is a rubric |
| 719 |
|
| 720 |
Topics and rubrics can be used at places where a `section title`_ is not |
| 721 |
allowed (e.g. inside a directive). |
| 722 |
|
| 723 |
Target Footnotes |
| 724 |
```````````````` |
| 725 |
|
| 726 |
.. target-notes:: |
| 727 |
|
| 728 |
|
| 729 |
Replacement Text |
| 730 |
```````````````` |
| 731 |
|
| 732 |
I recommend you try |Python|_. |
| 733 |
|
| 734 |
.. |Python| replace:: Python, *the* best language around |
| 735 |
|
| 736 |
Compound Paragraph |
| 737 |
`````````````````` |
| 738 |
|
| 739 |
The *compound* directive is used to create a "compound paragraph", which |
| 740 |
is a single logical paragraph containing multiple physical body |
| 741 |
elements. For example: |
| 742 |
|
| 743 |
.. compound:: |
| 744 |
|
| 745 |
The 'rm' command is very dangerous. If you are logged |
| 746 |
in as root and enter :: |
| 747 |
|
| 748 |
cd / |
| 749 |
rm -rf * |
| 750 |
|
| 751 |
you will erase the entire contents of your file system. |
| 752 |
|
| 753 |
Test the handling and display of compound paragraphs: |
| 754 |
|
| 755 |
.. compound:: |
| 756 |
:class: some-class |
| 757 |
|
| 758 |
Compound 2, paragraph 1, |
| 759 |
|
| 760 |
compound 2, paragraph 2, |
| 761 |
|
| 762 |
* list item 1, |
| 763 |
* list item 2, |
| 764 |
|
| 765 |
compound 2, paragraph 3. |
| 766 |
|
| 767 |
.. compound:: |
| 768 |
|
| 769 |
Compound 3, only consisting of one paragraph. |
| 770 |
|
| 771 |
.. compound:: |
| 772 |
|
| 773 |
:: |
| 774 |
|
| 775 |
Compound 4. |
| 776 |
This one starts with a literal block. |
| 777 |
|
| 778 |
Compound 4, paragraph following the literal block. |
| 779 |
|
| 780 |
Now something *really* perverted -- a nested compound block. This is |
| 781 |
just to test that it works at all; the results don't have to be |
| 782 |
meaningful. |
| 783 |
|
| 784 |
.. compound:: |
| 785 |
|
| 786 |
Compound 5, block 1 (a paragraph). |
| 787 |
|
| 788 |
.. compound:: |
| 789 |
|
| 790 |
Compound 6 is block 2 in compound 5. |
| 791 |
|
| 792 |
Compound 6, another paragraph. |
| 793 |
|
| 794 |
Compound 5, block 3 (a paragraph). |
| 795 |
|
| 796 |
.. compound:: |
| 797 |
|
| 798 |
Compound 7, tests the inclusion of various block-level |
| 799 |
elements in one logical paragraph. First a table, |
| 800 |
|
| 801 |
+--------------------+--------------------+--------------------+ |
| 802 |
| Left cell, first | Middle cell, | Right cell. | |
| 803 |
| paragraph. | consisting of | | |
| 804 |
| | exactly one | Paragraph 2. | |
| 805 |
| Left cell, second | paragraph. | | |
| 806 |
| paragraph. | | Paragraph 3. | |
| 807 |
+--------------------+--------------------+--------------------+ |
| 808 |
|
| 809 |
followed by a paragraph. This physical paragraph is |
| 810 |
actually a continuation of the paragraph before the table. It is followed |
| 811 |
by |
| 812 |
|
| 813 |
a quote and |
| 814 |
|
| 815 |
#. an enumerated list, |
| 816 |
|
| 817 |
a paragraph, |
| 818 |
|
| 819 |
--an option list, |
| 820 |
|
| 821 |
a paragraph, |
| 822 |
|
| 823 |
:a field: list, |
| 824 |
|
| 825 |
a paragraph, |
| 826 |
|
| 827 |
a definition |
| 828 |
list, |
| 829 |
|
| 830 |
a paragraph, an image: |
| 831 |
|
| 832 |
.. image:: ../../../docs/user/rst/images/biohazard.png |
| 833 |
|
| 834 |
a paragraph, |
| 835 |
|
| 836 |
| a line |
| 837 |
| block, |
| 838 |
|
| 839 |
a paragraph followed by a comment, |
| 840 |
|
| 841 |
.. this is a comment |
| 842 |
|
| 843 |
a paragraph, a |
| 844 |
|
| 845 |
.. note:: with content |
| 846 |
|
| 847 |
and the final paragraph of the compound 7. |
| 848 |
|
| 849 |
Parsed Literal Blocks |
| 850 |
````````````````````` |
| 851 |
|
| 852 |
.. parsed-literal:: |
| 853 |
|
| 854 |
This is a parsed literal block. |
| 855 |
This line is indented. The next line is blank. |
| 856 |
|
| 857 |
Inline markup is supported, e.g. *emphasis*, **strong**, ``literal |
| 858 |
text``, :sub:`sub-` and :sup:`super`\ scripts, |
| 859 |
inline formulas: :math:`A = 2 \pi r^2`, |
| 860 |
footnotes [1]_, _`hyperlink targets`, and `references |
| 861 |
<http://www.python.org/>`_. |
| 862 |
|
| 863 |
Code |
| 864 |
```` |
| 865 |
|
| 866 |
Blocks of source code can be set with the `code` directive. If the code |
| 867 |
language is specified, the content is parsed and tagged by the Pygments_ |
| 868 |
syntax highlighter and can be formatted with a style sheet. (Code parsing |
| 869 |
is turned off using the ``syntax-highlight`` config setting in the test |
| 870 |
conversions in order to get identical results with/without installed |
| 871 |
Pygments highlighter.) |
| 872 |
|
| 873 |
.. code:: python |
| 874 |
|
| 875 |
print 'This is Python code.' |
| 876 |
|
| 877 |
The ``:number-lines:`` option (with optional start value) generates line |
| 878 |
numbers: |
| 879 |
|
| 880 |
.. code:: python |
| 881 |
:number-lines: 8 |
| 882 |
|
| 883 |
# print integers from 0 to 9: |
| 884 |
for i in range(10): |
| 885 |
print i |
| 886 |
|
| 887 |
For inline code snippets, there is the `code` role, which can be used |
| 888 |
directly (the code will not be parsed/tagged, as the language is not known) |
| 889 |
or as base for special code roles, e.g. the LaTeX code in the next |
| 890 |
paragraph. |
| 891 |
|
| 892 |
.. role:: tex(code) |
| 893 |
:language: tex |
| 894 |
|
| 895 |
Docutils uses LaTeX syntax for math directives and roles: |
| 896 |
:tex:`\alpha = f(x)` prints :math:`\alpha = f(x)`. |
| 897 |
|
| 898 |
The ``:code:`` option of the `include` directive sets the included content |
| 899 |
as a code block, here the rst file ``header_footer.rst`` with line numbers: |
| 900 |
|
| 901 |
.. include:: header_footer.rst |
| 902 |
:code: rst |
| 903 |
:number-lines: |
| 904 |
|
| 905 |
.. _Pygments: http://pygments.org/ |
| 906 |
|
| 907 |
|
| 908 |
Meta |
| 909 |
```` |
| 910 |
|
| 911 |
The `“meta” directive`__ is used to specify metadata to be stored in, |
| 912 |
e.g., HTML META tags or ODT file properties. |
| 913 |
|
| 914 |
.. meta:: |
| 915 |
:keywords: reStructuredText, test, parser |
| 916 |
:description lang=en: A test document, containing at least one |
| 917 |
example of each reStructuredText construct. |
| 918 |
|
| 919 |
__ https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata |
| 920 |
|
| 921 |
|
| 922 |
Substitution Definitions |
| 923 |
------------------------ |
| 924 |
|
| 925 |
An inline image (|example|) example: |
| 926 |
|
| 927 |
.. |EXAMPLE| image:: ../../../docs/user/rst/images/biohazard.png |
| 928 |
|
| 929 |
A Unicode example: |
| 930 |
|
| 931 |
.. |heart| unicode:: 0x2665 |
| 932 |
:trim: |
| 933 |
|
| 934 |
(Substitution definitions are only visible in the rST source.) |
| 935 |
|
| 936 |
Comments |
| 937 |
-------- |
| 938 |
|
| 939 |
Here's one: |
| 940 |
|
| 941 |
.. Comments begin with two dots and a space. Anything may |
| 942 |
follow, except for the syntax of footnotes, hyperlink |
| 943 |
targets, directives, or substitution definitions. |
| 944 |
|
| 945 |
Double-dashes -- "--" -- must be escaped somehow in HTML output. |
| 946 |
|
| 947 |
Comments may contain non-ASCII characters: ä ö ü æ ø å |
| 948 |
|
| 949 |
(View the HTML/LaTeX/... source to see the comment.) |
| 950 |
|
| 951 |
Raw text |
| 952 |
-------- |
| 953 |
|
| 954 |
This does not necessarily look nice, because there may be missing white space. |
| 955 |
|
| 956 |
It's just there to freeze the behavior. |
| 957 |
|
| 958 |
.. raw:: html latex |
| 959 |
|
| 960 |
A test. |
| 961 |
|
| 962 |
.. raw:: html latex |
| 963 |
|
| 964 |
Second test. |
| 965 |
|
| 966 |
.. class:: myclass |
| 967 |
|
| 968 |
.. raw:: html latex |
| 969 |
|
| 970 |
Another test with myclass set. |
| 971 |
|
| 972 |
.. role:: raw-role(raw) |
| 973 |
:format: html latex |
| 974 |
:class: myrawroleclass |
| 975 |
|
| 976 |
This is the :raw-role:`fourth test` with myrawroleclass set. |
| 977 |
|
| 978 |
.. raw:: html |
| 979 |
|
| 980 |
Fifth test in HTML.<br />Line two. |
| 981 |
|
| 982 |
.. raw:: latex |
| 983 |
|
| 984 |
Fifth test in LaTeX.\\Line two. |
| 985 |
|
| 986 |
Container |
| 987 |
--------- |
| 988 |
|
| 989 |
.. container:: custom |
| 990 |
|
| 991 |
paragraph 1 |
| 992 |
|
| 993 |
paragraph 2 |