1 .. -*- coding: utf-8 -*-
3 =======================================
4 reStructuredText Markup Specification
5 =======================================
8 :Contact: docutils-develop@lists.sourceforge.net
11 :Copyright: This document has been placed in the public domain.
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.
20 .. _A ReStructuredText Primer: ../../user/rst/quickstart.html
21 .. _Quick reStructuredText: ../../user/rst/quickref.html
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_.
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.
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).
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.
45 `Literal blocks`_ (in which no markup processing is done) are used for
46 examples throughout this document, to illustrate the plaintext markup.
52 -----------------------
54 -----------------------
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.
64 Here are examples of `body elements`_:
66 - Paragraphs_ (and `inline markup`_)::
68 Paragraphs contain text and may contain inline markup:
69 *emphasis*, **strong emphasis**, `interpreted text`, ``inline
70 literals``, standalone hyperlinks (http://www.python.org),
71 external hyperlinks (Python_), internal cross-references
72 (example_), footnote references ([1]_), citation references
73 ([CIT2002]_), substitution references (|example|), and _`inline
76 Paragraphs are separated by blank lines and are left-aligned.
78 - Five types of lists:
82 - This is a bullet list.
84 - Bullets can be "*", "+", or "-".
86 2. `Enumerated lists`_::
88 1. This is an enumerated list.
90 2. Enumerators may be arabic numbers, letters, or roman
93 3. `Definition lists`_::
96 Definition lists associate a term with a definition.
99 The term is a one-line phrase, and the definition is one
100 or more paragraphs or body elements, indented relative to
105 :what: Field lists map field names to field bodies, like
106 database records. They are often part of an extension
109 :how: The field marker is a colon, the field name, and a
112 The field body may contain one or more body elements,
113 indented relative to the field marker.
115 5. `Option lists`_, for listing command-line options::
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
123 /V DOS/VMS-style options too
125 There must be at least two spaces between the option and the
128 - `Literal blocks`_::
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 -->)::
135 text = 'is left as-is'
136 spaces_and_linebreaks = 'are preserved'
137 markup_processing = None
141 Block quotes consist of indented body elements:
143 This theory, that is mine, is mine.
147 - `Doctest blocks`_::
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)
154 - Two syntaxes for tables_:
156 1. `Grid tables`_; complete, but complex and verbose::
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 +------------------------+-----------------------+
166 2. `Simple tables`_; easy and compact, but limited::
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 ==================== ======================
175 - `Explicit markup blocks`_ all begin with an explicit block marker,
176 two periods and a space:
180 .. [1] A footnote contains body elements, consistently
181 indented by at least 3 spaces.
185 .. [CIT2002] Just like a footnote, except the label is
188 - `Hyperlink targets`_::
190 .. _Python: http://www.python.org
194 The "_example" target above points to this paragraph.
198 .. image:: mylogo.png
200 - `Substitution definitions`_::
202 .. |symbol here| image:: symbol.png
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.
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
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.
228 Other whitespace characters (form feeds [chr(12)] and vertical tabs
229 [chr(11)]) are converted to single spaces before processing.
235 Blank lines are used to separate paragraphs and other elements.
236 Multiple successive blank lines are equivalent to a single blank line,
237 except within literal blocks (where all whitespace is preserved).
238 Blank lines may be omitted when the markup makes element separation
239 unambiguous, in conjunction with indentation. The first line of a
240 document is treated as if it is preceded by a blank line, and the last
241 line of a document is treated as if it is followed by a blank line.
247 Indentation is used to indicate -- and is only significant in
248 indicating -- block quotes, definitions (in definition list items),
249 and local nested content:
251 - list item content (multi-line contents of list items, and multiple
252 body elements within a list item, including nested lists),
253 - the content of literal blocks, and
254 - the content of explicit markup blocks.
256 Any text whose indentation is less than that of the current level
257 (i.e., unindented text or "dedents") ends the current level of
260 Since all indentation is significant, the level of indentation must be
261 consistent. For example, indentation is the sole markup indicator for
264 This is a top-level paragraph.
266 This paragraph belongs to a first-level block quote.
268 Paragraph 2 of the first-level block quote.
270 Multiple levels of indentation within a block quote will result in
271 more complex structures::
273 This is a top-level paragraph.
275 This paragraph belongs to a first-level block quote.
277 This paragraph belongs to a second-level block quote.
279 Another top-level paragraph.
281 This paragraph belongs to a second-level block quote.
283 This paragraph belongs to a first-level block quote. The
284 second-level block quote above is inside this first-level
287 When a paragraph or other construct consists of more than one line of
288 text, the lines must be left-aligned::
290 This is a paragraph. The lines of
291 this paragraph are aligned at the left.
293 This paragraph has problems. The
294 lines are not left-aligned. In addition
295 to potential misinterpretation, warning
296 and/or error messages will be generated
299 Several constructs begin with a marker, and the body of the construct
300 must be indented relative to the marker. For constructs using simple
301 markers (`bullet lists`_, `enumerated lists`_, footnotes_, citations_,
302 `hyperlink targets`_, directives_, and comments_), the level of
303 indentation of the body is determined by the position of the first
304 line of text, which begins on the same line as the marker. For
305 example, bullet list bodies must be indented by at least two columns
306 relative to the left edge of the bullet::
308 - This is the first line of a bullet list
309 item's paragraph. All lines must align
310 relative to the first line. [1]_
312 This indented paragraph is interpreted
315 Because it is not sufficiently indented,
316 this paragraph does not belong to the list
319 .. [1] Here's a footnote. The second line is aligned
320 with the beginning of the footnote label. The ".."
321 marker is what determines the indentation.
323 For constructs using complex markers (`field lists`_ and `option
324 lists`_), where the marker may contain arbitrary text, the indentation
325 of the first line *after* the marker determines the left edge of the
326 body. For example, field lists may have very long markers (containing
329 :Hello: This field has a short field name, so aligning the field
330 body with the first line is feasible.
332 :Number-of-African-swallows-required-to-carry-a-coconut: It would
333 be very difficult to align the field body with the left edge
334 of the first line. It may even be preferable not to begin the
335 body on the same line as the marker.
341 The character set universally available to plaintext documents, 7-bit
342 ASCII, is limited. No matter what characters are used for markup,
343 they will already have multiple meanings in written text. Therefore
344 markup characters *will* sometimes appear in text **without being
345 intended as markup**. Any serious markup system requires an escaping
346 mechanism to override the default meaning of the characters used for
347 the markup. In reStructuredText we use the backslash, commonly used
348 as an escaping character in other domains.
350 A backslash followed by any character (except whitespace characters)
351 escapes that character. The escaped character represents the
352 character itself, and is prevented from playing a role in any markup
353 interpretation. The backslash is removed from the output. A literal
354 backslash is represented by two backslashes in a row (the first
355 backslash "escapes" the second, preventing it being interpreted in an
358 Backslash-escaped whitespace characters are removed from the document.
359 This allows for character-level `inline markup`_.
361 There are two contexts in which backslashes have no special meaning:
362 literal blocks and inline literals. In these contexts, a single
363 backslash represents a literal backslash, without having to double up.
365 Please note that the reStructuredText specification and parser do not
366 address the issue of the representation or extraction of text input
367 (how and in what form the text actually *reaches* the parser).
368 Backslashes and other characters may serve a character-escaping
369 purpose in certain contexts and must be dealt with appropriately. For
370 example, Python uses backslashes in strings to escape certain
371 characters, but not others. The simplest solution when backslashes
372 appear in Python docstrings is to use raw docstrings::
374 r"""This is a raw docstring. Backslashes (\) are not touched."""
380 Simple reference names are single words consisting of alphanumerics
381 plus isolated (no two adjacent) internal hyphens, underscores,
382 periods, colons and plus signs; no whitespace or other characters are
383 allowed. Footnote labels (Footnotes_ & `Footnote References`_), citation
384 labels (Citations_ & `Citation References`_), `interpreted text`_ roles,
385 and some `hyperlink references`_ use the simple reference name syntax.
387 Reference names using punctuation or whose names are phrases (two or
388 more space-separated words) are called "phrase-references".
389 Phrase-references are expressed by enclosing the phrase in backquotes
390 and treating the backquoted text as a reference name::
392 Want to learn about `my favorite programming language`_?
394 .. _my favorite programming language: http://www.python.org
396 Simple reference names may also optionally use backquotes.
398 Reference names are whitespace-neutral and case-insensitive. When
399 resolving reference names internally:
401 - whitespace is normalized (one or more spaces, horizontal or vertical
402 tabs, newlines, carriage returns, or form feeds, are interpreted as
405 - case is normalized (all alphabetic characters are converted to
408 For example, the following `hyperlink references`_ are equivalent::
415 Hyperlinks_, footnotes_, and citations_ all share the same namespace
416 for reference names. The labels of citations (simple reference names)
417 and manually-numbered footnotes (numbers) are entered into the same
418 database as other hyperlink names. This means that a footnote
419 (defined as "``.. [1]``") which can be referred to by a footnote
420 reference (``[1]_``), can also be referred to by a plain hyperlink
421 reference (1_). Of course, each type of reference (hyperlink,
422 footnote, citation) may be processed and rendered differently. Some
423 care should be taken to avoid reference name conflicts.
432 Doctree element: document.
434 The top-level element of a parsed reStructuredText document is the
435 "document" element. After initial parsing, the document element is a
436 simple container for a document fragment, consisting of `body
437 elements`_, transitions_, and sections_, but lacking a document title
438 or other bibliographic elements. The code that calls the parser may
439 choose to run one or more optional post-parse transforms_,
440 rearranging the document fragment into a complete document with a
441 title and possibly other metadata elements (author, date, etc.; see
442 `Bibliographic Fields`_).
444 Specifically, there is no way to indicate a document title and
445 subtitle explicitly in reStructuredText. Instead, a lone top-level
446 section title (see Sections_ below) can be treated as the document
447 title. Similarly, a lone second-level section title immediately after
448 the "document title" can become the document subtitle. The rest of
449 the sections are then lifted up a level or two. See the `DocTitle
450 transform`_ for details.
456 Doctree elements: section, title.
458 Sections are identified through their titles, which are marked up with
459 adornment: "underlines" below the title text, or underlines and
460 matching "overlines" above the title. An underline/overline is a
461 single repeated punctuation character that begins in column 1 and
462 forms a line extending at least as far as the right edge of the title
463 text. Specifically, an underline/overline character may be any
464 non-alphanumeric printable 7-bit ASCII character [#]_. When an
465 overline is used, the length and character used must match the
466 underline. Underline-only adornment styles are distinct from
467 overline-and-underline styles that use the same character. There may
468 be any number of levels of section titles, although some output
469 formats may have limits (HTML has 6 levels).
471 .. [#] The following are all valid section title adornment
474 ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
476 Some characters are more suitable than others. The following are
479 = - ` : . ' " ~ ^ _ * + #
481 Rather than imposing a fixed number and order of section title
482 adornment styles, the order enforced will be the order as encountered.
483 The first style encountered will be an outermost title (like HTML H1),
484 the second style will be a subtitle, the third will be a subsubtitle,
487 Below are examples of section title styles::
524 When a title has both an underline and an overline, the title text may
525 be inset, as in the first two examples above. This is merely
526 aesthetic and not significant. Underline-only title text may *not* be
529 A blank line after a title is optional. All text blocks up to the
530 next title of the same or higher level are included in a section (or
533 All section title styles need not be used, nor need any specific
534 section title style be used. However, a document must be consistent
535 in its use of section titles: once a hierarchy of title styles is
536 established, sections must use that hierarchy.
538 Each section title automatically generates a hyperlink target pointing
539 to the section. The text of the hyperlink target (the "reference
540 name") is the same as that of the section title. See `Implicit
541 Hyperlink Targets`_ for a complete description.
543 Sections may contain `body elements`_, transitions_, and nested
550 Doctree element: transition.
552 Instead of subheads, extra space or a type ornament between
553 paragraphs may be used to mark text divisions or to signal
554 changes in subject or emphasis.
556 (The Chicago Manual of Style, 14th edition, section 1.80)
558 Transitions are commonly seen in novels and short fiction, as a gap
559 spanning one or more lines, with or without a type ornament such as a
560 row of asterisks. Transitions separate other body elements. A
561 transition should not begin or end a section or document, nor should
562 two transitions be immediately adjacent.
564 The syntax for a transition marker is a horizontal line of 4 or more
565 repeated punctuation characters. The syntax is the same as section
566 title underlines without title text. Transition markers require blank
567 lines before and after::
575 Unlike section title underlines, no hierarchy of transition markers is
576 enforced, nor do differences in transition markers accomplish
577 anything. It is recommended that a single consistent style be used.
579 The processing system is free to render transitions in output in any
580 way it likes. For example, horizontal rules (``<hr>``) in HTML output
581 would be an obvious choice.
590 Doctree element: paragraph.
592 Paragraphs consist of blocks of left-aligned text with no markup
593 indicating any other body element. Blank lines separate paragraphs
594 from each other and from other body elements. Paragraphs may contain
599 +------------------------------+
602 +------------------------------+
604 +------------------------------+
607 +------------------------------+
613 Doctree elements: bullet_list, list_item.
615 A text block which begins with a "*", "+", "-", "•", "‣", or "⁃",
616 followed by whitespace, is a bullet list item (a.k.a. "unordered" list
617 item). List item bodies must be left-aligned and indented relative to
618 the bullet; the text immediately after the bullet determines the
619 indentation. For example::
621 - This is the first bullet list item. The blank line above the
622 first list item is required; blank lines between list items
623 (such as below this paragraph) are optional.
625 - This is the first paragraph in the second item in the list.
627 This is the second paragraph in the second item in the list.
628 The blank line above this paragraph is required. The left edge
629 of this paragraph lines up with the paragraph above, both
630 indented relative to the bullet.
632 - This is a sublist. The bullet lines up with the left edge of
633 the text blocks above. A sublist is a new list so requires a
634 blank line above and below.
636 - This is the third item of the main list.
638 This paragraph is not part of the list.
640 Here are examples of **incorrectly** formatted bullet lists::
642 - This first line is fine.
643 A blank line is required between list items and paragraphs.
646 - The following line appears to be a new sublist, but it is not:
647 - This is a paragraph continuation, not a sublist (since there's
648 no blank line). This line is also incorrectly indented.
649 - Warnings may be issued by the implementation.
653 +------+-----------------------+
655 +------| (body elements)+ |
656 +-----------------------+
662 Doctree elements: enumerated_list, list_item.
664 Enumerated lists (a.k.a. "ordered" lists) are similar to bullet lists,
665 but use enumerators instead of bullets. An enumerator consists of an
666 enumeration sequence member and formatting, followed by whitespace.
667 The following enumeration sequences are recognized:
669 - arabic numerals: 1, 2, 3, ... (no upper limit).
670 - uppercase alphabet characters: A, B, C, ..., Z.
671 - lower-case alphabet characters: a, b, c, ..., z.
672 - uppercase Roman numerals: I, II, III, IV, ..., MMMMCMXCIX (4999).
673 - lowercase Roman numerals: i, ii, iii, iv, ..., mmmmcmxcix (4999).
675 In addition, the auto-enumerator, "#", may be used to automatically
676 enumerate a list. Auto-enumerated lists may begin with explicit
677 enumeration, which sets the sequence. Fully auto-enumerated lists use
678 arabic numerals and begin with 1. (Auto-enumerated lists are new in
681 The following formatting types are recognized:
683 - suffixed with a period: "1.", "A.", "a.", "I.", "i.".
684 - surrounded by parentheses: "(1)", "(A)", "(a)", "(I)", "(i)".
685 - suffixed with a right-parenthesis: "1)", "A)", "a)", "I)", "i)".
687 While parsing an enumerated list, a new list will be started whenever:
689 - An enumerator is encountered which does not have the same format and
690 sequence type as the current list (e.g. "1.", "(a)" produces two
693 - The enumerators are not in sequence (e.g., "1.", "3." produces two
696 It is recommended that the enumerator of the first list item be
697 ordinal-1 ("1", "A", "a", "I", or "i"). Although other start-values
698 will be recognized, they may not be supported by the output format. A
699 level-1 [info] system message will be generated for any list beginning
700 with a non-ordinal-1 enumerator.
702 Lists using Roman numerals must begin with "I"/"i" or a
703 multi-character value, such as "II" or "XV". Any other
704 single-character Roman numeral ("V", "X", "L", "C", "D", "M") will be
705 interpreted as a letter of the alphabet, not as a Roman numeral.
706 Likewise, lists using letters of the alphabet may not begin with
707 "I"/"i", since these are recognized as Roman numeral 1.
709 The second line of each enumerated list item is checked for validity.
710 This is to prevent ordinary paragraphs from being mistakenly
711 interpreted as list items, when they happen to begin with text
712 identical to enumerators. For example, this text is parsed as an
715 A. Einstein was a really
718 However, ambiguity cannot be avoided if the paragraph consists of only
719 one line. This text is parsed as an enumerated list item::
721 A. Einstein was a really smart dude.
723 If a single-line paragraph begins with text identical to an enumerator
724 ("A.", "1.", "(b)", "I)", etc.), the first character will have to be
725 escaped in order to have the line parsed as an ordinary paragraph::
727 \A. Einstein was a really smart dude.
729 Examples of nested enumerated lists::
731 1. Item 1 initial text.
739 Example syntax diagram::
741 +-------+----------------------+
742 | "1. " | list item |
743 +-------| (body elements)+ |
744 +----------------------+
750 Doctree elements: definition_list, definition_list_item, term,
751 classifier, definition.
753 Each definition list item contains a term, optional classifiers, and a
754 definition. A term is a simple one-line word or phrase. Optional
755 classifiers may follow the term on the same line, each after an inline
756 " : " (space, colon, space). A definition is a block indented
757 relative to the term, and may contain multiple paragraphs and other
758 body elements. There may be no blank line between a term line and a
759 definition block (this distinguishes definition lists from `block
760 quotes`_). Blank lines are required before the first and after the
761 last definition list item, but are optional in-between. For example::
767 Definition 2, paragraph 1.
769 Definition 2, paragraph 2.
774 term 4 : classifier one : classifier two
777 Inline markup is parsed in the term line before the classifier
778 delimiter (" : ") is recognized. The delimiter will only be
779 recognized if it appears outside of any inline markup.
781 A definition list may be used in various ways, including:
783 - As a dictionary or glossary. The term is the word itself, a
784 classifier may be used to indicate the usage of the term (noun,
785 verb, etc.), and the definition follows.
787 - To describe program variables. The term is the variable name, a
788 classifier may be used to indicate the type of the variable (string,
789 integer, etc.), and the definition describes the variable's use in
790 the program. This usage of definition lists supports the classifier
791 syntax of Grouch_, a system for describing and enforcing a Python
796 +----------------------------+
797 | term [ " : " classifier ]* |
798 +--+-------------------------+--+
801 +----------------------------+
807 Doctree elements: field_list, field, field_name, field_body.
809 Field lists are used as part of an extension syntax, such as options
810 for directives_, or database-like records meant for further
811 processing. They may also be used for two-column table-like
812 structures resembling database records (label & data pairs).
813 Applications of reStructuredText may recognize field names and
814 transform fields or field bodies in certain contexts. For examples,
815 see `Bibliographic Fields`_ below, or the "image_" and "meta_"
816 directives in `reStructuredText Directives`_.
818 Field lists are mappings from field names to field bodies, modeled on
819 RFC822_ headers. A field name may consist of any characters, but
820 colons (":") inside of field names must be escaped with a backslash.
821 Inline markup is parsed in field names. Field names are
822 case-insensitive when further processed or transformed. The field
823 name, along with a single colon prefix and suffix, together form the
824 field marker. The field marker is followed by whitespace and the
825 field body. The field body may contain multiple body elements,
826 indented relative to the field marker. The first line after the field
827 name marker determines the indentation of the field body. For
835 :Indentation: Since the field marker may be quite long, the second
836 and subsequent lines of the field body do not have to line up
837 with the first line, but they must be indented relative to the
838 field name marker, and they must line up with each other.
839 :Parameter i: integer
841 The interpretation of individual words in a multi-word field name is
842 up to the application. The application may specify a syntax for the
843 field name. For example, second and subsequent words may be treated
844 as "arguments", quoted phrases may be treated as a single argument,
845 and direct support for the "name=value" syntax may be added.
847 Standard RFC822_ headers cannot be used for this construct because
848 they are ambiguous. A word followed by a colon at the beginning of a
849 line is common in written text. However, in well-defined contexts
850 such as when a field list invariably occurs at the beginning of a
851 document (PEPs and email messages), standard RFC822 headers could be
854 Syntax diagram (simplified)::
856 +--------------------+----------------------+
857 | ":" field name ":" | field body |
858 +-------+------------+ |
860 +-----------------------------------+
866 Doctree elements: docinfo, author, authors, organization, contact,
867 version, status, date, copyright, field, topic.
869 When a field list is the first non-comment element in a document
870 (after the document title, if there is one), it may have its fields
871 transformed to document bibliographic data. This bibliographic data
872 corresponds to the front matter of a book, such as the title page and
875 Certain registered field names (listed below) are recognized and
876 transformed to the corresponding doctree elements, most becoming child
877 elements of the "docinfo" element. No ordering is required of these
878 fields, although they may be rearranged to fit the document structure,
879 as noted. Unless otherwise indicated below, each of the bibliographic
880 elements' field bodies may contain a single paragraph only. Field
881 bodies may be checked for `RCS keywords`_ and cleaned up. Any
882 unrecognized fields will remain as generic fields in the docinfo
885 The registered bibliographic field names and their corresponding
886 doctree elements are as follows:
888 - Field name "Author": author element.
889 - "Authors": authors.
890 - "Organization": organization.
891 - "Contact": contact.
892 - "Address": address.
893 - "Version": version.
896 - "Copyright": copyright.
897 - "Dedication": topic.
900 The "Authors" field may contain either: a single paragraph consisting
901 of a list of authors, separated by ";" or ","; or a bullet list whose
902 elements each contain a single paragraph per author. ";" is checked
903 first, so "Doe, Jane; Doe, John" will work. In some languages
904 (e.g. Swedish), there is no singular/plural distinction between
905 "Author" and "Authors", so only an "Authors" field is provided, and a
906 single name is interpreted as an "Author". If a single name contains
907 a comma, end it with a semicolon to disambiguate: ":Authors: Doe,
910 The "Address" field is for a multi-line surface mailing address.
911 Newlines and whitespace will be preserved.
913 The "Dedication" and "Abstract" fields may contain arbitrary body
914 elements. Only one of each is allowed. They become topic elements
915 with "Dedication" or "Abstract" titles (or language equivalents)
916 immediately following the docinfo element.
918 This field-name-to-element mapping can be replaced for other
919 languages. See the `DocInfo transform`_ implementation documentation
922 Unregistered/generic fields may contain one or more paragraphs or
923 arbitrary body elements.
929 `Bibliographic fields`_ recognized by the parser are normally checked
930 for RCS [#]_ keywords and cleaned up [#]_. RCS keywords may be
931 entered into source files as "$keyword$", and once stored under RCS or
932 CVS [#]_, they are expanded to "$keyword: expansion text $". For
933 example, a "Status" field will be transformed to a "status" element::
935 :Status: $keyword: expansion text $
937 .. [#] Revision Control System.
938 .. [#] RCS keyword processing can be turned off (unimplemented).
939 .. [#] Concurrent Versions System. CVS uses the same keywords as RCS.
941 Processed, the "status" element's text will become simply "expansion
942 text". The dollar sign delimiters and leading RCS keyword name are
945 The RCS keyword processing only kicks in when the field list is in
946 bibliographic context (first non-comment construct in the document,
947 after a document title if there is one).
953 Doctree elements: option_list, option_list_item, option_group, option,
954 option_string, option_argument, description.
956 Option lists are two-column lists of command-line options and
957 descriptions, documenting a program's options. For example::
960 -b Output both (this description is
962 -c arg Output just arg.
963 --long Output all day long.
965 -p This option has two paragraphs in the description.
968 This is the second. Blank lines may be omitted between
969 options (as above) or left in (as here and below).
971 --very-long-option A VMS-style option. Note the adjustment for
972 the required two spaces.
974 --an-even-longer-option
975 The description can also start on the next line.
977 -2, --two This option has two variants.
979 -f FILE, --file=FILE These two options are synonyms; both have
982 /V A VMS/DOS-style option.
984 There are several types of options recognized by reStructuredText:
986 - Short POSIX options consist of one dash and an option letter.
987 - Long POSIX options consist of two dashes and an option word; some
988 systems use a single dash.
989 - Old GNU-style "plus" options consist of one plus and an option
990 letter ("plus" options are deprecated now, their use discouraged).
991 - DOS/VMS options consist of a slash and an option letter or word.
993 Please note that both POSIX-style and DOS/VMS-style options may be
994 used by DOS or Windows software. These and other variations are
995 sometimes used mixed together. The names above have been chosen for
998 The syntax for short and long POSIX options is based on the syntax
999 supported by Python's getopt.py_ module, which implements an option
1000 parser similar to the `GNU libc getopt_long()`_ function but with some
1001 restrictions. There are many variant option systems, and
1002 reStructuredText option lists do not support all of them.
1004 Although long POSIX and DOS/VMS option words may be allowed to be
1005 truncated by the operating system or the application when used on the
1006 command line, reStructuredText option lists do not show or support
1007 this with any special syntax. The complete option word should be
1008 given, supported by notes about truncation if and when applicable.
1010 Options may be followed by an argument placeholder, whose role and
1011 syntax should be explained in the description text. Either a space or
1012 an equals sign may be used as a delimiter between options and option
1013 argument placeholders; short options ("-" or "+" prefix only) may omit
1014 the delimiter. Option arguments may take one of two forms:
1016 - Begins with a letter (``[a-zA-Z]``) and subsequently consists of
1017 letters, numbers, underscores and hyphens (``[a-zA-Z0-9_-]``).
1018 - Begins with an open-angle-bracket (``<``) and ends with a
1019 close-angle-bracket (``>``); any characters except angle brackets
1020 are allowed internally.
1022 Multiple option "synonyms" may be listed, sharing a single
1023 description. They must be separated by comma-space.
1025 There must be at least two spaces between the option(s) and the
1026 description. The description may contain multiple body elements. The
1027 first line after the option marker determines the indentation of the
1028 description. As with other types of lists, blank lines are required
1029 before the first option list item and after the last, but are optional
1030 between option entries.
1032 Syntax diagram (simplified)::
1034 +----------------------------+-------------+
1035 | option [" " argument] " " | description |
1036 +-------+--------------------+ |
1037 | (body elements)+ |
1038 +----------------------------------+
1044 Doctree element: literal_block.
1046 A paragraph consisting of two colons ("::") signifies that the
1047 following text block(s) comprise a literal block. The literal block
1048 must either be indented or quoted (see below). No markup processing
1049 is done within a literal block. It is left as-is, and is typically
1050 rendered in a monospaced typeface::
1052 This is a typical paragraph. An indented literal block follows.
1056 for a in [5,4,3,2,1]: # this is program code, shown as-is
1059 # a literal block continues until the indentation ends
1061 This text has returned to the indentation of the first paragraph,
1062 is outside of the literal block, and is therefore treated as an
1065 The paragraph containing only "::" will be completely removed from the
1066 output; no empty paragraph will remain.
1068 As a convenience, the "::" is recognized at the end of any paragraph.
1069 If immediately preceded by whitespace, both colons will be removed
1070 from the output (this is the "partially minimized" form). When text
1071 immediately precedes the "::", *one* colon will be removed from the
1072 output, leaving only one colon visible (i.e., "::" will be replaced by
1073 ":"; this is the "fully minimized" form).
1075 In other words, these are all equivalent (please pay attention to the
1076 colons after "Paragraph"):
1086 2. Partially minimized form::
1092 3. Fully minimized form::
1098 All whitespace (including line breaks, but excluding minimum
1099 indentation for indented literal blocks) is preserved. Blank lines
1100 are required before and after a literal block, but these blank lines
1101 are not included as part of the literal block.
1104 Indented Literal Blocks
1105 ```````````````````````
1107 Indented literal blocks are indicated by indentation relative to the
1108 surrounding text (leading whitespace on each line). The minimum
1109 indentation will be removed from each line of an indented literal
1110 block. The literal block need not be contiguous; blank lines are
1111 allowed between sections of indented text. The literal block ends
1112 with the end of the indentation.
1116 +------------------------------+
1118 | (ends with "::") |
1119 +------------------------------+
1120 +---------------------------+
1121 | indented literal block |
1122 +---------------------------+
1125 Quoted Literal Blocks
1126 `````````````````````
1128 Quoted literal blocks are unindented contiguous blocks of text where
1129 each line begins with the same non-alphanumeric printable 7-bit ASCII
1130 character [#]_. A blank line ends a quoted literal block. The
1131 quoting characters are preserved in the processed document.
1134 The following are all valid quoting characters::
1136 ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
1138 Note that these are the same characters as are valid for title
1139 adornment of sections_.
1141 Possible uses include literate programming in Haskell and email
1148 > Why didn't I think of that?
1154 +------------------------------+
1156 | (ends with "::") |
1157 +------------------------------+
1158 +------------------------------+
1159 | ">" per-line-quoted |
1160 | ">" contiguous literal block |
1161 +------------------------------+
1167 Doctree elements: line_block, line. (New in Docutils 0.3.5.)
1169 Line blocks are useful for address blocks, verse (poetry, song
1170 lyrics), and unadorned lists, where the structure of lines is
1171 significant. Line blocks are groups of lines beginning with vertical
1172 bar ("|") prefixes. Each vertical bar prefix indicates a new line, so
1173 line breaks are preserved. Initial indents are also significant,
1174 resulting in a nested structure. Inline markup is supported.
1175 Continuation lines are wrapped portions of long lines; they begin with
1176 a space in place of the vertical bar. The left edge of a continuation
1177 line must be indented, but need not be aligned with the left edge of
1178 the text above it. A line block ends with a blank line.
1180 This example illustrates continuation lines::
1182 | Lend us a couple of bob till Thursday.
1183 | I'm absolutely skint.
1184 | But I'm expecting a postal order and I can pay you back
1185 as soon as it comes.
1188 This example illustrates the nesting of line blocks, indicated by the
1189 initial indentation of new lines::
1191 Take it away, Eric the Orchestra Leader!
1193 | A one, two, a one two three four
1195 | Half a bee, philosophically,
1196 | must, *ipso facto*, half not be.
1197 | But half the bee has got to be,
1198 | *vis a vis* its entity. D'you see?
1200 | But can a bee be said to be
1201 | or not to be an entire bee,
1202 | when half the bee is not a bee,
1203 | due to some ancient injury?
1209 +------+-----------------------+
1211 +------| continuation line |
1212 +-----------------------+
1218 Doctree element: block_quote, attribution.
1220 A text block that is indented relative to the preceding text, without
1221 preceding markup indicating it to be a literal block or other content,
1222 is a block quote. All markup processing (for body elements and inline
1223 markup) continues within the block quote::
1225 This is an ordinary paragraph, introducing a block quote.
1227 "It is my business to know things. That is my trade."
1231 A block quote may end with an attribution: a text block beginning with
1232 "--", "---", or a true em-dash, flush left within the block quote. If
1233 the attribution consists of multiple lines, the left edges of the
1234 second and subsequent lines must align.
1236 Multiple block quotes may occur consecutively if terminated with
1239 Unindented paragraph.
1247 `Empty comments`_ may be used to explicitly terminate preceding
1248 constructs that would otherwise consume a block quote::
1256 Empty comments may also be used to separate block quotes::
1264 Blank lines are required before and after a block quote, but these
1265 blank lines are not included as part of the block quote.
1269 +------------------------------+
1270 | (current level of |
1272 +------------------------------+
1273 +---------------------------+
1275 | (body elements)+ |
1277 | -- attribution text |
1279 +---------------------------+
1285 Doctree element: doctest_block.
1287 Doctest blocks are interactive Python sessions cut-and-pasted into
1288 docstrings. They are meant to illustrate usage by example, and
1289 provide an elegant and powerful testing environment via the `doctest
1290 module`_ in the Python standard library.
1292 Doctest blocks are text blocks which begin with ``">>> "``, the Python
1293 interactive interpreter main prompt, and end with a blank line.
1294 Doctest blocks are treated as a special case of literal blocks,
1295 without requiring the literal block syntax. If both are present, the
1296 literal block syntax takes priority over Doctest block syntax::
1298 This is an ordinary paragraph.
1300 >>> print 'this is a Doctest block'
1301 this is a Doctest block
1303 The following is a literal block::
1305 >>> This is not recognized as a doctest block by
1306 reStructuredText. It *will* be recognized by the doctest
1309 Indentation is not required for doctest blocks.
1315 Doctree elements: table, tgroup, colspec, thead, tbody, row, entry.
1317 ReStructuredText provides two syntaxes for delineating table cells:
1318 `Grid Tables`_ and `Simple Tables`_.
1320 As with other body elements, blank lines are required before and after
1321 tables. Tables' left edges should align with the left edge of
1322 preceding text blocks; if indented, the table is considered to be part
1325 Once isolated, each table cell is treated as a miniature document; the
1326 top and bottom cell boundaries act as delimiting blank lines. Each
1327 cell contains zero or more body elements. Cell contents may include
1328 left and/or right margins, which are removed before processing.
1334 Grid tables provide a complete table representation via grid-like
1335 "ASCII art". Grid tables allow arbitrary cell contents (body
1336 elements), and both row and column spans. However, grid tables can be
1337 cumbersome to produce, especially for simple data sets. The `Emacs
1338 table mode`_ is a tool that allows easy editing of grid tables, in
1339 Emacs. See `Simple Tables`_ for a simpler (but limited)
1342 Grid tables are described with a visual grid made up of the characters
1343 "-", "=", "|", and "+". The hyphen ("-") is used for horizontal lines
1344 (row separators). The equals sign ("=") may be used to separate
1345 optional header rows from the table body (not supported by the `Emacs
1346 table mode`_). The vertical bar ("|") is used for vertical lines
1347 (column separators). The plus sign ("+") is used for intersections of
1348 horizontal and vertical lines. Example::
1350 +------------------------+------------+----------+----------+
1351 | Header row, column 1 | Header 2 | Header 3 | Header 4 |
1352 | (header rows optional) | | | |
1353 +========================+============+==========+==========+
1354 | body row 1, column 1 | column 2 | column 3 | column 4 |
1355 +------------------------+------------+----------+----------+
1356 | body row 2 | Cells may span columns. |
1357 +------------------------+------------+---------------------+
1358 | body row 3 | Cells may | - Table cells |
1359 +------------------------+ span rows. | - contain |
1360 | body row 4 | | - body elements. |
1361 +------------------------+------------+---------------------+
1363 Some care must be taken with grid tables to avoid undesired
1364 interactions with cell text in rare cases. For example, the following
1365 table contains a cell in row 2 spanning from column 2 to column 4::
1367 +--------------+----------+-----------+-----------+
1368 | row 1, col 1 | column 2 | column 3 | column 4 |
1369 +--------------+----------+-----------+-----------+
1371 +--------------+----------+-----------+-----------+
1373 +--------------+----------+-----------+-----------+
1375 If a vertical bar is used in the text of that cell, it could have
1376 unintended effects if accidentally aligned with column boundaries::
1378 +--------------+----------+-----------+-----------+
1379 | row 1, col 1 | column 2 | column 3 | column 4 |
1380 +--------------+----------+-----------+-----------+
1381 | row 2 | Use the command ``ls | more``. |
1382 +--------------+----------+-----------+-----------+
1384 +--------------+----------+-----------+-----------+
1386 Several solutions are possible. All that is needed is to break the
1387 continuity of the cell outline rectangle. One possibility is to shift
1388 the text by adding an extra space before::
1390 +--------------+----------+-----------+-----------+
1391 | row 1, col 1 | column 2 | column 3 | column 4 |
1392 +--------------+----------+-----------+-----------+
1393 | row 2 | Use the command ``ls | more``. |
1394 +--------------+----------+-----------+-----------+
1396 +--------------+----------+-----------+-----------+
1398 Another possibility is to add an extra line to row 2::
1400 +--------------+----------+-----------+-----------+
1401 | row 1, col 1 | column 2 | column 3 | column 4 |
1402 +--------------+----------+-----------+-----------+
1403 | row 2 | Use the command ``ls | more``. |
1405 +--------------+----------+-----------+-----------+
1407 +--------------+----------+-----------+-----------+
1413 Simple tables provide a compact and easy to type but limited
1414 row-oriented table representation for simple data sets. Cell contents
1415 are typically single paragraphs, although arbitrary body elements may
1416 be represented in most cells. Simple tables allow multi-line rows (in
1417 all but the first column) and column spans, but not row spans. See
1418 `Grid Tables`_ above for a complete table representation.
1420 Simple tables are described with horizontal borders made up of "=" and
1421 "-" characters. The equals sign ("=") is used for top and bottom
1422 table borders, and to separate optional header rows from the table
1423 body. The hyphen ("-") is used to indicate column spans in a single
1424 row by underlining the joined columns, and may optionally be used to
1425 explicitly and/or visually separate rows.
1427 A simple table begins with a top border of equals signs with one or
1428 more spaces at each column boundary (two or more spaces recommended).
1429 Regardless of spans, the top border *must* fully describe all table
1430 columns. There must be at least two columns in the table (to
1431 differentiate it from section headers). The top border may be
1432 followed by header rows, and the last of the optional header rows is
1433 underlined with '=', again with spaces at column boundaries. There
1434 may not be a blank line below the header row separator; it would be
1435 interpreted as the bottom border of the table. The bottom boundary of
1436 the table consists of '=' underlines, also with spaces at column
1437 boundaries. For example, here is a truth table, a three-column table
1438 with one header row and four body rows::
1449 Underlines of '-' may be used to indicate column spans by "filling in"
1450 column margins to join adjacent columns. Column span underlines must
1451 be complete (they must cover all columns) and align with established
1452 column boundaries. Text lines containing column span underlines may
1453 not contain any other text. A column span underline applies only to
1454 one row immediately above it. For example, here is a table with a
1455 column span in the header::
1468 Each line of text must contain spaces at column boundaries, except
1469 where cells have been joined by column spans. Each line of text
1470 starts a new row, except when there is a blank cell in the first
1471 column. In that case, that line of text is parsed as a continuation
1472 line. For this reason, cells in the first column of new rows (*not*
1473 continuation lines) *must* contain some text; blank cells would lead
1474 to a misinterpretation (but see the tip below). Also, this mechanism
1475 limits cells in the first column to only one line of text. Use `grid
1476 tables`_ if this limitation is unacceptable.
1480 To start a new row in a simple table without text in the first
1481 column in the processed output, use one of these:
1483 * an empty comment (".."), which may be omitted from the processed
1484 output (see Comments_ below)
1486 * a backslash escape ("``\``") followed by a space (see `Escaping
1489 Underlines of '-' may also be used to visually separate rows, even if
1490 there are no column spans. This is especially useful in long tables,
1491 where rows are many lines long.
1493 Blank lines are permitted within simple tables. Their interpretation
1494 depends on the context. Blank lines *between* rows are ignored.
1495 Blank lines *within* multi-line rows may separate paragraphs or other
1496 body elements within cells.
1498 The rightmost column is unbounded; text may continue past the edge of
1499 the table (as indicated by the table borders). However, it is
1500 recommended that borders be made long enough to contain the entire
1503 The following example illustrates continuation lines (row 2 consists
1504 of two lines of text, and four lines for row 3), a blank line
1505 separating paragraphs (row 3, column 2), text extending past the right
1506 edge of the table, and a new row which will have no text in the first
1507 column in the processed output (row 4)::
1512 1 Second column of row 1.
1513 2 Second column of row 2.
1514 Second line of paragraph.
1515 3 - Second column of row 3.
1517 - Second item in bullet
1518 list (row 3, column 2).
1519 \ Row 4; column 1 will be empty.
1523 Explicit Markup Blocks
1524 ----------------------
1526 An explicit markup block is a text block:
1528 - whose first line begins with ".." followed by whitespace (the
1529 "explicit markup start"),
1530 - whose second and subsequent lines (if any) are indented relative to
1532 - which ends before an unindented line.
1534 Explicit markup blocks are analogous to bullet list items, with ".."
1535 as the bullet. The text on the lines immediately after the explicit
1536 markup start determines the indentation of the block body. The
1537 maximum common indentation is always removed from the second and
1538 subsequent lines of the block body. Therefore if the first construct
1539 fits in one line, and the indentation of the first and second
1540 constructs should differ, the first construct should not begin on the
1541 same line as the explicit markup start.
1543 Blank lines are required between explicit markup blocks and other
1544 elements, but are optional between explicit markup blocks where
1547 The explicit markup syntax is used for footnotes, citations, hyperlink
1548 targets, directives, substitution definitions, and comments.
1554 Doctree elements: footnote_, label_.
1556 .. _footnote: ../doctree.html#footnote
1557 .. _label: ../doctree.html#label
1559 Each footnote consists of an explicit markup start (".. "), a left
1560 square bracket, the footnote label, a right square bracket, and
1561 whitespace, followed by indented body elements. A footnote label can
1564 - a whole decimal number consisting of one or more digits,
1566 - a single "#" (denoting `auto-numbered footnotes`_),
1568 - a "#" followed by a simple reference name (an `autonumber label`_),
1571 - a single "*" (denoting `auto-symbol footnotes`_).
1573 The footnote content (body elements) must be consistently indented (by
1574 at least 3 spaces) and left-aligned. The first body element within a
1575 footnote may often begin on the same line as the footnote label.
1576 However, if the first element fits on one line and the indentation of
1577 the remaining elements differ, the first element must begin on the
1578 line after the footnote label. Otherwise, the difference in
1579 indentation will not be detected.
1581 Footnotes may occur anywhere in the document, not only at the end.
1582 Where and how they appear in the processed output depends on the
1585 Here is a manually numbered footnote::
1587 .. [1] Body elements go here.
1589 Each footnote automatically generates a hyperlink target pointing to
1590 itself. The text of the hyperlink target name is the same as that of
1591 the footnote label. `Auto-numbered footnotes`_ generate a number as
1592 their footnote label and reference name. See `Implicit Hyperlink
1593 Targets`_ for a complete description of the mechanism.
1597 +-------+-------------------------+
1598 | ".. " | "[" label "]" footnote |
1600 | (body elements)+ |
1601 +-------------------------+
1604 Auto-Numbered Footnotes
1605 .......................
1607 A number sign ("#") may be used as the first character of a footnote
1608 label to request automatic numbering of the footnote or footnote
1611 The first footnote to request automatic numbering is assigned the
1612 label "1", the second is assigned the label "2", and so on (assuming
1613 there are no manually numbered footnotes present; see `Mixed Manual
1614 and Auto-Numbered Footnotes`_ below). A footnote which has
1615 automatically received a label "1" generates an implicit hyperlink
1616 target with name "1", just as if the label was explicitly specified.
1618 .. _autonumber label: `autonumber labels`_
1620 A footnote may specify a label explicitly while at the same time
1621 requesting automatic numbering: ``[#label]``. These labels are called
1622 _`autonumber labels`. Autonumber labels do two things:
1624 - On the footnote itself, they generate a hyperlink target whose name
1625 is the autonumber label (doesn't include the "#").
1627 - They allow an automatically numbered footnote to be referred to more
1628 than once, as a footnote reference or hyperlink reference. For
1631 If [#note]_ is the first footnote reference, it will show up as
1632 "[1]". We can refer to it again as [#note]_ and again see
1633 "[1]". We can also refer to it as note_ (an ordinary internal
1634 hyperlink reference).
1636 .. [#note] This is the footnote labeled "note".
1638 The numbering is determined by the order of the footnotes, not by the
1639 order of the references. For footnote references without autonumber
1640 labels (``[#]_``), the footnotes and footnote references must be in
1641 the same relative order but need not alternate in lock-step. For
1644 [#]_ is a reference to footnote 1, and [#]_ is a reference to
1647 .. [#] This is footnote 1.
1648 .. [#] This is footnote 2.
1649 .. [#] This is footnote 3.
1651 [#]_ is a reference to footnote 3.
1653 Special care must be taken if footnotes themselves contain
1654 auto-numbered footnote references, or if multiple references are made
1655 in close proximity. Footnotes and references are noted in the order
1656 they are encountered in the document, which is not necessarily the
1657 same as the order in which a person would read them.
1660 Auto-Symbol Footnotes
1661 .....................
1663 An asterisk ("*") may be used for footnote labels to request automatic
1664 symbol generation for footnotes and footnote references. The asterisk
1665 may be the only character in the label. For example::
1667 Here is a symbolic footnote reference: [*]_.
1669 .. [*] This is the footnote.
1671 A transform will insert symbols as labels into corresponding footnotes
1672 and footnote references. The number of references must be equal to
1673 the number of footnotes. One symbol footnote cannot have multiple
1676 The standard Docutils system uses the following symbols for footnote
1679 - asterisk/star ("*")
1680 - dagger (HTML character entity "†", Unicode U+02020)
1681 - double dagger ("‡"/U+02021)
1682 - section mark ("§"/U+000A7)
1683 - pilcrow or paragraph mark ("¶"/U+000B6)
1685 - spade suit ("♠"/U+02660)
1686 - heart suit ("♥"/U+02665)
1687 - diamond suit ("♦"/U+02666)
1688 - club suit ("♣"/U+02663)
1690 .. [#] This list was inspired by the list of symbols for "Note
1691 Reference Marks" in The Chicago Manual of Style, 14th edition,
1692 section 12.51. "Parallels" ("||") were given in CMoS instead of
1693 the pilcrow. The last four symbols (the card suits) were added
1696 If more than ten symbols are required, the same sequence will be
1697 reused, doubled and then tripled, and so on ("**" etc.).
1699 .. Note:: When using auto-symbol footnotes, the choice of output
1700 encoding is important. Many of the symbols used are not encodable
1701 in certain common text encodings such as Latin-1 (ISO 8859-1). The
1702 use of UTF-8 for the output encoding is recommended. An
1703 alternative for HTML and XML output is to use the
1704 "xmlcharrefreplace" `output encoding error handler`__.
1706 __ ../../user/config.html#output-encoding-error-handler
1709 Mixed Manual and Auto-Numbered Footnotes
1710 ........................................
1712 Manual and automatic footnote numbering may both be used within a
1713 single document, although the results may not be expected. Manual
1714 numbering takes priority. Only unused footnote numbers are assigned
1715 to auto-numbered footnotes. The following example should be
1718 [2]_ will be "2" (manually numbered),
1719 [#]_ will be "3" (anonymous auto-numbered), and
1720 [#label]_ will be "1" (labeled auto-numbered).
1722 .. [2] This footnote is labeled manually, so its number is fixed.
1724 .. [#label] This autonumber-labeled footnote will be labeled "1".
1725 It is the first auto-numbered footnote and no other footnote
1726 with label "1" exists. The order of the footnotes is used to
1727 determine numbering, not the order of the footnote references.
1729 .. [#] This footnote will be labeled "3". It is the second
1730 auto-numbered footnote, but footnote label "2" is already used.
1736 Citations are identical to footnotes except that they use only
1737 non-numeric labels such as ``[note]`` or ``[GVR2001]``. Citation
1738 labels are simple `reference names`_ (case-insensitive single words
1739 consisting of alphanumerics plus internal hyphens, underscores, and
1740 periods; no whitespace). Citations may be rendered separately and
1741 differently from footnotes. For example::
1743 Here is a citation reference: [CIT2002]_.
1745 .. [CIT2002] This is the citation. It's just like a footnote,
1746 except the label is textual.
1754 Doctree element: target_.
1756 .. _target: ../doctree.html#target
1758 These are also called _`explicit hyperlink targets`, to differentiate
1759 them from `implicit hyperlink targets`_ defined below.
1761 Hyperlink targets identify a location within or outside of a document,
1762 which may be linked to by `hyperlink references`_.
1764 Hyperlink targets may be named or anonymous. Named hyperlink targets
1765 consist of an explicit markup start (".. "), an underscore, the
1766 reference name (no trailing underscore), a colon, whitespace, and a
1769 .. _hyperlink-name: link-block
1771 Reference names are whitespace-neutral and case-insensitive. See
1772 `Reference Names`_ for details and examples.
1774 Anonymous hyperlink targets consist of an explicit markup start
1775 (".. "), two underscores, a colon, whitespace, and a link block; there
1776 is no reference name::
1778 .. __: anonymous-hyperlink-target-link-block
1780 An alternate syntax for anonymous hyperlinks consists of two
1781 underscores, a space, and a link block::
1783 __ anonymous-hyperlink-target-link-block
1785 See `Anonymous Hyperlinks`_ below.
1787 There are three types of hyperlink targets: internal, external, and
1790 1. _`Internal hyperlink targets` have empty link blocks. They provide
1791 an end point allowing a hyperlink to connect one place to another
1792 within a document. An internal hyperlink target points to the
1793 element following the target. [#]_ For example::
1795 Clicking on this internal hyperlink will take us to the target_
1800 The hyperlink target above points to this paragraph.
1802 Internal hyperlink targets may be "chained". Multiple adjacent
1803 internal hyperlink targets all point to the same element::
1808 The targets "target1" and "target2" are synonyms; they both
1809 point to this paragraph.
1811 If the element "pointed to" is an external hyperlink target (with a
1812 URI in its link block; see #2 below) the URI from the external
1813 hyperlink target is propagated to the internal hyperlink targets;
1814 they will all "point to" the same URI. There is no need to
1815 duplicate a URI. For example, all three of the following hyperlink
1816 targets refer to the same URI::
1818 .. _Python DOC-SIG mailing list archive:
1820 .. _Doc-SIG: http://mail.python.org/pipermail/doc-sig/
1822 An inline form of internal hyperlink target is available; see
1823 `Inline Internal Targets`_.
1825 .. [#] Works also, if the internal hyperlink target is "nested" at the
1826 end of an indented text block. This behaviour allows setting targets
1827 to individual list items (except the first, as a preceding internal
1828 target applies to the list as a whole)::
1834 * second item, with hyperlink target.
1837 2. _`External hyperlink targets` have an absolute or relative URI or
1838 email address in their link blocks. For example, take the
1841 See the Python_ home page for info.
1843 `Write to me`_ with your questions.
1845 .. _Python: http://www.python.org
1846 .. _Write to me: jdoe@example.com
1848 After processing into HTML, the hyperlinks might be expressed as::
1850 See the <a href="http://www.python.org">Python</a> home page
1853 <a href="mailto:jdoe@example.com">Write to me</a> with your
1856 An external hyperlink's URI may begin on the same line as the
1857 explicit markup start and target name, or it may begin in an
1858 indented text block immediately following, with no intervening
1859 blank lines. If there are multiple lines in the link block, they
1860 are concatenated. Any whitespace is removed (whitespace is
1861 permitted to allow for line wrapping). The following external
1862 hyperlink targets are equivalent::
1864 .. _one-liner: http://docutils.sourceforge.net/rst.html
1866 .. _starts-on-this-line: http://
1867 docutils.sourceforge.net/rst.html
1871 sourceforge.net/rst.html
1873 If an external hyperlink target's URI contains an underscore as its
1874 last character, it must be escaped to avoid being mistaken for an
1875 indirect hyperlink target::
1877 This link_ refers to a file called ``underscore_``.
1879 .. _link: underscore\_
1881 It is possible (although not generally recommended) to include URIs
1882 directly within hyperlink references. See `Embedded URIs and Aliases`_
1885 3. _`Indirect hyperlink targets` have a hyperlink reference in their
1886 link blocks. In the following example, target "one" indirectly
1887 references whatever target "two" references, and target "two"
1888 references target "three", an internal hyperlink target. In
1889 effect, all three reference the same thing::
1895 Just as with `hyperlink references`_ anywhere else in a document,
1896 if a phrase-reference is used in the link block it must be enclosed
1897 in backquotes. As with `external hyperlink targets`_, the link
1898 block of an indirect hyperlink target may begin on the same line as
1899 the explicit markup start or the next line. It may also be split
1900 over multiple lines, in which case the lines are joined with
1901 whitespace before being normalized.
1903 For example, the following indirect hyperlink targets are
1906 .. _one-liner: `A HYPERLINK`_
1912 It is possible to include an alias directly within hyperlink
1913 references. See `Embedded URIs and Aliases`_ below.
1915 If the reference name contains any colons, either:
1917 - the phrase must be enclosed in backquotes::
1919 .. _`FAQTS: Computers: Programming: Languages: Python`:
1920 http://python.faqts.com/
1922 - or the colon(s) must be backslash-escaped in the link target::
1924 .. _Chapter One\: "Tadpole Days":
1926 It's not easy being green...
1928 See `Implicit Hyperlink Targets`_ below for the resolution of
1929 duplicate reference names.
1933 +-------+----------------------+
1934 | ".. " | "_" name ":" link |
1937 +----------------------+
1940 Anonymous Hyperlinks
1941 ....................
1943 The `World Wide Web Consortium`_ recommends in its `HTML Techniques
1944 for Web Content Accessibility Guidelines`_ that authors should
1945 "clearly identify the target of each link." Hyperlink references
1946 should be as verbose as possible, but duplicating a verbose hyperlink
1947 name in the target is onerous and error-prone. Anonymous hyperlinks
1948 are designed to allow convenient verbose hyperlink references, and are
1949 analogous to `Auto-Numbered Footnotes`_. They are particularly useful
1950 in short or one-off documents. However, this feature is easily abused
1951 and can result in unreadable plaintext and/or unmaintainable
1952 documents. Caution is advised.
1954 Anonymous `hyperlink references`_ are specified with two underscores
1957 See `the web site of my favorite programming language`__.
1959 Anonymous targets begin with ".. __:"; no reference name is required
1962 .. __: http://www.python.org
1964 As a convenient alternative, anonymous targets may begin with "__"
1967 __ http://www.python.org
1969 The reference name of the reference is not used to match the reference
1970 to its target. Instead, the order of anonymous hyperlink references
1971 and targets within the document is significant: the first anonymous
1972 reference will link to the first anonymous target. The number of
1973 anonymous hyperlink references in a document must match the number of
1974 anonymous targets. For readability, it is recommended that targets be
1975 kept close to references. Take care when editing text containing
1976 anonymous references; adding, removing, and rearranging references
1977 require attention to the order of corresponding targets.
1983 Doctree elements: depend on the directive.
1985 Directives are an extension mechanism for reStructuredText, a way of
1986 adding support for new constructs without adding new primary syntax
1987 (directives may support additional syntax locally). All standard
1988 directives (those implemented and registered in the reference
1989 reStructuredText parser) are described in the `reStructuredText
1990 Directives`_ document, and are always available. Any other directives
1991 are domain-specific, and may require special action to make them
1992 available when processing the document.
1994 For example, here's how an image_ may be placed::
1996 .. image:: mylogo.jpeg
1998 A figure_ (a graphic with a caption) may placed like this::
2000 .. figure:: larch.png
2004 An admonition_ (note, caution, etc.) contains other body elements::
2006 .. note:: This is a paragraph
2008 - Here is a bullet list.
2010 Directives are indicated by an explicit markup start (".. ") followed
2011 by the directive type, two colons, and whitespace (together called the
2012 "directive marker"). Directive types are case-insensitive single
2013 words (alphanumerics plus isolated internal hyphens, underscores,
2014 plus signs, colons, and periods; no whitespace). Two colons are used
2015 after the directive type for these reasons:
2017 - Two colons are distinctive, and unlikely to be used in common text.
2019 - Two colons avoids clashes with common comment text like::
2021 .. Danger: modify at your own risk!
2023 - If an implementation of reStructuredText does not recognize a
2024 directive (i.e., the directive-handler is not installed), a level-3
2025 (error) system message is generated, and the entire directive block
2026 (including the directive itself) will be included as a literal
2027 block. Thus "::" is a natural choice.
2029 The directive block is consists of any text on the first line of the
2030 directive after the directive marker, and any subsequent indented
2031 text. The interpretation of the directive block is up to the
2032 directive code. There are three logical parts to the directive block:
2034 1. Directive arguments.
2035 2. Directive options.
2036 3. Directive content.
2038 Individual directives can employ any combination of these parts.
2039 Directive arguments can be filesystem paths, URLs, title text, etc.
2040 Directive options are indicated using `field lists`_; the field names
2041 and contents are directive-specific. Arguments and options must form
2042 a contiguous block beginning on the first or second line of the
2043 directive; a blank line indicates the beginning of the directive
2044 content block. If either arguments and/or options are employed by the
2045 directive, a blank line must separate them from the directive content.
2046 The "figure" directive employs all three parts::
2048 .. figure:: larch.png
2053 Simple directives may not require any content. If a directive that
2054 does not employ a content block is followed by indented text anyway,
2055 it is an error. If a block quote should immediately follow a
2056 directive, use an empty comment in-between (see Comments_ below).
2058 Actions taken in response to directives and the interpretation of text
2059 in the directive content block or subsequent text block(s) are
2060 directive-dependent. See `reStructuredText Directives`_ for details.
2062 Directives are meant for the arbitrary processing of their contents,
2063 which can be transformed into something possibly unrelated to the
2064 original text. It may also be possible for directives to be used as
2065 pragmas, to modify the behavior of the parser, such as to experiment
2066 with alternate syntax. There is no parser support for this
2067 functionality at present; if a reasonable need for pragma directives
2068 is found, they may be supported.
2070 Directives do not generate "directive" elements; they are a *parser
2071 construct* only, and have no intrinsic meaning outside of
2072 reStructuredText. Instead, the parser will transform recognized
2073 directives into (possibly specialized) document elements. Unknown
2074 directives will trigger level-3 (error) system messages.
2078 +-------+-------------------------------+
2079 | ".. " | directive type "::" directive |
2082 +-------------------------------+
2085 Substitution Definitions
2086 ````````````````````````
2088 Doctree element: substitution_definition.
2090 Substitution definitions are indicated by an explicit markup start
2091 (".. ") followed by a vertical bar, the substitution text, another
2092 vertical bar, whitespace, and the definition block. Substitution text
2093 may not begin or end with whitespace. A substitution definition block
2094 contains an embedded inline-compatible directive (without the leading
2095 ".. "), such as "image_" or "replace_". For example::
2097 The |biohazard| symbol must be used on containers used to
2098 dispose of medical waste.
2100 .. |biohazard| image:: biohazard.png
2102 It is an error for a substitution definition block to directly or
2103 indirectly contain a circular substitution reference.
2105 `Substitution references`_ are replaced in-line by the processed
2106 contents of the corresponding definition (linked by matching
2107 substitution text). Matches are case-sensitive but forgiving; if no
2108 exact match is found, a case-insensitive comparison is attempted.
2110 Substitution definitions allow the power and flexibility of
2111 block-level directives_ to be shared by inline text. They are a way
2112 to include arbitrarily complex inline structures within text, while
2113 keeping the details out of the flow of text. They are the equivalent
2114 of SGML/XML's named entities or programming language macros.
2116 Without the substitution mechanism, every time someone wants an
2117 application-specific new inline structure, they would have to petition
2118 for a syntax change. In combination with existing directive syntax,
2119 any inline structure can be coded without new syntax (except possibly
2124 +-------+-----------------------------------------------------+
2125 | ".. " | "|" substitution text "| " directive type "::" data |
2126 +-------+ directive block |
2128 +-----------------------------------------------------+
2130 Following are some use cases for the substitution mechanism. Please
2131 note that most of the embedded directives shown are examples only and
2132 have not been implemented.
2135 Substitution references may be used to associate ambiguous text
2136 with a unique object identifier.
2138 For example, many sites may wish to implement an inline "user"
2141 |Michael| and |Jon| are our widget-wranglers.
2143 .. |Michael| user:: mjones
2146 Depending on the needs of the site, this may be used to index the
2147 document for later searching, to hyperlink the inline text in
2148 various ways (mailto, homepage, mouseover Javascript with profile
2149 and contact information, etc.), or to customize presentation of
2150 the text (include username in the inline text, include an icon
2151 image with a link next to the text, make the text bold or a
2152 different color, etc.).
2154 The same approach can be used in documents which frequently refer
2155 to a particular type of objects with unique identifiers but
2156 ambiguous common names. Movies, albums, books, photos, court
2157 cases, and laws are possible. For example::
2159 |The Transparent Society| offers a fascinating alternate view
2162 .. |The Transparent Society| book:: isbn=0738201448
2164 Classes or functions, in contexts where the module or class names
2165 are unclear and/or interpreted text cannot be used, are another
2168 4XSLT has the convenience method |runString|, so you don't
2169 have to mess with DOM objects if all you want is the
2172 .. |runString| function:: module=xml.xslt class=Processor
2175 Images are a common use for substitution references::
2177 West led the |H| 3, covered by dummy's |H| Q, East's |H| K,
2178 and trumped in hand with the |S| 2.
2180 .. |H| image:: /images/heart.png
2183 .. |S| image:: /images/spade.png
2187 * |Red light| means stop.
2188 * |Green light| means go.
2189 * |Yellow light| means go really fast.
2191 .. |Red light| image:: red_light.png
2192 .. |Green light| image:: green_light.png
2193 .. |Yellow light| image:: yellow_light.png
2195 |-><-| is the official symbol of POEE_.
2197 .. |-><-| image:: discord.png
2198 .. _POEE: http://www.poee.org/
2200 The "image_" directive has been implemented.
2203 Substitution references may be used to associate inline text with
2204 an externally defined presentation style::
2206 Even |the text in Texas| is big.
2208 .. |the text in Texas| style:: big
2210 The style name may be meaningful in the context of some particular
2211 output format (CSS class name for HTML output, LaTeX style name
2212 for LaTeX, etc), or may be ignored for other output formats (such
2215 .. @@@ This needs to be rethought & rewritten or removed:
2217 Interpreted text is unsuitable for this purpose because the set
2218 of style names cannot be predefined - it is the domain of the
2219 content author, not the author of the parser and output
2220 formatter - and there is no way to associate a style name
2221 argument with an interpreted text style role. Also, it may be
2222 desirable to use the same mechanism for styling blocks::
2225 At Bob's Underwear Shop, we'll do anything to get in
2228 .. style:: disclaimer
2229 All rights reversed. Reprint what you like.
2231 .. [#] There may be sufficient need for a "style" mechanism to
2232 warrant simpler syntax such as an extension to the interpreted
2233 text role syntax. The substitution mechanism is cumbersome for
2234 simple text styling.
2237 Inline markup may be used for later processing by a template
2238 engine. For example, a Zope_ author might write::
2240 Welcome back, |name|!
2242 .. |name| tal:: replace user/getUserName
2244 After processing, this ZPT output would result::
2247 <span tal:replace="user/getUserName">name</span>!
2249 Zope would then transform this to something like "Welcome back,
2250 David!" during a session with an actual user.
2253 The substitution mechanism may be used for simple macro
2254 substitution. This may be appropriate when the replacement text
2255 is repeated many times throughout one or more documents,
2256 especially if it may need to change later. A short example is
2257 unavoidably contrived::
2259 |RST|_ is a little annoying to type over and over, especially
2260 when writing about |RST| itself, and spelling out the
2261 bicapitalized word |RST| every time isn't really necessary for
2262 |RST| source readability.
2264 .. |RST| replace:: reStructuredText
2265 .. _RST: http://docutils.sourceforge.net/rst.html
2267 Note the trailing underscore in the first use of a substitution
2268 reference. This indicates a reference to the corresponding
2271 Substitution is also appropriate when the replacement text cannot
2272 be represented using other inline constructs, or is obtrusively
2275 But still, that's nothing compared to a name like
2278 .. |j2ee-cas| replace::
2279 the Java `TM`:super: 2 Platform, Enterprise Edition Client
2281 __ http://developer.java.sun.com/developer/earlyAccess/
2284 The "replace_" directive has been implemented.
2290 Doctree element: comment.
2292 Arbitrary indented text may follow the explicit markup start and will
2293 be processed as a comment element. No further processing is done on
2294 the comment block text; a comment contains a single "text blob".
2295 Depending on the output formatter, comments may be removed from the
2296 processed output. The only restriction on comments is that they not
2297 use the same syntax as any of the other explicit markup constructs:
2298 substitution definitions, directives, footnotes, citations, or
2299 hyperlink targets. To ensure that none of the other explicit markup
2300 constructs is recognized, leave the ".." on a line by itself::
2302 .. This is a comment
2314 An explicit markup start followed by a blank line and nothing else
2315 (apart from whitespace) is an "_`empty comment`". It serves to
2316 terminate a preceding construct, and does **not** consume any indented
2317 text following. To have a block quote follow a list or any indented
2318 construct, insert an unindented empty comment in-between.
2322 +-------+----------------------+
2326 +----------------------+
2329 Implicit Hyperlink Targets
2330 ==========================
2332 Implicit hyperlink targets are generated by section titles, footnotes,
2333 and citations, and may also be generated by extension constructs.
2334 Implicit hyperlink targets otherwise behave identically to explicit
2335 `hyperlink targets`_.
2337 Problems of ambiguity due to conflicting duplicate implicit and
2338 explicit reference names are avoided by following this procedure:
2340 1. `Explicit hyperlink targets`_ override any implicit targets having
2341 the same reference name. The implicit hyperlink targets are
2342 removed, and level-1 (info) system messages are inserted.
2344 2. Duplicate implicit hyperlink targets are removed, and level-1
2345 (info) system messages inserted. For example, if two or more
2346 sections have the same title (such as "Introduction" subsections of
2347 a rigidly-structured document), there will be duplicate implicit
2350 3. Duplicate explicit hyperlink targets are removed, and level-2
2351 (warning) system messages are inserted. Exception: duplicate
2352 `external hyperlink targets`_ (identical hyperlink names and
2353 referenced URIs) do not conflict, and are not removed.
2355 System messages are inserted where target links have been removed.
2356 See "Error Handling" in `PEP 258`_.
2358 The parser must return a set of *unique* hyperlink targets. The
2359 calling software (such as the Docutils_) can warn of unresolvable
2360 links, giving reasons for the messages.
2366 In reStructuredText, inline markup applies to words or phrases within
2367 a text block. The same whitespace and punctuation that serves to
2368 delimit words in written text is used to delimit the inline markup
2369 syntax constructs (see the `inline markup recognition rules`_ for
2370 details). The text within inline markup may not begin or end with
2371 whitespace. Arbitrary `character-level inline markup`_ is supported
2372 although not encouraged. Inline markup cannot be nested.
2374 There are nine inline markup constructs. Five of the constructs use
2375 identical start-strings and end-strings to indicate the markup:
2378 - `strong emphasis`_: "**"
2379 - `interpreted text`_: "`"
2380 - `inline literals`_: "``"
2381 - `substitution references`_: "|"
2383 Three constructs use different start-strings and end-strings:
2385 - `inline internal targets`_: "_`" and "`"
2386 - `footnote references`_: "[" and "]_"
2387 - `hyperlink references`_: "`" and "\`_" (phrases), or just a
2388 trailing "_" (single words)
2390 `Standalone hyperlinks`_ are recognized implicitly, and use no extra
2393 Inline markup recognition rules
2394 -------------------------------
2396 Inline markup start-strings and end-strings are only recognized if all of
2397 the following conditions are met:
2399 1. Inline markup start-strings must start a text block or be
2400 immediately preceded by
2403 * one of the ASCII characters ``- : / ' " < ( [ {``, or
2404 * a punctuation character with `Unicode category`_
2407 `Pi` (Initial quote),
2408 `Pf` (Final quote), or
2411 2. Inline markup start-strings must be immediately followed by
2414 3. Inline markup end-strings must be immediately preceded by
2417 4. Inline markup end-strings must end a text block or be immediately
2421 * one of the ASCII characters ``- . , : ; ! ? \ / ' " ) ] } >``, or
2422 * a punctuation character with `Unicode category`_
2425 `Pi` (Initial quote),
2426 `Pf` (Final quote), or
2429 5. If an inline markup start-string is immediately preceded by one of the
2430 ASCII characters ``' " < ( [ {`` or a character with Unicode character
2431 category `Ps`, `Pi`, or `Pf`, it must not be followed by the
2432 corresponding closing character from ``' " ) ] } >`` or the categories
2433 `Pe`, `Pf`, or `Pi`.
2434 (For quotes, corresponding characters can be
2435 any of the `quotation marks in international usage`_.)
2437 6. An inline markup end-string must be separated by at least one
2438 character from the start-string.
2440 7. An unescaped backslash preceding a start-string or end-string will
2441 disable markup recognition, except for the end-string of `inline
2442 literals`_. See `Escaping Mechanism`_ above for details.
2444 .. _Unicode category:
2445 http://www.unicode.org/Public/5.1.0/ucd/UCD.html#General_Category_Values
2447 .. _quotation marks in international usage:
2448 http://en.wikipedia.org/wiki/Quotation_mark,_non-English_usage
2450 The inline markup recognition rules were devised to allow 90% of non-markup
2451 uses of "*", "`", "_", and "|" without escaping. For example, none of the
2452 following terms are recognized as containing inline markup strings:
2454 - 2*x a**b O(N**2) e**(x*y) f(x)*f(y) a|b file*.* (breaks 1)
2455 - 2 * x a ** b (* BOM32_* ` `` _ __ | (breaks 2)
2456 - "*" '|' (*) [*] {*} <*>
2459 »*« ›*‹ «*» »*» ›*› (breaks 5)
2461 - __init__ __init__()
2463 No escaping is required inside the following inline markup examples:
2465 - *2 * x *a **b *.txt* (breaks 3)
2466 - *2*x a**b O(N**2) e**(x*y) f(x)*f(y) a*(1+2)* (breaks 4)
2468 It may be desirable to use `inline literals`_ for some of these anyhow,
2469 especially if they represent code snippets. It's a judgment call.
2471 These cases *do* require either literal-quoting or escaping to avoid
2474 \*4, class\_, \*args, \**kwargs, \`TeX-quoted', \*ML, \*.txt
2476 In most use cases, `inline literals`_ or `literal blocks`_ are the best
2477 choice (by default, this also selects a monospaced font)::
2479 *4, class_, *args, **kwargs, `TeX-quoted', *ML, *.txt
2484 Inline markup delimiter characters are used for multiple constructs,
2485 so to avoid ambiguity there must be a specific recognition order for
2486 each character. The inline markup recognition order is as follows:
2488 - Asterisks: `Strong emphasis`_ ("**") is recognized before emphasis_
2491 - Backquotes: `Inline literals`_ ("``"), `inline internal targets`_
2492 (leading "_`", trailing "`"), are mutually independent, and are
2493 recognized before phrase `hyperlink references`_ (leading "`",
2494 trailing "\`_") and `interpreted text`_ ("`").
2496 - Trailing underscores: Footnote references ("[" + label + "]_") and
2497 simple `hyperlink references`_ (name + trailing "_") are mutually
2500 - Vertical bars: `Substitution references`_ ("|") are independently
2503 - `Standalone hyperlinks`_ are the last to be recognized.
2506 Character-Level Inline Markup
2507 -----------------------------
2509 It is possible to mark up individual characters within a word with
2510 backslash escapes (see `Escaping Mechanism`_ above). Backslash
2511 escapes can be used to allow arbitrary text to immediately follow
2514 Python ``list``\s use square bracket syntax.
2516 The backslash will disappear from the processed document. The word
2517 "list" will appear as inline literal text, and the letter "s" will
2518 immediately follow it as normal text, with no space in-between.
2520 Arbitrary text may immediately precede inline markup using
2521 backslash-escaped whitespace::
2523 Possible in *re*\ ``Structured``\ *Text*, though not encouraged.
2525 The backslashes and spaces separating "re", "Structured", and "Text"
2526 above will disappear from the processed document.
2530 The use of backslash-escapes for character-level inline markup is
2531 not encouraged. Such use is ugly and detrimental to the
2532 unprocessed document's readability. Please use this feature
2533 sparingly and only where absolutely necessary.
2539 Doctree element: emphasis.
2541 Start-string = end-string = "*".
2543 Text enclosed by single asterisk characters is emphasized::
2545 This is *emphasized text*.
2547 Emphasized text is typically displayed in italics.
2553 Doctree element: strong.
2555 Start-string = end-string = "**".
2557 Text enclosed by double-asterisks is emphasized strongly::
2559 This is **strong text**.
2561 Strongly emphasized text is typically displayed in boldface.
2567 Doctree element: depends on the explicit or implicit role and
2570 Start-string = end-string = "`".
2572 Interpreted text is text that is meant to be related, indexed, linked,
2573 summarized, or otherwise processed, but the text itself is typically
2574 left alone. Interpreted text is enclosed by single backquote
2577 This is `interpreted text`.
2579 The "role" of the interpreted text determines how the text is
2580 interpreted. The role may be inferred implicitly (as above; the
2581 "default role" is used) or indicated explicitly, using a role marker.
2582 A role marker consists of a colon, the role name, and another colon.
2583 A role name is a single word consisting of alphanumerics plus isolated
2584 internal hyphens, underscores, plus signs, colons, and periods;
2585 no whitespace or other characters are allowed. A role marker is
2586 either a prefix or a suffix to the interpreted text, whichever reads
2587 better; it's up to the author::
2589 :role:`interpreted text`
2591 `interpreted text`:role:
2593 Interpreted text allows extensions to the available inline descriptive
2594 markup constructs. To emphasis_, `strong emphasis`_, `inline
2595 literals`_, and `hyperlink references`_, we can add "title reference",
2596 "index entry", "acronym", "class", "red", "blinking" or anything else
2597 we want. Only pre-determined roles are recognized; unknown roles will
2598 generate errors. A core set of standard roles is implemented in the
2599 reference parser; see `reStructuredText Interpreted Text Roles`_ for
2600 individual descriptions. The role_ directive can be used to define
2601 custom interpreted text roles. In addition, applications may support
2608 Doctree element: literal.
2610 Start-string = end-string = "``".
2612 Text enclosed by double-backquotes is treated as inline literals::
2614 This text is an example of ``inline literals``.
2616 Inline literals may contain any characters except two adjacent
2617 backquotes in an end-string context (according to the recognition
2618 rules above). No markup interpretation (including backslash-escape
2619 interpretation) is done within inline literals.
2621 Line breaks are *not* preserved in inline literals. Although a
2622 reStructuredText parser will preserve runs of spaces in its output,
2623 the final representation of the processed document is dependent on the
2624 output formatter, thus the preservation of whitespace cannot be
2625 guaranteed. If the preservation of line breaks and/or other
2626 whitespace is important, `literal blocks`_ should be used.
2628 Inline literals are useful for short code snippets. For example::
2630 The regular expression ``[+-]?(\d+(\.\d*)?|\.\d+)`` matches
2631 floating-point numbers (without exponents).
2634 Hyperlink References
2635 --------------------
2637 Doctree element: reference.
2639 - Named hyperlink references:
2641 - Start-string = "" (empty string), end-string = "_".
2642 - Start-string = "`", end-string = "\`_". (Phrase references.)
2644 - Anonymous hyperlink references:
2646 - Start-string = "" (empty string), end-string = "__".
2647 - Start-string = "`", end-string = "\`__". (Phrase references.)
2649 Hyperlink references are indicated by a trailing underscore, "_",
2650 except for `standalone hyperlinks`_ which are recognized
2651 independently. The underscore can be thought of as a right-pointing
2652 arrow. The trailing underscores point away from hyperlink references,
2653 and the leading underscores point toward `hyperlink targets`_.
2655 Hyperlinks consist of two parts. In the text body, there is a source
2656 link, a reference name with a trailing underscore (or two underscores
2657 for `anonymous hyperlinks`_)::
2659 See the Python_ home page for info.
2661 A target link with a matching reference name must exist somewhere else
2662 in the document. See `Hyperlink Targets`_ for a full description).
2664 `Anonymous hyperlinks`_ (which see) do not use reference names to
2665 match references to targets, but otherwise behave similarly to named
2669 Embedded URIs and Aliases
2670 `````````````````````````
2672 A hyperlink reference may directly embed a target URI or (since
2673 Docutils 0.11) a hyperlink reference within angle brackets ("<...>")
2676 See the `Python home page <http://www.python.org>`_ for info.
2678 This `link <Python home page_>`_ is an alias to the link above.
2680 This is exactly equivalent to::
2682 See the `Python home page`_ for info.
2684 This link_ is an alias to the link above.
2686 .. _Python home page: http://www.python.org
2687 .. _link: `Python home page`_
2689 The bracketed URI must be preceded by whitespace and be the last text
2690 before the end string.
2692 With a single trailing underscore, the reference is named and the same
2693 target URI may be referred to again.
2694 With two trailing underscores, the reference and target are both
2695 anonymous, and the target cannot be referred to again. These are
2696 "one-off" hyperlinks. For example::
2698 `RFC 2396 <http://www.rfc-editor.org/rfc/rfc2396.txt>`__ and `RFC
2699 2732 <http://www.rfc-editor.org/rfc/rfc2732.txt>`__ together
2700 define the syntax of URIs.
2704 `RFC 2396`__ and `RFC 2732`__ together define the syntax of URIs.
2706 __ http://www.rfc-editor.org/rfc/rfc2396.txt
2707 __ http://www.rfc-editor.org/rfc/rfc2732.txt
2709 `Standalone hyperlinks`_ are treated as URIs, even if they end with an
2710 underscore like in the example of a Python function documentation::
2712 `__init__ <http:example.py.html#__init__>`__
2714 If a target URI that is not recognized as `standalone hyperlink`_ happens
2715 to end with an underscore, this needs to be backslash-escaped to avoid
2716 being parsed as hyperlink reference. For example ::
2718 Use the `source <parrots.txt\_>`__.
2720 creates an anonymous reference to the file ``parrots.txt_``.
2722 If the reference text happens to end with angle-bracketed text that is
2723 *not* a URI or hyperlink reference, at least one angle-bracket needs to
2724 be backslash-escaped or an escaped space should follow. For example, here
2725 are three references to titles describing a tag::
2727 See `HTML Element: \<a>`_, `HTML Element: <b\> `_, and
2728 `HTML Element: <c>\ `_.
2730 The reference text may also be omitted, in which case the URI will be
2731 duplicated for use as the reference text. This is useful for relative
2732 URIs where the address or file name is also the desired reference
2735 See `<a_named_relative_link>`_ or `<an_anonymous_relative_link>`__
2740 This construct offers easy authoring and maintenance of hyperlinks
2741 at the expense of general readability. Inline URIs, especially
2742 long ones, inevitably interrupt the natural flow of text. For
2743 documents meant to be read in source form, the use of independent
2744 block-level `hyperlink targets`_ is **strongly recommended**. The
2745 embedded URI construct is most suited to documents intended *only*
2746 to be read in processed form.
2749 Inline Internal Targets
2750 ------------------------
2752 Doctree element: target.
2754 Start-string = "_`", end-string = "`".
2756 Inline internal targets are the equivalent of explicit `internal
2757 hyperlink targets`_, but may appear within running text. The syntax
2758 begins with an underscore and a backquote, is followed by a hyperlink
2759 name or phrase, and ends with a backquote. Inline internal targets
2760 may not be anonymous.
2762 For example, the following paragraph contains a hyperlink target named
2765 Oh yes, the _`Norwegian Blue`. What's, um, what's wrong with it?
2767 See `Implicit Hyperlink Targets`_ for the resolution of duplicate
2774 Doctree element: footnote_reference_.
2776 .. _footnote_reference: ../doctree.html#footnote-reference
2778 Start-string = "[", end-string = "]_".
2780 Each footnote reference consists of a square-bracketed label followed
2781 by a trailing underscore. Footnote labels are one of:
2783 - one or more digits (i.e., a number),
2785 - a single "#" (denoting `auto-numbered footnotes`_),
2787 - a "#" followed by a simple reference name (an `autonumber label`_),
2790 - a single "*" (denoting `auto-symbol footnotes`_).
2796 .. [1] Read The Fine Manual
2802 Doctree element: citation_reference.
2804 Start-string = "[", end-string = "]_".
2806 Each citation reference consists of a square-bracketed label followed
2807 by a trailing underscore. Citation labels are simple `reference
2808 names`_ (case-insensitive single words, consisting of alphanumerics
2809 plus internal hyphens, underscores, and periods; no whitespace).
2813 Here is a citation reference: [CIT2002]_.
2815 See Citations_ for the citation itself.
2818 Substitution References
2819 -----------------------
2821 Doctree element: substitution_reference, reference.
2823 Start-string = "|", end-string = "|" (optionally followed by "_" or
2826 Vertical bars are used to bracket the substitution reference text. A
2827 substitution reference may also be a hyperlink reference by appending
2828 a "_" (named) or "__" (anonymous) suffix; the substitution text is
2829 used for the reference text in the named case.
2831 The processing system replaces substitution references with the
2832 processed contents of the corresponding `substitution definitions`_
2833 (which see for the definition of "correspond"). Substitution
2834 definitions produce inline-compatible elements.
2838 This is a simple |substitution reference|. It will be replaced by
2839 the processing system.
2841 This is a combination |substitution and hyperlink reference|_. In
2842 addition to being replaced, the replacement text or element will
2843 refer to the "substitution and hyperlink reference" target.
2845 .. _standalone hyperlink:
2847 Standalone Hyperlinks
2848 ---------------------
2850 Doctree element: reference.
2852 Start-string = end-string = "" (empty string).
2854 A URI (absolute URI [#URI]_ or standalone email address) within a text
2855 block is treated as a general external hyperlink with the URI itself
2856 as the link's text. For example::
2858 See http://www.python.org for info.
2860 would be marked up in HTML as::
2862 See <a href="http://www.python.org">http://www.python.org</a> for
2865 Two forms of URI are recognized:
2867 1. Absolute URIs. These consist of a scheme, a colon (":"), and a
2868 scheme-specific part whose interpretation depends on the scheme.
2870 The scheme is the name of the protocol, such as "http", "ftp",
2871 "mailto", or "telnet". The scheme consists of an initial letter,
2872 followed by letters, numbers, and/or "+", "-", ".". Recognition is
2873 limited to known schemes, per the `Official IANA Registry of URI
2874 Schemes`_ and the W3C's `Retired Index of WWW Addressing Schemes`_.
2876 The scheme-specific part of the resource identifier may be either
2877 hierarchical or opaque:
2879 - Hierarchical identifiers begin with one or two slashes and may
2880 use slashes to separate hierarchical components of the path.
2881 Examples are web pages and FTP sites::
2883 http://www.python.org
2885 ftp://ftp.python.org/pub/python
2887 - Opaque identifiers do not begin with slashes. Examples are
2888 email addresses and newsgroups::
2890 mailto:someone@somewhere.com
2892 news:comp.lang.python
2894 With queries, fragments, and %-escape sequences, URIs can become
2895 quite complicated. A reStructuredText parser must be able to
2896 recognize any absolute URI, as defined in RFC2396_ and RFC2732_.
2898 2. Standalone email addresses, which are treated as if they were
2899 absolute URIs with a "mailto:" scheme. Example::
2901 someone@somewhere.com
2903 Punctuation at the end of a URI is not considered part of the URI,
2904 unless the URI is terminated by a closing angle bracket (">").
2905 Backslashes may be used in URIs to escape markup characters,
2906 specifically asterisks ("*") and underscores ("_") which are vaid URI
2907 characters (see `Escaping Mechanism`_ above).
2909 .. [#URI] Uniform Resource Identifier. URIs are a general form of
2910 URLs (Uniform Resource Locators). For the syntax of URIs see
2911 RFC2396_ and RFC2732_.
2917 (New in Docutils 0.3.10.)
2919 All measures consist of a positive floating point number in standard
2920 (non-scientific) notation and a unit, possibly separated by one or
2923 Units are only supported where explicitly mentioned in the reference
2930 The following length units are supported by the reStructuredText
2933 * em (ems, the height of the element's font)
2934 * ex (x-height, the height of the letter "x")
2935 * px (pixels, relative to the canvas resolution)
2936 * in (inches; 1in=2.54cm)
2937 * cm (centimeters; 1cm=10mm)
2939 * pt (points; 1pt=1/72in)
2940 * pc (picas; 1pc=12pt)
2942 This set corresponds to the `length units in CSS`_.
2944 (List and explanations taken from
2945 http://www.htmlhelp.com/reference/css/units.html#length.)
2947 The following are all valid length values: "1.5em", "20 mm", ".5in".
2949 Length values without unit are completed with a writer-dependent
2950 default (e.g. px with `html4css1`, pt with `latex2e`). See the writer
2951 specific documentation in the `user doc`__ for details.
2953 .. _length units in CSS:
2954 http://www.w3.org/TR/CSS2/syndata.html#length-units
2961 Percentage values have a percent sign ("%") as unit. Percentage
2962 values are relative to other values, depending on the context in which
2970 Doctree element: system_message, problematic.
2972 Markup errors are handled according to the specification in `PEP
2976 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
2977 .. _Docutils: http://docutils.sourceforge.net/
2978 .. _The Docutils Document Tree: ../doctree.html
2979 .. _Docutils Generic DTD: ../docutils.dtd
2981 http://docutils.sourceforge.net/docutils/transforms/
2982 .. _Grouch: http://www.mems-exchange.org/software/grouch/
2983 .. _RFC822: http://www.rfc-editor.org/rfc/rfc822.txt
2984 .. _DocTitle transform:
2985 .. _DocInfo transform:
2986 http://docutils.sourceforge.net/docutils/transforms/frontmatter.py
2988 http://www.python.org/doc/current/lib/module-getopt.html
2989 .. _GNU libc getopt_long():
2990 http://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html
2992 http://www.python.org/doc/current/lib/module-doctest.html
2993 .. _Emacs table mode: http://table.sourceforge.net/
2994 .. _Official IANA Registry of URI Schemes:
2995 http://www.iana.org/assignments/uri-schemes
2996 .. _Retired Index of WWW Addressing Schemes:
2997 http://www.w3.org/Addressing/schemes.html
2998 .. _World Wide Web Consortium: http://www.w3.org/
2999 .. _HTML Techniques for Web Content Accessibility Guidelines:
3000 http://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text
3001 .. _image: directives.html#image
3002 .. _replace: directives.html#replace
3003 .. _meta: directives.html#meta
3004 .. _figure: directives.html#figure
3005 .. _admonition: directives.html#admonitions
3006 .. _role: directives.html#custom-interpreted-text-roles
3007 .. _reStructuredText Directives: directives.html
3008 .. _reStructuredText Interpreted Text Roles: roles.html
3009 .. _RFC2396: http://www.rfc-editor.org/rfc/rfc2396.txt
3010 .. _RFC2732: http://www.rfc-editor.org/rfc/rfc2732.txt
3011 .. _Zope: http://www.zope.com/
3012 .. _PEP 258: ../../peps/pep-0258.html
3018 indent-tabs-mode: nil
3019 sentence-end-double-space: t