1 .. This is a comment. Note how any initial comments are moved by
2 transforms to after the document title, subtitle, and docinfo.
6 ================================
7 reStructuredText Test Document
8 ================================
10 .. Above is the document title, and below is the subtitle.
11 They are transformed from section titles after parsing.
15 --------------------------------
16 Examples of Syntax Constructs
17 --------------------------------
19 .. bibliographic fields (which also require a transform):
21 :Author: David Goodger
22 :Address: 123 Example Street
25 :Contact: goodger@python.org
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.
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
39 :field name: This is a "generic bibliographic field".
41 Generic bibliographic fields may contain multiple body elements.
47 For Docutils users & co-developers.
51 This is a test document, containing at least one example of each
52 reStructuredText construct.
55 :keywords: reStructuredText, test, parser
56 :description lang=en: A test document, containing at least one
57 example of each reStructuredText construct.
61 \pagebreak[4] % start ToC on new page
63 .. contents:: Table of Contents
64 .. section-numbering::
75 Lone subsections are converted to a section subtitle by a transform
76 activated with the ``--section-subtitles`` command line option or the
77 ``sectsubtitle-xform`` configuration value.
89 It divides the section. Transitions may also occur between sections:
104 Paragraphs contain text and may contain inline markup: *emphasis*,
105 **strong emphasis**, ``inline literals``, standalone hyperlinks
106 (http://www.python.org), external hyperlinks (Python_), internal
107 cross-references (example_), external hyperlinks with embedded URIs
108 (`Python web site <http://www.python.org>`__), `anonymous hyperlink
109 references`__ (`a second reference`__), footnote references (manually
110 numbered [1]_, anonymous auto-numbered [#]_, labeled auto-numbered
111 [#label]_, or symbolic [*]_), citation references ([CIT2002]_),
112 substitution references (|example|), and _`inline hyperlink targets`
113 (see Targets_ below for a reference back to here). Character-level
114 inline markup is also possible (although exceedingly ugly!) in *re*\
115 ``Structured``\ *Text*. Problems are indicated by |problematic| text
116 (generated by processing errors; this one is intentional). Here is a
117 reference to the doctitle_ and the subtitle_.
119 __ http://www.python.org/
120 __ http://docutils.sourceforge.net/
122 The default role for interpreted text is `Title Reference`. Here are
123 some explicit interpreted text roles: a PEP reference (:PEP:`287`); an
124 RFC reference (:RFC:`2822`); an abbreviation (:ab:`abb.`), an acronym
125 (:ac:`reST`), code (:code:`print "hello world"`); a :sub:`subscript`;
126 a :sup:`superscript` and explicit roles for :title:`Docutils`'
127 :emphasis:`standard` :strong:`inline` :literal:`markup`.
129 .. DO NOT RE-WRAP THE FOLLOWING PARAGRAPH!
131 Let's test wrapping and whitespace significance in inline literals:
132 ``This is an example of --inline-literal --text, --including some--
133 strangely--hyphenated-words. Adjust-the-width-of-your-browser-window
134 to see how the text is wrapped. -- ---- -------- Now note the
135 spacing between the words of this sentence (words
136 should be grouped in pairs).``
138 If the ``--pep-references`` option was supplied, there should be a
139 live link to PEP 258 here.
146 + Nested bullet list.
151 Paragraph 2 of item 2.
153 * Nested bullet list.
161 * This nested list should be compacted by the HTML writer.
165 .. Even if this item contains a target and a comment.
180 2. Lists that don't start at 1:
200 Definition paragraph 1.
202 Definition paragraph 2.
205 Term : classifier one : classifier two
211 :what: Field lists map field names to field bodies, like database
212 records. They are often part of an extension syntax. They are
213 an unambiguous variant of RFC 2822 fields.
217 The field marker is a colon, the field name, and a colon.
219 The field body may contain one or more body elements, indented
220 relative to the field marker.
226 This paragraph has the `credits` class set. (This is actually not
227 about credits but just for ensuring that the class attribute
228 doesn't get stripped away.)
233 For listing command-line options:
235 -a command-line option "a"
236 -b file options can have arguments
237 and long descriptions
238 --long options can be long also
239 --input=file long options can also have
243 The description can also start on the next line.
245 The description may contain multiple body elements,
246 regardless of where it starts.
248 -x, -y, -z Multiple options are an "option group".
249 -v, --verbose Commonly-seen: short & long options.
250 -1 file, --one=file, --two file
251 Multiple options with arguments.
252 /V DOS/VMS-style options too
254 There must be at least two spaces between the option and the
260 Literal blocks are indicated with a double-colon ("::") at the end of
261 the preceding paragraph (over there ``-->``). They can be indented::
264 text = 'is left as-is'
265 spaces_and_linebreaks = 'are preserved'
266 markup_processing = None
268 Or they can be quoted without indentation::
272 > Why didn't I think of that?
277 This section tests line blocks. Line blocks are body elements which
278 consist of lines and other line blocks. Nested line blocks cause
281 | This is a line block. It ends with a blank line.
282 | New lines begin with a vertical bar ("|").
283 | Line breaks and initial indent are significant, and preserved.
284 | Continuation lines are also possible. A long line that is intended
285 to wrap should begin with a space in place of the vertical bar.
286 | The left edge of a continuation line need not be aligned with
287 the left edge of the text above it.
289 | This is a second line block.
291 | Blank lines are permitted internally, but they must begin with a "|".
293 Another line block, surrounded by paragraphs:
295 | And it's no good waiting by the window
296 | It's no good waiting for the sun
297 | Please believe me, the things you dream of
298 | They don't fall in the lap of no-one
300 Take it away, Eric the Orchestra Leader!
302 | A one, two, a one two three four
304 | Half a bee, philosophically,
305 | must, *ipso facto*, half not be.
306 | But half the bee has got to be,
307 | *vis a vis* its entity. D'you see?
309 | But can a bee be said to be
310 | or not to be an entire bee,
311 | when half the bee is not a bee,
312 | due to some ancient injury?
316 A line block, like the following poem by Christian Morgenstern, can
317 also be centre-aligned:
319 .. class:: language-de align-center
323 | Zwei Trichter wandeln durch die Nacht.
324 | Durch ihres Rumpfs verengten Schacht
325 | fließt weißes Mondlicht
336 Block quotes consist of indented body elements:
338 My theory by A. Elk. Brackets Miss, brackets. This theory goes
339 as follows and begins now. All brontosauruses are thin at one
340 end, much much thicker in the middle and then thin again at the
341 far end. That is my theory, it is mine, and belongs to me and I
342 own it, and what it is too.
346 The language of a quote (like any other object) can be specified by
349 .. class:: language-fr
353 ReStructuredText est un langage de balisage léger utilisé
354 notamment dans la documentation du langage Python.
359 >>> print 'Python-specific usage examples; begun with ">>>"'
360 Python-specific usage examples; begun with ">>>"
361 >>> print '(cut and pasted from interactive Python sessions)'
362 (cut and pasted from interactive Python sessions)
367 .. [1] A footnote contains body elements, consistently indented by at
370 This is the footnote's second paragraph.
372 .. [#label] Footnotes may be numbered, either manually (as in [1]_) or
373 automatically using a "#"-prefixed label. This footnote has a
374 label so it can be referred to from multiple places, both as a
375 footnote reference ([#label]_) and as a `hyperlink reference`__.
379 .. [#] This footnote is numbered automatically and anonymously using a
382 This is the second paragraph.
384 And this is the third paragraph.
386 .. [*] Footnotes may also use symbols, specified with a "*" label.
387 Here's a reference to the next footnote: [*]_.
389 .. [*] This footnote shows the next symbol in the sequence.
391 .. [4] Here's an unreferenced footnote, with a reference to a
392 nonexistent footnote: [5]_.
397 .. [CIT2002] Citations are text-labeled footnotes. They may be
398 rendered separately and differently from footnotes.
400 Here's a reference to the above, [CIT2002]_, and a [nonexistent]_
410 This paragraph is pointed to by the explicit "example" target. A
411 reference can be found under `Inline Markup`_, above. `Inline
412 hyperlink targets`_ are also possible.
414 Section headers are implicit targets, referred to by name. See
415 Targets_, which is a subsection of `Body Elements`_.
417 Explicit external targets are interpolated into references such as
420 .. _Python: http://www.python.org/
422 Targets may be indirect and anonymous. Thus `this phrase`__ may also
423 refer to the Targets_ section.
427 Here's a `hyperlink reference without a target`_, which generates an
430 Duplicate Target Names
431 ``````````````````````
433 Duplicate names in section headers or other implicit targets will
434 generate "info" (level-1) system messages. Duplicate names in
435 explicit targets will generate "warning" (level-2) system messages.
437 Duplicate Target Names
438 ``````````````````````
440 Since there are two "Duplicate Target Names" section headers, we
441 cannot uniquely refer to either of them by name. If we try to (like
442 this: `Duplicate Target Names`_), an error is generated.
447 .. contents:: :local:
449 These are just a sample of the many reStructuredText Directives. For
451 http://docutils.sourceforge.net/docs/ref/rst/directives.html.
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`_).
463 An image directive (also clickable -- a hyperlink reference):
465 .. image:: ../../../docs/user/rst/images/title.png
466 :class: class1 class2
469 Image with multiple IDs:
474 .. image:: ../../../docs/user/rst/images/title.png
478 .. image:: ../../../docs/user/rst/images/biohazard.png
481 A left-aligned image:
483 .. image:: ../../../docs/user/rst/images/biohazard.png
486 This paragraph might flow around the image.
487 The specific behavior depends upon the style sheet and
488 the browser or rendering software used.
490 A right-aligned image:
492 .. image:: ../../../docs/user/rst/images/biohazard.png
495 This paragraph might flow around the image.
496 The specific behavior depends upon the style sheet and
497 the browser or rendering software used.
499 For inline images see `Substitution Definitions`_.
505 .. image:: ../../../docs/user/rst/images/biohazard.png
508 An image 2 em wide and 15 pixel high:
510 .. image:: ../../../docs/user/rst/images/biohazard.png
514 An image occupying 50% of the line width:
516 .. image:: ../../../docs/user/rst/images/title.png
521 .. image:: ../../../docs/user/rst/images/biohazard.png
524 A *figure* is an image with a caption and/or a legend. With page-based output
525 media, figures might float to a different position if this helps the page
528 .. figure:: ../../../docs/user/rst/images/title.png
529 :figclass: figclass1 figclass2
530 :class: class1 class2
531 :alt: reStructuredText, the markup syntax
534 Plaintext markup syntax and parser system.
536 +------------+-----------------------------------------------+
537 | re | Revised, revisited, based on 're' module. |
538 +------------+-----------------------------------------------+
539 | Structured | Structure-enhanced text, structuredtext. |
540 +------------+-----------------------------------------------+
541 | Text | Well it is, isn't it? |
542 +------------+-----------------------------------------------+
544 This paragraph is also part of the legend.
546 A left-aligned figure:
548 .. figure:: ../../../docs/user/rst/images/biohazard.png
549 :figclass: figclass1 figclass2
550 :class: class1 class2
551 :alt: reStructuredText, the markup syntax
560 The legend may consist of several paragraphs.
562 This paragraph might flow around the figure.
564 The specific behavior depends upon the style sheet and the browser or
565 rendering software used.
569 .. figure:: ../../../docs/user/rst/images/biohazard.png
577 The legend may consist of several paragraphs.
579 This paragraph might flow around the figure.
581 The specific behavior depends upon the style sheet and the browser or
582 rendering software used.
584 A right-aligned figure:
586 .. figure:: ../../../docs/user/rst/images/biohazard.png
594 The legend may consist of several paragraphs.
596 This paragraph might flow around the figure. The specific behavior depends
597 upon the style sheet and the browser or rendering software used.
603 .. Attention:: Directives at large.
607 Don't take any wooden nickels.
609 .. DANGER:: Mad scientist at work!
611 .. Error:: Does not compute.
613 .. Hint:: It's bigger than a bread box.
616 - Wash behind your ears.
617 - Clean up your room.
621 .. Note:: This is a note.
623 .. Tip:: 15% if the service is good.
625 .. WARNING:: Strong prose may provoke extreme mental exertion.
626 Reader discretion is strongly advised.
628 .. admonition:: And, by the way...
630 You can make up your own admonition too.
632 .. _Docutils: http://docutils.sourceforge.net/
634 Topics, Sidebars, and Rubrics
635 `````````````````````````````
637 *Sidebars* are like miniature, parallel documents.
639 .. sidebar:: Sidebar Title
640 :subtitle: Optional Subtitle
642 This is a sidebar. It is for text outside the flow of the main
645 .. rubric:: This is a rubric inside a sidebar
647 Sidebars often appear beside the main text with a border and a different
648 background or font color.
650 A *topic* is like a block quote with a title, or a self-contained section
653 .. topic:: Topic Title
657 A *rubric* is like an informal heading that doesn't correspond to the
658 document's structure. It is typically highlighted in red (hence the name).
660 .. rubric:: This is a rubric
662 Topics and rubrics can be used at places where a `section title`_ is not
663 allowed (e.g. inside a directive).
674 I recommend you try |Python|_.
676 .. |Python| replace:: Python, *the* best language around
684 Compound 1, paragraph 1.
686 Compound 1, paragraph 2.
688 * Compound 1, list item one.
689 * Compound 1, list item two.
691 Another compound statement:
695 Compound 2, a literal block::
699 Compound 2, this is a test.
703 Compound 3, only consisting of one paragraph.
710 This one starts with a literal block.
712 Compound 4, a paragraph.
714 Now something *really* perverted -- a nested compound block. This is
715 just to test that it works at all; the results don't have to be
720 Compound 5, block 1 (a paragraph).
724 Compound 6, block 2 in compound 5.
726 Compound 6, another paragraph.
728 Compound 5, block 3 (a paragraph).
732 Compound 7, with a table inside:
734 +--------------------+--------------------+--------------------+
735 | Left cell, first | Middle cell, | Right cell. |
736 | paragraph. | consisting of | |
737 | | exactly one | Paragraph 2. |
738 | Left cell, second | paragraph. | |
739 | paragraph. | | Paragraph 3. |
740 +--------------------+--------------------+--------------------+
742 Compound 7, a paragraph after the table.
744 Compound 7, another paragraph.
746 Parsed Literal Blocks
747 `````````````````````
751 This is a parsed literal block.
752 This line is indented. The next line is blank.
754 Inline markup is supported, e.g. *emphasis*, **strong**, ``literal
755 text``, footnotes [1]_, _`hyperlink targets`, and `references
756 <http://www.python.org/>`_.
761 Blocks of source code can be set with the `code` directive. If the code
762 language is specified, the content is parsed and tagged by the Pygments_
763 syntax highlighter and can be formatted with a style sheet. (Code parsing
764 is turned off using the ``syntax-highlight`` config setting in the test
765 conversions in order to get identical results with/without installed
766 Pygments highlighter.)
770 print 'This is Python code.'
772 The ``:number-lines:`` option (with optional start value) generates line
778 # print integers from 0 to 9:
782 For inline code snippets, there is the `code` role, which can be used
783 directly (the code will not be parsed/tagged, as the language is not known)
784 or as base for special code roles, e.g. the LaTeX code in the next
790 Docutils uses LaTeX syntax for math directives and roles:
791 :tex:`\alpha = f(x)` prints :math:`\alpha = f(x)`.
793 The ``:code:`` option of the `include` directive sets the included content
794 as a code block, here the rst file ``header_footer.txt`` with line numbers:
796 .. include:: header_footer.txt
800 .. _Pygments: http://pygments.org/
802 Substitution Definitions
803 ------------------------
805 An inline image (|example|) example:
807 .. |EXAMPLE| image:: ../../../docs/user/rst/images/biohazard.png
809 (Substitution definitions are not visible in the HTML source.)
816 .. Comments begin with two dots and a space. Anything may
817 follow, except for the syntax of footnotes, hyperlink
818 targets, directives, or substitution definitions.
820 Double-dashes -- "--" -- must be escaped somehow in HTML output.
822 Comments may contain non-ASCII characters: ä ö ü æ ø å
824 (View the HTML source to see the comment.)
829 This does not necessarily look nice, because there may be missing white space.
831 It's just there to freeze the behavior.
845 Another test with myclass set.
847 .. role:: raw-role(raw)
849 :class: myrawroleclass
851 This is the :raw-role:`fourth test` with myrawroleclass set.
855 Fifth test in HTML.<br />Line two.
859 Fifth test in LaTeX.\\Line two.
864 .. container:: custom