Add ``+`` and ``:`` to simple names
[docutils.git] / docs / ref / rst / restructuredtext.txt
blobf9dcdcd10b60e7604d6b8e6d8e80ba7babffc5a0
1 .. -*- coding: utf-8 -*-
3 =======================================
4  reStructuredText Markup Specification
5 =======================================
7 :Author: David Goodger
8 :Contact: goodger@python.org
9 :Revision: $Revision$
10 :Date: $Date$
11 :Copyright: This document has been placed in the public domain.
13 .. Note::
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.
49 .. contents::
52 -----------------------
53  Quick Syntax Overview
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
74       internal targets`.
76       Paragraphs are separated by blank lines and are left-aligned.
78 - Five types of lists:
80   1. `Bullet 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
91             numerals.
93   3. `Definition lists`_::
95          what
96              Definition lists associate a term with a definition.
98          how
99              The term is a one-line phrase, and the definition is one
100              or more paragraphs or body elements, indented relative to
101              the term.
103   4. `Field lists`_::
105          :what: Field lists map field names to field bodies, like
106                 database records.  They are often part of an extension
107                 syntax.
109          :how: The field marker is a colon, the field name, and a
110                colon.
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
122                        arguments
123          /V            DOS/VMS-style options too
125      There must be at least two spaces between the option and the
126      description.
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 -->)::
134           if literal_block:
135               text = 'is left as-is'
136               spaces_and_linebreaks = 'are preserved'
137               markup_processing = None
139 - `Block quotes`_::
141       Block quotes consist of indented body elements:
143           This theory, that is mine, is mine.
145           -- Anne Elk (Miss)
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:
178   - Footnotes_::
180         .. [1] A footnote contains body elements, consistently
181            indented by at least 3 spaces.
183   - Citations_::
185         .. [CIT2002] Just like a footnote, except the label is
186            textual.
188   - `Hyperlink targets`_::
190         .. _Python: http://www.python.org
192         .. _example:
194         The "_example" target above points to this paragraph.
196   - Directives_::
198         .. image:: mylogo.png
200   - `Substitution definitions`_::
202         .. |symbol here| image:: symbol.png
204   - Comments_::
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.
211 ----------------
212  Syntax Details
213 ----------------
215 Descriptions below list "doctree elements" (document tree element
216 names; XML DTD generic identifiers) corresponding to syntax
217 constructs.  For details on the hierarchy of elements, please see `The
218 Docutils Document Tree`_ and the `Docutils Generic DTD`_ XML document
219 type definition.
222 Whitespace
223 ==========
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.
232 Blank Lines
233 -----------
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.
244 Indentation
245 -----------
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
258 indentation.
260 Since all indentation is significant, the level of indentation must be
261 consistent.  For example, indentation is the sole markup indicator for
262 `block quotes`_::
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
285         block quote.
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
297       by the parser.
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
313           as a block quote.
315     Because it is not sufficiently indented,
316     this paragraph does not belong to the list
317     item.
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
327 the field names)::
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.
338 Escaping Mechanism
339 ==================
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
356 "escaping" role).
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."""
377 Reference Names
378 ===============
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
403   a single space), and
405 - case is normalized (all alphabetic characters are converted to
406   lowercase).
408 For example, the following `hyperlink references`_ are equivalent::
410     - `A HYPERLINK`_
411     - `a    hyperlink`_
412     - `A
413       Hyperlink`_
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.
426 Document Structure
427 ==================
429 Document
430 --------
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.
453 Sections
454 --------
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
472    characters::
474        ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
476    Some characters are more suitable than others.  The following are
477    recommended::
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,
485 and so on.
487 Below are examples of section title styles::
489     ===============
490      Section Title
491     ===============
493     ---------------
494      Section Title
495     ---------------
497     Section Title
498     =============
500     Section Title
501     -------------
503     Section Title
504     `````````````
506     Section Title
507     '''''''''''''
509     Section Title
510     .............
512     Section Title
513     ~~~~~~~~~~~~~
515     Section Title
516     *************
518     Section Title
519     +++++++++++++
521     Section Title
522     ^^^^^^^^^^^^^
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
527 inset.
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
531 subsection, etc.).
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
544 sections.
547 Transitions
548 -----------
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::
569     Para.
571     ----------
573     Para.
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.
584 Body Elements
585 =============
587 Paragraphs
588 ----------
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
595 `inline markup`_.
597 Syntax diagram::
599     +------------------------------+
600     | paragraph                    |
601     |                              |
602     +------------------------------+
604     +------------------------------+
605     | paragraph                    |
606     |                              |
607     +------------------------------+
610 Bullet Lists
611 ------------
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.
644     (Warning)
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.
651 Syntax diagram::
653     +------+-----------------------+
654     | "- " | list item             |
655     +------| (body elements)+      |
656            +-----------------------+
659 Enumerated Lists
660 ----------------
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
679 Docutils 0.3.8.)
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
691   separate lists).
693 - The enumerators are not in sequence (e.g., "1.", "3." produces two
694   separate lists).
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
713 ordinary paragraph::
715     A. Einstein was a really
716     smart dude.
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.
733        a) Item 1a.
734        b) Item 1b.
736     2. a) Item 2a.
737        b) Item 2b.
739 Example syntax diagram::
741     +-------+----------------------+
742     | "1. " | list item            |
743     +-------| (body elements)+     |
744             +----------------------+
747 Definition Lists
748 ----------------
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::
763     term 1
764         Definition 1.
766     term 2
767         Definition 2, paragraph 1.
769         Definition 2, paragraph 2.
771     term 3 : classifier
772         Definition 3.
774     term 4 : classifier one : classifier two
775         Definition 4.
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
792   object schema.
794 Syntax diagram::
796     +----------------------------+
797     | term [ " : " classifier ]* |
798     +--+-------------------------+--+
799        | definition                 |
800        | (body elements)+           |
801        +----------------------------+
804 Field Lists
805 -----------
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
828 example::
830     :Date: 2001-08-16
831     :Version: 1
832     :Authors: - Me
833               - Myself
834               - I
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
852 used.
854 Syntax diagram (simplified)::
856     +--------------------+----------------------+
857     | ":" field name ":" | field body           |
858     +-------+------------+                      |
859             | (body elements)+                  |
860             +-----------------------------------+
863 Bibliographic Fields
864 ````````````````````
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
873 copyright page.
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
883 element.
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.
894 - "Status": status.
895 - "Date": date.
896 - "Copyright": copyright.
897 - "Dedication": topic.
898 - "Abstract": 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,
908 Jane;".
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
920 for details.
922 Unregistered/generic fields may contain one or more paragraphs or
923 arbitrary body elements.
926 RCS Keywords
927 ````````````
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
943 removed.
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).
950 Option Lists
951 ------------
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::
959     -a         Output all.
960     -b         Output both (this description is
961                quite long).
962     -c arg     Output just arg.
963     --long     Output all day long.
965     -p         This option has two paragraphs in the description.
966                This is the first.
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
980                           arguments.
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
996 convenience only.
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             +----------------------------------+
1041 Literal Blocks
1042 --------------
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.
1054     ::
1056         for a in [5,4,3,2,1]:   # this is program code, shown as-is
1057             print a
1058         print "it's..."
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
1063     ordinary paragraph.
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"):
1078 1. Expanded form::
1080       Paragraph:
1082       ::
1084           Literal block
1086 2. Partially minimized form::
1088       Paragraph: ::
1090           Literal block
1092 3. Fully minimized form::
1094       Paragraph::
1096           Literal block
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.
1114 Syntax diagram::
1116     +------------------------------+
1117     | paragraph                    |
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.
1133 .. [#]
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
1142 quoting::
1144     John Doe wrote::
1146     >> Great idea!
1147     >
1148     > Why didn't I think of that?
1150     You just did!  ;-)
1152 Syntax diagram::
1154     +------------------------------+
1155     | paragraph                    |
1156     | (ends with "::")             |
1157     +------------------------------+
1158     +------------------------------+
1159     | ">" per-line-quoted          |
1160     | ">" contiguous literal block |
1161     +------------------------------+
1164 Line Blocks
1165 -----------
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.
1186     | Love, Ewan.
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
1194         |
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?
1199         |
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?
1204         |
1205         | Singing...
1207 Syntax diagram::
1209     +------+-----------------------+
1210     | "| " | line                  |
1211     +------| continuation line     |
1212            +-----------------------+
1215 Block Quotes
1216 ------------
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."
1229         -- Sherlock Holmes
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
1237 attributions.
1239     Unindented paragraph.
1241         Block quote 1.
1243         -- Attribution 1
1245         Block quote 2.
1247 `Empty comments`_ may be used to explicitly terminate preceding
1248 constructs that would otherwise consume a block quote::
1250     * List item.
1252     ..
1254         Block quote 3.
1256 Empty comments may also be used to separate block quotes::
1258         Block quote 4.
1260     ..
1262         Block quote 5.
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.
1267 Syntax diagram::
1269     +------------------------------+
1270     | (current level of            |
1271     | indentation)                 |
1272     +------------------------------+
1273        +---------------------------+
1274        | block quote               |
1275        | (body elements)+          |
1276        |                           |
1277        | -- attribution text       |
1278        |    (optional)             |
1279        +---------------------------+
1282 Doctest Blocks
1283 --------------
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
1307         module, though!
1309 Indentation is not required for doctest blocks.
1312 Tables
1313 ------
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
1323 of a block quote.
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.
1331 Grid Tables
1332 ```````````
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)
1340 representation.
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     +--------------+----------+-----------+-----------+
1370     | row 2        |                                  |
1371     +--------------+----------+-----------+-----------+
1372     | row 3        |          |           |           |
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     +--------------+----------+-----------+-----------+
1383     | row 3        |          |           |           |
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     +--------------+----------+-----------+-----------+
1395     | row 3        |          |           |           |
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``.   |
1404     |              |                                  |
1405     +--------------+----------+-----------+-----------+
1406     | row 3        |          |           |           |
1407     +--------------+----------+-----------+-----------+
1410 Simple Tables
1411 `````````````
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 last of the optional
1432 header rows is underlined with '=', again with spaces at column
1433 boundaries.  There may not be a blank line below the header row
1434 separator; it would be interpreted as the bottom border of the table.
1435 The bottom boundary of the table consists of '=' underlines, also with
1436 spaces at column boundaries.  For example, here is a truth table, a
1437 three-column table with one header row and four body rows::
1439     =====  =====  =======
1440       A      B    A and B
1441     =====  =====  =======
1442     False  False  False
1443     True   False  False
1444     False  True   False
1445     True   True   True
1446     =====  =====  =======
1448 Underlines of '-' may be used to indicate column spans by "filling in"
1449 column margins to join adjacent columns.  Column span underlines must
1450 be complete (they must cover all columns) and align with established
1451 column boundaries.  Text lines containing column span underlines may
1452 not contain any other text.  A column span underline applies only to
1453 one row immediately above it.  For example, here is a table with a
1454 column span in the header::
1456     =====  =====  ======
1457        Inputs     Output
1458     ------------  ------
1459       A      B    A or B
1460     =====  =====  ======
1461     False  False  False
1462     True   False  True
1463     False  True   True
1464     True   True   True
1465     =====  =====  ======
1467 Each line of text must contain spaces at column boundaries, except
1468 where cells have been joined by column spans.  Each line of text
1469 starts a new row, except when there is a blank cell in the first
1470 column.  In that case, that line of text is parsed as a continuation
1471 line.  For this reason, cells in the first column of new rows (*not*
1472 continuation lines) *must* contain some text; blank cells would lead
1473 to a misinterpretation.  An empty comment ("..") is sufficient and
1474 will be omitted from the processed output (see Comments_ below).
1475 Also, this mechanism limits cells in the first column to only one line
1476 of text.  Use `grid tables`_ if this limitation is unacceptable.
1478 Underlines of '-' may also be used to visually separate rows, even if
1479 there are no column spans.  This is especially useful in long tables,
1480 where rows are many lines long.
1482 Blank lines are permitted within simple tables.  Their interpretation
1483 depends on the context.  Blank lines *between* rows are ignored.
1484 Blank lines *within* multi-line rows may separate paragraphs or other
1485 body elements within cells.
1487 The rightmost column is unbounded; text may continue past the edge of
1488 the table (as indicated by the table borders).  However, it is
1489 recommended that borders be made long enough to contain the entire
1490 text.
1492 The following example illustrates continuation lines (row 2 consists
1493 of two lines of text, and four lines for row 3), a blank line
1494 separating paragraphs (row 3, column 2), and text extending past the
1495 right edge of the table::
1497     =====  =====
1498     col 1  col 2
1499     =====  =====
1500     1      Second column of row 1.
1501     2      Second column of row 2.
1502            Second line of paragraph.
1503     3      - Second column of row 3.
1505            - Second item in bullet
1506              list (row 3, column 2).
1507     =====  =====
1510 Explicit Markup Blocks
1511 ----------------------
1513 An explicit markup block is a text block:
1515 - whose first line begins with ".." followed by whitespace (the
1516   "explicit markup start"),
1517 - whose second and subsequent lines (if any) are indented relative to
1518   the first, and
1519 - which ends before an unindented line.
1521 Explicit markup blocks are analogous to bullet list items, with ".."
1522 as the bullet.  The text on the lines immediately after the explicit
1523 markup start determines the indentation of the block body.  The
1524 maximum common indentation is always removed from the second and
1525 subsequent lines of the block body.  Therefore if the first construct
1526 fits in one line, and the indentation of the first and second
1527 constructs should differ, the first construct should not begin on the
1528 same line as the explicit markup start.
1530 Blank lines are required between explicit markup blocks and other
1531 elements, but are optional between explicit markup blocks where
1532 unambiguous.
1534 The explicit markup syntax is used for footnotes, citations, hyperlink
1535 targets, directives, substitution definitions, and comments.
1538 Footnotes
1539 `````````
1541 Doctree elements: footnote, label.
1543 Each footnote consists of an explicit markup start (".. "), a left
1544 square bracket, the footnote label, a right square bracket, and
1545 whitespace, followed by indented body elements.  A footnote label can
1548 - a whole decimal number consisting of one or more digits,
1550 - a single "#" (denoting `auto-numbered footnotes`_),
1552 - a "#" followed by a simple reference name (an `autonumber label`_),
1553   or
1555 - a single "*" (denoting `auto-symbol footnotes`_).
1557 The footnote content (body elements) must be consistently indented (by
1558 at least 3 spaces) and left-aligned.  The first body element within a
1559 footnote may often begin on the same line as the footnote label.
1560 However, if the first element fits on one line and the indentation of
1561 the remaining elements differ, the first element must begin on the
1562 line after the footnote label.  Otherwise, the difference in
1563 indentation will not be detected.
1565 Footnotes may occur anywhere in the document, not only at the end.
1566 Where and how they appear in the processed output depends on the
1567 processing system.
1569 Here is a manually numbered footnote::
1571     .. [1] Body elements go here.
1573 Each footnote automatically generates a hyperlink target pointing to
1574 itself.  The text of the hyperlink target name is the same as that of
1575 the footnote label.  `Auto-numbered footnotes`_ generate a number as
1576 their footnote label and reference name.  See `Implicit Hyperlink
1577 Targets`_ for a complete description of the mechanism.
1579 Syntax diagram::
1581     +-------+-------------------------+
1582     | ".. " | "[" label "]" footnote  |
1583     +-------+                         |
1584             | (body elements)+        |
1585             +-------------------------+
1588 Auto-Numbered Footnotes
1589 .......................
1591 A number sign ("#") may be used as the first character of a footnote
1592 label to request automatic numbering of the footnote or footnote
1593 reference.
1595 The first footnote to request automatic numbering is assigned the
1596 label "1", the second is assigned the label "2", and so on (assuming
1597 there are no manually numbered footnotes present; see `Mixed Manual
1598 and Auto-Numbered Footnotes`_ below).  A footnote which has
1599 automatically received a label "1" generates an implicit hyperlink
1600 target with name "1", just as if the label was explicitly specified.
1602 .. _autonumber label: `autonumber labels`_
1604 A footnote may specify a label explicitly while at the same time
1605 requesting automatic numbering: ``[#label]``.  These labels are called
1606 _`autonumber labels`.  Autonumber labels do two things:
1608 - On the footnote itself, they generate a hyperlink target whose name
1609   is the autonumber label (doesn't include the "#").
1611 - They allow an automatically numbered footnote to be referred to more
1612   than once, as a footnote reference or hyperlink reference.  For
1613   example::
1615       If [#note]_ is the first footnote reference, it will show up as
1616       "[1]".  We can refer to it again as [#note]_ and again see
1617       "[1]".  We can also refer to it as note_ (an ordinary internal
1618       hyperlink reference).
1620       .. [#note] This is the footnote labeled "note".
1622 The numbering is determined by the order of the footnotes, not by the
1623 order of the references.  For footnote references without autonumber
1624 labels (``[#]_``), the footnotes and footnote references must be in
1625 the same relative order but need not alternate in lock-step.  For
1626 example::
1628     [#]_ is a reference to footnote 1, and [#]_ is a reference to
1629     footnote 2.
1631     .. [#] This is footnote 1.
1632     .. [#] This is footnote 2.
1633     .. [#] This is footnote 3.
1635     [#]_ is a reference to footnote 3.
1637 Special care must be taken if footnotes themselves contain
1638 auto-numbered footnote references, or if multiple references are made
1639 in close proximity.  Footnotes and references are noted in the order
1640 they are encountered in the document, which is not necessarily the
1641 same as the order in which a person would read them.
1644 Auto-Symbol Footnotes
1645 .....................
1647 An asterisk ("*") may be used for footnote labels to request automatic
1648 symbol generation for footnotes and footnote references.  The asterisk
1649 may be the only character in the label.  For example::
1651     Here is a symbolic footnote reference: [*]_.
1653     .. [*] This is the footnote.
1655 A transform will insert symbols as labels into corresponding footnotes
1656 and footnote references.  The number of references must be equal to
1657 the number of footnotes.  One symbol footnote cannot have multiple
1658 references.
1660 The standard Docutils system uses the following symbols for footnote
1661 marks [#]_:
1663 - asterisk/star ("*")
1664 - dagger (HTML character entity "&dagger;", Unicode U+02020)
1665 - double dagger ("&Dagger;"/U+02021)
1666 - section mark ("&sect;"/U+000A7)
1667 - pilcrow or paragraph mark ("&para;"/U+000B6)
1668 - number sign ("#")
1669 - spade suit ("&spades;"/U+02660)
1670 - heart suit ("&hearts;"/U+02665)
1671 - diamond suit ("&diams;"/U+02666)
1672 - club suit ("&clubs;"/U+02663)
1674 .. [#] This list was inspired by the list of symbols for "Note
1675    Reference Marks" in The Chicago Manual of Style, 14th edition,
1676    section 12.51.  "Parallels" ("||") were given in CMoS instead of
1677    the pilcrow.  The last four symbols (the card suits) were added
1678    arbitrarily.
1680 If more than ten symbols are required, the same sequence will be
1681 reused, doubled and then tripled, and so on ("**" etc.).
1683 .. Note:: When using auto-symbol footnotes, the choice of output
1684    encoding is important.  Many of the symbols used are not encodable
1685    in certain common text encodings such as Latin-1 (ISO 8859-1).  The
1686    use of UTF-8 for the output encoding is recommended.  An
1687    alternative for HTML and XML output is to use the
1688    "xmlcharrefreplace" `output encoding error handler`__.
1690 __ ../../user/config.html#output-encoding-error-handler
1693 Mixed Manual and Auto-Numbered Footnotes
1694 ........................................
1696 Manual and automatic footnote numbering may both be used within a
1697 single document, although the results may not be expected.  Manual
1698 numbering takes priority.  Only unused footnote numbers are assigned
1699 to auto-numbered footnotes.  The following example should be
1700 illustrative::
1702     [2]_ will be "2" (manually numbered),
1703     [#]_ will be "3" (anonymous auto-numbered), and
1704     [#label]_ will be "1" (labeled auto-numbered).
1706     .. [2] This footnote is labeled manually, so its number is fixed.
1708     .. [#label] This autonumber-labeled footnote will be labeled "1".
1709        It is the first auto-numbered footnote and no other footnote
1710        with label "1" exists.  The order of the footnotes is used to
1711        determine numbering, not the order of the footnote references.
1713     .. [#] This footnote will be labeled "3".  It is the second
1714        auto-numbered footnote, but footnote label "2" is already used.
1717 Citations
1718 `````````
1720 Citations are identical to footnotes except that they use only
1721 non-numeric labels such as ``[note]`` or ``[GVR2001]``.  Citation
1722 labels are simple `reference names`_ (case-insensitive single words
1723 consisting of alphanumerics plus internal hyphens, underscores, and
1724 periods; no whitespace).  Citations may be rendered separately and
1725 differently from footnotes.  For example::
1727     Here is a citation reference: [CIT2002]_.
1729     .. [CIT2002] This is the citation.  It's just like a footnote,
1730        except the label is textual.
1733 .. _hyperlinks:
1735 Hyperlink Targets
1736 `````````````````
1738 Doctree element: target.
1740 These are also called _`explicit hyperlink targets`, to differentiate
1741 them from `implicit hyperlink targets`_ defined below.
1743 Hyperlink targets identify a location within or outside of a document,
1744 which may be linked to by `hyperlink references`_.
1746 Hyperlink targets may be named or anonymous.  Named hyperlink targets
1747 consist of an explicit markup start (".. "), an underscore, the
1748 reference name (no trailing underscore), a colon, whitespace, and a
1749 link block::
1751     .. _hyperlink-name: link-block
1753 Reference names are whitespace-neutral and case-insensitive.  See
1754 `Reference Names`_ for details and examples.
1756 Anonymous hyperlink targets consist of an explicit markup start
1757 (".. "), two underscores, a colon, whitespace, and a link block; there
1758 is no reference name::
1760     .. __: anonymous-hyperlink-target-link-block
1762 An alternate syntax for anonymous hyperlinks consists of two
1763 underscores, a space, and a link block::
1765     __ anonymous-hyperlink-target-link-block
1767 See `Anonymous Hyperlinks`_ below.
1769 There are three types of hyperlink targets: internal, external, and
1770 indirect.
1772 1. _`Internal hyperlink targets` have empty link blocks.  They provide
1773    an end point allowing a hyperlink to connect one place to another
1774    within a document.  An internal hyperlink target points to the
1775    element following the target.  For example::
1777        Clicking on this internal hyperlink will take us to the target_
1778        below.
1780        .. _target:
1782        The hyperlink target above points to this paragraph.
1784    Internal hyperlink targets may be "chained".  Multiple adjacent
1785    internal hyperlink targets all point to the same element::
1787        .. _target1:
1788        .. _target2:
1790        The targets "target1" and "target2" are synonyms; they both
1791        point to this paragraph.
1793    If the element "pointed to" is an external hyperlink target (with a
1794    URI in its link block; see #2 below) the URI from the external
1795    hyperlink target is propagated to the internal hyperlink targets;
1796    they will all "point to" the same URI.  There is no need to
1797    duplicate a URI.  For example, all three of the following hyperlink
1798    targets refer to the same URI::
1800        .. _Python DOC-SIG mailing list archive:
1801        .. _archive:
1802        .. _Doc-SIG: http://mail.python.org/pipermail/doc-sig/
1804    An inline form of internal hyperlink target is available; see
1805    `Inline Internal Targets`_.
1807 2. _`External hyperlink targets` have an absolute or relative URI or
1808    email address in their link blocks.  For example, take the
1809    following input::
1811        See the Python_ home page for info.
1813        `Write to me`_ with your questions.
1815        .. _Python: http://www.python.org
1816        .. _Write to me: jdoe@example.com
1818    After processing into HTML, the hyperlinks might be expressed as::
1820        See the <a href="http://www.python.org">Python</a> home page
1821        for info.
1823        <a href="mailto:jdoe@example.com">Write to me</a> with your
1824        questions.
1826    An external hyperlink's URI may begin on the same line as the
1827    explicit markup start and target name, or it may begin in an
1828    indented text block immediately following, with no intervening
1829    blank lines.  If there are multiple lines in the link block, they
1830    are concatenated.  Any whitespace is removed (whitespace is
1831    permitted to allow for line wrapping).  The following external
1832    hyperlink targets are equivalent::
1834        .. _one-liner: http://docutils.sourceforge.net/rst.html
1836        .. _starts-on-this-line: http://
1837           docutils.sourceforge.net/rst.html
1839        .. _entirely-below:
1840           http://docutils.
1841           sourceforge.net/rst.html
1843    If an external hyperlink target's URI contains an underscore as its
1844    last character, it must be escaped to avoid being mistaken for an
1845    indirect hyperlink target::
1847        This link_ refers to a file called ``underscore_``.
1849        .. _link: underscore\_
1851    It is possible (although not generally recommended) to include URIs
1852    directly within hyperlink references.  See `Embedded URIs`_ below.
1854 3. _`Indirect hyperlink targets` have a hyperlink reference in their
1855    link blocks.  In the following example, target "one" indirectly
1856    references whatever target "two" references, and target "two"
1857    references target "three", an internal hyperlink target.  In
1858    effect, all three reference the same thing::
1860        .. _one: two_
1861        .. _two: three_
1862        .. _three:
1864    Just as with `hyperlink references`_ anywhere else in a document,
1865    if a phrase-reference is used in the link block it must be enclosed
1866    in backquotes.  As with `external hyperlink targets`_, the link
1867    block of an indirect hyperlink target may begin on the same line as
1868    the explicit markup start or the next line.  It may also be split
1869    over multiple lines, in which case the lines are joined with
1870    whitespace before being normalized.
1872    For example, the following indirect hyperlink targets are
1873    equivalent::
1875        .. _one-liner: `A HYPERLINK`_
1876        .. _entirely-below:
1877           `a    hyperlink`_
1878        .. _split: `A
1879           Hyperlink`_
1881 If the reference name contains any colons, either:
1883 - the phrase must be enclosed in backquotes::
1885       .. _`FAQTS: Computers: Programming: Languages: Python`:
1886          http://python.faqts.com/
1888 - or the colon(s) must be backslash-escaped in the link target::
1890       .. _Chapter One\: "Tadpole Days":
1892       It's not easy being green...
1894 See `Implicit Hyperlink Targets`_ below for the resolution of
1895 duplicate reference names.
1897 Syntax diagram::
1899     +-------+----------------------+
1900     | ".. " | "_" name ":" link    |
1901     +-------+ block                |
1902             |                      |
1903             +----------------------+
1906 Anonymous Hyperlinks
1907 ....................
1909 The `World Wide Web Consortium`_ recommends in its `HTML Techniques
1910 for Web Content Accessibility Guidelines`_ that authors should
1911 "clearly identify the target of each link."  Hyperlink references
1912 should be as verbose as possible, but duplicating a verbose hyperlink
1913 name in the target is onerous and error-prone.  Anonymous hyperlinks
1914 are designed to allow convenient verbose hyperlink references, and are
1915 analogous to `Auto-Numbered Footnotes`_.  They are particularly useful
1916 in short or one-off documents.  However, this feature is easily abused
1917 and can result in unreadable plaintext and/or unmaintainable
1918 documents.  Caution is advised.
1920 Anonymous `hyperlink references`_ are specified with two underscores
1921 instead of one::
1923     See `the web site of my favorite programming language`__.
1925 Anonymous targets begin with ".. __:"; no reference name is required
1926 or allowed::
1928     .. __: http://www.python.org
1930 As a convenient alternative, anonymous targets may begin with "__"
1931 only::
1933     __ http://www.python.org
1935 The reference name of the reference is not used to match the reference
1936 to its target.  Instead, the order of anonymous hyperlink references
1937 and targets within the document is significant: the first anonymous
1938 reference will link to the first anonymous target.  The number of
1939 anonymous hyperlink references in a document must match the number of
1940 anonymous targets.  For readability, it is recommended that targets be
1941 kept close to references.  Take care when editing text containing
1942 anonymous references; adding, removing, and rearranging references
1943 require attention to the order of corresponding targets.
1946 Directives
1947 ``````````
1949 Doctree elements: depend on the directive.
1951 Directives are an extension mechanism for reStructuredText, a way of
1952 adding support for new constructs without adding new primary syntax
1953 (directives may support additional syntax locally).  All standard
1954 directives (those implemented and registered in the reference
1955 reStructuredText parser) are described in the `reStructuredText
1956 Directives`_ document, and are always available.  Any other directives
1957 are domain-specific, and may require special action to make them
1958 available when processing the document.
1960 For example, here's how an image_ may be placed::
1962     .. image:: mylogo.jpeg
1964 A figure_ (a graphic with a caption) may placed like this::
1966     .. figure:: larch.png
1968        The larch.
1970 An admonition_ (note, caution, etc.) contains other body elements::
1972     .. note:: This is a paragraph
1974        - Here is a bullet list.
1976 Directives are indicated by an explicit markup start (".. ") followed
1977 by the directive type, two colons, and whitespace (together called the
1978 "directive marker").  Directive types are case-insensitive single
1979 words (alphanumerics plus internal hyphens, underscores, and periods;
1980 no whitespace).  Two colons are used after the directive type for
1981 these reasons:
1983 - Two colons are distinctive, and unlikely to be used in common text.
1985 - Two colons avoids clashes with common comment text like::
1987       .. Danger: modify at your own risk!
1989 - If an implementation of reStructuredText does not recognize a
1990   directive (i.e., the directive-handler is not installed), a level-3
1991   (error) system message is generated, and the entire directive block
1992   (including the directive itself) will be included as a literal
1993   block.  Thus "::" is a natural choice.
1995 The directive block is consists of any text on the first line of the
1996 directive after the directive marker, and any subsequent indented
1997 text.  The interpretation of the directive block is up to the
1998 directive code.  There are three logical parts to the directive block:
2000 1. Directive arguments.
2001 2. Directive options.
2002 3. Directive content.
2004 Individual directives can employ any combination of these parts.
2005 Directive arguments can be filesystem paths, URLs, title text, etc.
2006 Directive options are indicated using `field lists`_; the field names
2007 and contents are directive-specific.  Arguments and options must form
2008 a contiguous block beginning on the first or second line of the
2009 directive; a blank line indicates the beginning of the directive
2010 content block.  If either arguments and/or options are employed by the
2011 directive, a blank line must separate them from the directive content.
2012 The "figure" directive employs all three parts::
2014     .. figure:: larch.png
2015        :scale: 50
2017        The larch.
2019 Simple directives may not require any content.  If a directive that
2020 does not employ a content block is followed by indented text anyway,
2021 it is an error.  If a block quote should immediately follow a
2022 directive, use an empty comment in-between (see Comments_ below).
2024 Actions taken in response to directives and the interpretation of text
2025 in the directive content block or subsequent text block(s) are
2026 directive-dependent.  See `reStructuredText Directives`_ for details.
2028 Directives are meant for the arbitrary processing of their contents,
2029 which can be transformed into something possibly unrelated to the
2030 original text.  It may also be possible for directives to be used as
2031 pragmas, to modify the behavior of the parser, such as to experiment
2032 with alternate syntax.  There is no parser support for this
2033 functionality at present; if a reasonable need for pragma directives
2034 is found, they may be supported.
2036 Directives do not generate "directive" elements; they are a *parser
2037 construct* only, and have no intrinsic meaning outside of
2038 reStructuredText.  Instead, the parser will transform recognized
2039 directives into (possibly specialized) document elements.  Unknown
2040 directives will trigger level-3 (error) system messages.
2042 Syntax diagram::
2044     +-------+-------------------------------+
2045     | ".. " | directive type "::" directive |
2046     +-------+ block                         |
2047             |                               |
2048             +-------------------------------+
2051 Substitution Definitions
2052 ````````````````````````
2054 Doctree element: substitution_definition.
2056 Substitution definitions are indicated by an explicit markup start
2057 (".. ") followed by a vertical bar, the substitution text, another
2058 vertical bar, whitespace, and the definition block.  Substitution text
2059 may not begin or end with whitespace.  A substitution definition block
2060 contains an embedded inline-compatible directive (without the leading
2061 ".. "), such as "image_" or "replace_".  For example::
2063     The |biohazard| symbol must be used on containers used to
2064     dispose of medical waste.
2066     .. |biohazard| image:: biohazard.png
2068 It is an error for a substitution definition block to directly or
2069 indirectly contain a circular substitution reference.
2071 `Substitution references`_ are replaced in-line by the processed
2072 contents of the corresponding definition (linked by matching
2073 substitution text).  Matches are case-sensitive but forgiving; if no
2074 exact match is found, a case-insensitive comparison is attempted.
2076 Substitution definitions allow the power and flexibility of
2077 block-level directives_ to be shared by inline text.  They are a way
2078 to include arbitrarily complex inline structures within text, while
2079 keeping the details out of the flow of text.  They are the equivalent
2080 of SGML/XML's named entities or programming language macros.
2082 Without the substitution mechanism, every time someone wants an
2083 application-specific new inline structure, they would have to petition
2084 for a syntax change.  In combination with existing directive syntax,
2085 any inline structure can be coded without new syntax (except possibly
2086 a new directive).
2088 Syntax diagram::
2090     +-------+-----------------------------------------------------+
2091     | ".. " | "|" substitution text "| " directive type "::" data |
2092     +-------+ directive block                                     |
2093             |                                                     |
2094             +-----------------------------------------------------+
2096 Following are some use cases for the substitution mechanism.  Please
2097 note that most of the embedded directives shown are examples only and
2098 have not been implemented.
2100 Objects
2101     Substitution references may be used to associate ambiguous text
2102     with a unique object identifier.
2104     For example, many sites may wish to implement an inline "user"
2105     directive::
2107         |Michael| and |Jon| are our widget-wranglers.
2109         .. |Michael| user:: mjones
2110         .. |Jon|     user:: jhl
2112     Depending on the needs of the site, this may be used to index the
2113     document for later searching, to hyperlink the inline text in
2114     various ways (mailto, homepage, mouseover Javascript with profile
2115     and contact information, etc.), or to customize presentation of
2116     the text (include username in the inline text, include an icon
2117     image with a link next to the text, make the text bold or a
2118     different color, etc.).
2120     The same approach can be used in documents which frequently refer
2121     to a particular type of objects with unique identifiers but
2122     ambiguous common names.  Movies, albums, books, photos, court
2123     cases, and laws are possible.  For example::
2125         |The Transparent Society| offers a fascinating alternate view
2126         on privacy issues.
2128         .. |The Transparent Society| book:: isbn=0738201448
2130     Classes or functions, in contexts where the module or class names
2131     are unclear and/or interpreted text cannot be used, are another
2132     possibility::
2134         4XSLT has the convenience method |runString|, so you don't
2135         have to mess with DOM objects if all you want is the
2136         transformed output.
2138         .. |runString| function:: module=xml.xslt class=Processor
2140 Images
2141     Images are a common use for substitution references::
2143         West led the |H| 3, covered by dummy's |H| Q, East's |H| K,
2144         and trumped in hand with the |S| 2.
2146         .. |H| image:: /images/heart.png
2147            :height: 11
2148            :width: 11
2149         .. |S| image:: /images/spade.png
2150            :height: 11
2151            :width: 11
2153         * |Red light| means stop.
2154         * |Green light| means go.
2155         * |Yellow light| means go really fast.
2157         .. |Red light|    image:: red_light.png
2158         .. |Green light|  image:: green_light.png
2159         .. |Yellow light| image:: yellow_light.png
2161         |-><-| is the official symbol of POEE_.
2163         .. |-><-| image:: discord.png
2164         .. _POEE: http://www.poee.org/
2166     The "image_" directive has been implemented.
2168 Styles [#]_
2169     Substitution references may be used to associate inline text with
2170     an externally defined presentation style::
2172         Even |the text in Texas| is big.
2174         .. |the text in Texas| style:: big
2176     The style name may be meaningful in the context of some particular
2177     output format (CSS class name for HTML output, LaTeX style name
2178     for LaTeX, etc), or may be ignored for other output formats (such
2179     as plaintext).
2181     .. @@@ This needs to be rethought & rewritten or removed:
2183        Interpreted text is unsuitable for this purpose because the set
2184        of style names cannot be predefined - it is the domain of the
2185        content author, not the author of the parser and output
2186        formatter - and there is no way to associate a style name
2187        argument with an interpreted text style role.  Also, it may be
2188        desirable to use the same mechanism for styling blocks::
2190            .. style:: motto
2191               At Bob's Underwear Shop, we'll do anything to get in
2192               your pants.
2194            .. style:: disclaimer
2195               All rights reversed.  Reprint what you like.
2197     .. [#] There may be sufficient need for a "style" mechanism to
2198        warrant simpler syntax such as an extension to the interpreted
2199        text role syntax.  The substitution mechanism is cumbersome for
2200        simple text styling.
2202 Templates
2203     Inline markup may be used for later processing by a template
2204     engine.  For example, a Zope_ author might write::
2206         Welcome back, |name|!
2208         .. |name| tal:: replace user/getUserName
2210     After processing, this ZPT output would result::
2212         Welcome back,
2213         <span tal:replace="user/getUserName">name</span>!
2215     Zope would then transform this to something like "Welcome back,
2216     David!" during a session with an actual user.
2218 Replacement text
2219     The substitution mechanism may be used for simple macro
2220     substitution.  This may be appropriate when the replacement text
2221     is repeated many times throughout one or more documents,
2222     especially if it may need to change later.  A short example is
2223     unavoidably contrived::
2225         |RST|_ is a little annoying to type over and over, especially
2226         when writing about |RST| itself, and spelling out the
2227         bicapitalized word |RST| every time isn't really necessary for
2228         |RST| source readability.
2230         .. |RST| replace:: reStructuredText
2231         .. _RST: http://docutils.sourceforge.net/rst.html
2233     Note the trailing underscore in the first use of a substitution
2234     reference.  This indicates a reference to the corresponding
2235     hyperlink target.
2237     Substitution is also appropriate when the replacement text cannot
2238     be represented using other inline constructs, or is obtrusively
2239     long::
2241         But still, that's nothing compared to a name like
2242         |j2ee-cas|__.
2244         .. |j2ee-cas| replace::
2245            the Java `TM`:super: 2 Platform, Enterprise Edition Client
2246            Access Services
2247         __ http://developer.java.sun.com/developer/earlyAccess/
2248            j2eecas/
2250     The "replace_" directive has been implemented.
2253 Comments
2254 ````````
2256 Doctree element: comment.
2258 Arbitrary indented text may follow the explicit markup start and will
2259 be processed as a comment element.  No further processing is done on
2260 the comment block text; a comment contains a single "text blob".
2261 Depending on the output formatter, comments may be removed from the
2262 processed output.  The only restriction on comments is that they not
2263 use the same syntax as any of the other explicit markup constructs:
2264 substitution definitions, directives, footnotes, citations, or
2265 hyperlink targets.  To ensure that none of the other explicit markup
2266 constructs is recognized, leave the ".." on a line by itself::
2268     .. This is a comment
2269     ..
2270        _so: is this!
2271     ..
2272        [and] this!
2273     ..
2274        this:: too!
2275     ..
2276        |even| this:: !
2278 .. _empty comments:
2280 An explicit markup start followed by a blank line and nothing else
2281 (apart from whitespace) is an "_`empty comment`".  It serves to
2282 terminate a preceding construct, and does **not** consume any indented
2283 text following.  To have a block quote follow a list or any indented
2284 construct, insert an unindented empty comment in-between.
2286 Syntax diagram::
2288     +-------+----------------------+
2289     | ".. " | comment              |
2290     +-------+ block                |
2291             |                      |
2292             +----------------------+
2295 Implicit Hyperlink Targets
2296 ==========================
2298 Implicit hyperlink targets are generated by section titles, footnotes,
2299 and citations, and may also be generated by extension constructs.
2300 Implicit hyperlink targets otherwise behave identically to explicit
2301 `hyperlink targets`_.
2303 Problems of ambiguity due to conflicting duplicate implicit and
2304 explicit reference names are avoided by following this procedure:
2306 1. `Explicit hyperlink targets`_ override any implicit targets having
2307    the same reference name.  The implicit hyperlink targets are
2308    removed, and level-1 (info) system messages are inserted.
2310 2. Duplicate implicit hyperlink targets are removed, and level-1
2311    (info) system messages inserted.  For example, if two or more
2312    sections have the same title (such as "Introduction" subsections of
2313    a rigidly-structured document), there will be duplicate implicit
2314    hyperlink targets.
2316 3. Duplicate explicit hyperlink targets are removed, and level-2
2317    (warning) system messages are inserted.  Exception: duplicate
2318    `external hyperlink targets`_ (identical hyperlink names and
2319    referenced URIs) do not conflict, and are not removed.
2321 System messages are inserted where target links have been removed.
2322 See "Error Handling" in `PEP 258`_.
2324 The parser must return a set of *unique* hyperlink targets.  The
2325 calling software (such as the Docutils_) can warn of unresolvable
2326 links, giving reasons for the messages.
2329 Inline Markup
2330 =============
2332 In reStructuredText, inline markup applies to words or phrases within
2333 a text block.  The same whitespace and punctuation that serves to
2334 delimit words in written text is used to delimit the inline markup
2335 syntax constructs.  The text within inline markup may not begin or end
2336 with whitespace.  Arbitrary `character-level inline markup`_ is
2337 supported although not encouraged.  Inline markup cannot be nested.
2339 There are nine inline markup constructs.  Five of the constructs use
2340 identical start-strings and end-strings to indicate the markup:
2342 - emphasis_: "*"
2343 - `strong emphasis`_: "**"
2344 - `interpreted text`_: "`"
2345 - `inline literals`_: "``"
2346 - `substitution references`_: "|"
2348 Three constructs use different start-strings and end-strings:
2350 - `inline internal targets`_: "_`" and "`"
2351 - `footnote references`_: "[" and "]_"
2352 - `hyperlink references`_: "`" and "\`_" (phrases), or just a
2353   trailing "_" (single words)
2355 `Standalone hyperlinks`_ are recognized implicitly, and use no extra
2356 markup.
2358 The inline markup start-string and end-string recognition rules are as
2359 follows.  If any of the conditions are not met, the start-string or
2360 end-string will not be recognized or processed.
2362 1. Inline markup start-strings must start a text block or be
2363    immediately preceded by whitespace or one of::
2365        ' " ( [ { < - / :
2367 2. Inline markup start-strings must be immediately followed by
2368    non-whitespace.
2370 3. Inline markup end-strings must be immediately preceded by
2371    non-whitespace.
2373 4. Inline markup end-strings must end a text block or be immediately
2374    followed by whitespace or one of::
2376        ' " ) ] } > - / : . , ; ! ? \
2378 5. If an inline markup start-string is immediately preceded by a
2379    single or double quote, "(", "[", "{", or "<", it must not be
2380    immediately followed by the corresponding single or double quote,
2381    ")", "]", "}", or ">".
2383 6. An inline markup end-string must be separated by at least one
2384    character from the start-string.
2386 7. An unescaped backslash preceding a start-string or end-string will
2387    disable markup recognition, except for the end-string of `inline
2388    literals`_.  See `Escaping Mechanism`_ above for details.
2390 For example, none of the following are recognized as containing inline
2391 markup start-strings:
2393 - asterisks: * "*" '*' (*) (* [*] {*} 1*x BOM32_*
2394 - double asterisks: **  a**b O(N**2) etc.
2395 - backquotes: ` `` etc.
2396 - underscores: _ __ __init__ __init__() etc.
2397 - vertical bars: | || etc.
2399 It may be desirable to use inline literals for some of these anyhow,
2400 especially if they represent code snippets.  It's a judgment call.
2402 These cases *do* require either literal-quoting or escaping to avoid
2403 misinterpretation::
2405     *4, class_, *args, **kwargs, `TeX-quoted', *ML, *.txt
2407 The inline markup recognition rules were devised intentionally to
2408 allow 90% of non-markup uses of "*", "`", "_", and "|" *without*
2409 resorting to backslashes.  For 9 of the remaining 10%, use inline
2410 literals or literal blocks::
2412     "``\*``" -> "\*" (possibly in another font or quoted)
2414 Only those who understand the escaping and inline markup rules should
2415 attempt the remaining 1%.  ;-)
2417 Inline markup delimiter characters are used for multiple constructs,
2418 so to avoid ambiguity there must be a specific recognition order for
2419 each character.  The inline markup recognition order is as follows:
2421 - Asterisks: `Strong emphasis`_ ("**") is recognized before emphasis_
2422   ("*").
2424 - Backquotes: `Inline literals`_ ("``"), `inline internal targets`_
2425   (leading "_`", trailing "`"), are mutually independent, and are
2426   recognized before phrase `hyperlink references`_ (leading "`",
2427   trailing "\`_") and `interpreted text`_ ("`").
2429 - Trailing underscores: Footnote references ("[" + label + "]_") and
2430   simple `hyperlink references`_ (name + trailing "_") are mutually
2431   independent.
2433 - Vertical bars: `Substitution references`_ ("|") are independently
2434   recognized.
2436 - `Standalone hyperlinks`_ are the last to be recognized.
2439 Character-Level Inline Markup
2440 -----------------------------
2442 It is possible to mark up individual characters within a word with
2443 backslash escapes (see `Escaping Mechanism`_ above).  Backslash
2444 escapes can be used to allow arbitrary text to immediately follow
2445 inline markup::
2447     Python ``list``\s use square bracket syntax.
2449 The backslash will disappear from the processed document.  The word
2450 "list" will appear as inline literal text, and the letter "s" will
2451 immediately follow it as normal text, with no space in-between.
2453 Arbitrary text may immediately precede inline markup using
2454 backslash-escaped whitespace::
2456     Possible in *re*\ ``Structured``\ *Text*, though not encouraged.
2458 The backslashes and spaces separating "re", "Structured", and "Text"
2459 above will disappear from the processed document.
2461 .. CAUTION::
2463    The use of backslash-escapes for character-level inline markup is
2464    not encouraged.  Such use is ugly and detrimental to the
2465    unprocessed document's readability.  Please use this feature
2466    sparingly and only where absolutely necessary.
2469 Emphasis
2470 --------
2472 Doctree element: emphasis.
2474 Start-string = end-string = "*".
2476 Text enclosed by single asterisk characters is emphasized::
2478     This is *emphasized text*.
2480 Emphasized text is typically displayed in italics.
2483 Strong Emphasis
2484 ---------------
2486 Doctree element: strong.
2488 Start-string = end-string = "**".
2490 Text enclosed by double-asterisks is emphasized strongly::
2492     This is **strong text**.
2494 Strongly emphasized text is typically displayed in boldface.
2497 Interpreted Text
2498 ----------------
2500 Doctree element: depends on the explicit or implicit role and
2501 processing.
2503 Start-string = end-string = "`".
2505 Interpreted text is text that is meant to be related, indexed, linked,
2506 summarized, or otherwise processed, but the text itself is typically
2507 left alone.  Interpreted text is enclosed by single backquote
2508 characters::
2510     This is `interpreted text`.
2512 The "role" of the interpreted text determines how the text is
2513 interpreted.  The role may be inferred implicitly (as above; the
2514 "default role" is used) or indicated explicitly, using a role marker.
2515 A role marker consists of a colon, the role name, and another colon.
2516 A role name is a single word consisting of alphanumerics plus internal
2517 hyphens, underscores, and periods; no whitespace or other characters
2518 are allowed.  A role marker is either a prefix or a suffix to the
2519 interpreted text, whichever reads better; it's up to the author::
2521     :role:`interpreted text`
2523     `interpreted text`:role:
2525 Interpreted text allows extensions to the available inline descriptive
2526 markup constructs.  To emphasis_, `strong emphasis`_, `inline
2527 literals`_, and `hyperlink references`_, we can add "title reference",
2528 "index entry", "acronym", "class", "red", "blinking" or anything else
2529 we want.  Only pre-determined roles are recognized; unknown roles will
2530 generate errors.  A core set of standard roles is implemented in the
2531 reference parser; see `reStructuredText Interpreted Text Roles`_ for
2532 individual descriptions.  In addition, applications may support
2533 specialized roles.
2536 Inline Literals
2537 ---------------
2539 Doctree element: literal.
2541 Start-string = end-string = "``".
2543 Text enclosed by double-backquotes is treated as inline literals::
2545     This text is an example of ``inline literals``.
2547 Inline literals may contain any characters except two adjacent
2548 backquotes in an end-string context (according to the recognition
2549 rules above).  No markup interpretation (including backslash-escape
2550 interpretation) is done within inline literals.
2552 Line breaks are *not* preserved in inline literals.  Although a
2553 reStructuredText parser will preserve runs of spaces in its output,
2554 the final representation of the processed document is dependent on the
2555 output formatter, thus the preservation of whitespace cannot be
2556 guaranteed.  If the preservation of line breaks and/or other
2557 whitespace is important, `literal blocks`_ should be used.
2559 Inline literals are useful for short code snippets.  For example::
2561     The regular expression ``[+-]?(\d+(\.\d*)?|\.\d+)`` matches
2562     floating-point numbers (without exponents).
2565 Hyperlink References
2566 --------------------
2568 Doctree element: reference.
2570 - Named hyperlink references:
2572   - Start-string = "" (empty string), end-string = "_".
2573   - Start-string = "`", end-string = "\`_".  (Phrase references.)
2575 - Anonymous hyperlink references:
2577   - Start-string = "" (empty string), end-string = "__".
2578   - Start-string = "`", end-string = "\`__".  (Phrase references.)
2580 Hyperlink references are indicated by a trailing underscore, "_",
2581 except for `standalone hyperlinks`_ which are recognized
2582 independently.  The underscore can be thought of as a right-pointing
2583 arrow.  The trailing underscores point away from hyperlink references,
2584 and the leading underscores point toward `hyperlink targets`_.
2586 Hyperlinks consist of two parts.  In the text body, there is a source
2587 link, a reference name with a trailing underscore (or two underscores
2588 for `anonymous hyperlinks`_)::
2590     See the Python_ home page for info.
2592 A target link with a matching reference name must exist somewhere else
2593 in the document.  See `Hyperlink Targets`_ for a full description).
2595 `Anonymous hyperlinks`_ (which see) do not use reference names to
2596 match references to targets, but otherwise behave similarly to named
2597 hyperlinks.
2600 Embedded URIs
2601 `````````````
2603 A hyperlink reference may directly embed a target URI inline, within
2604 angle brackets ("<...>") as follows::
2606     See the `Python home page <http://www.python.org>`_ for info.
2608 This is exactly equivalent to::
2610     See the `Python home page`_ for info.
2612     .. _Python home page: http://www.python.org
2614 The bracketed URI must be preceded by whitespace and be the last text
2615 before the end string.  With a single trailing underscore, the
2616 reference is named and the same target URI may be referred to again.
2618 With two trailing underscores, the reference and target are both
2619 anonymous, and the target cannot be referred to again.  These are
2620 "one-off" hyperlinks.  For example::
2622     `RFC 2396 <http://www.rfc-editor.org/rfc/rfc2396.txt>`__ and `RFC
2623     2732 <http://www.rfc-editor.org/rfc/rfc2732.txt>`__ together
2624     define the syntax of URIs.
2626 Equivalent to::
2628     `RFC 2396`__ and `RFC 2732`__ together define the syntax of URIs.
2630     __ http://www.rfc-editor.org/rfc/rfc2396.txt
2631     __ http://www.rfc-editor.org/rfc/rfc2732.txt
2633 If reference text happens to end with angle-bracketed text that is
2634 *not* a URI, the open-angle-bracket needs to be backslash-escaped.
2635 For example, here is a reference to a title describing a tag::
2637     See `HTML Element: \<a>`_ below.
2639 The reference text may also be omitted, in which case the URI will be
2640 duplicated for use as the reference text.  This is useful for relative
2641 URIs where the address or file name is also the desired reference
2642 text::
2644     See `<a_named_relative_link>`_ or `<an_anonymous_relative_link>`__
2645     for details.
2647 .. CAUTION::
2649    This construct offers easy authoring and maintenance of hyperlinks
2650    at the expense of general readability.  Inline URIs, especially
2651    long ones, inevitably interrupt the natural flow of text.  For
2652    documents meant to be read in source form, the use of independent
2653    block-level `hyperlink targets`_ is **strongly recommended**.  The
2654    embedded URI construct is most suited to documents intended *only*
2655    to be read in processed form.
2658 Inline Internal Targets
2659 ------------------------
2661 Doctree element: target.
2663 Start-string = "_`", end-string = "`".
2665 Inline internal targets are the equivalent of explicit `internal
2666 hyperlink targets`_, but may appear within running text.  The syntax
2667 begins with an underscore and a backquote, is followed by a hyperlink
2668 name or phrase, and ends with a backquote.  Inline internal targets
2669 may not be anonymous.
2671 For example, the following paragraph contains a hyperlink target named
2672 "Norwegian Blue"::
2674     Oh yes, the _`Norwegian Blue`.  What's, um, what's wrong with it?
2676 See `Implicit Hyperlink Targets`_ for the resolution of duplicate
2677 reference names.
2680 Footnote References
2681 -------------------
2683 Doctree element: footnote_reference.
2685 Start-string = "[", end-string = "]_".
2687 Each footnote reference consists of a square-bracketed label followed
2688 by a trailing underscore.  Footnote labels are one of:
2690 - one or more digits (i.e., a number),
2692 - a single "#" (denoting `auto-numbered footnotes`_),
2694 - a "#" followed by a simple reference name (an `autonumber label`_),
2695   or
2697 - a single "*" (denoting `auto-symbol footnotes`_).
2699 For example::
2701     Please RTFM [1]_.
2703     .. [1] Read The Fine Manual
2706 Citation References
2707 -------------------
2709 Doctree element: citation_reference.
2711 Start-string = "[", end-string = "]_".
2713 Each citation reference consists of a square-bracketed label followed
2714 by a trailing underscore.  Citation labels are simple `reference
2715 names`_ (case-insensitive single words, consisting of alphanumerics
2716 plus internal hyphens, underscores, and periods; no whitespace).
2718 For example::
2720     Here is a citation reference: [CIT2002]_.
2722 See Citations_ for the citation itself.
2725 Substitution References
2726 -----------------------
2728 Doctree element: substitution_reference, reference.
2730 Start-string = "|", end-string = "|" (optionally followed by "_" or
2731 "__").
2733 Vertical bars are used to bracket the substitution reference text.  A
2734 substitution reference may also be a hyperlink reference by appending
2735 a "_" (named) or "__" (anonymous) suffix; the substitution text is
2736 used for the reference text in the named case.
2738 The processing system replaces substitution references with the
2739 processed contents of the corresponding `substitution definitions`_
2740 (which see for the definition of "correspond").  Substitution
2741 definitions produce inline-compatible elements.
2743 Examples::
2745     This is a simple |substitution reference|.  It will be replaced by
2746     the processing system.
2748     This is a combination |substitution and hyperlink reference|_.  In
2749     addition to being replaced, the replacement text or element will
2750     refer to the "substitution and hyperlink reference" target.
2753 Standalone Hyperlinks
2754 ---------------------
2756 Doctree element: reference.
2758 Start-string = end-string = "" (empty string).
2760 A URI (absolute URI [#URI]_ or standalone email address) within a text
2761 block is treated as a general external hyperlink with the URI itself
2762 as the link's text.  For example::
2764     See http://www.python.org for info.
2766 would be marked up in HTML as::
2768     See <a href="http://www.python.org">http://www.python.org</a> for
2769     info.
2771 Two forms of URI are recognized:
2773 1. Absolute URIs.  These consist of a scheme, a colon (":"), and a
2774    scheme-specific part whose interpretation depends on the scheme.
2776    The scheme is the name of the protocol, such as "http", "ftp",
2777    "mailto", or "telnet".  The scheme consists of an initial letter,
2778    followed by letters, numbers, and/or "+", "-", ".".  Recognition is
2779    limited to known schemes, per the `Official IANA Registry of URI
2780    Schemes`_ and the W3C's `Retired Index of WWW Addressing Schemes`_.
2782    The scheme-specific part of the resource identifier may be either
2783    hierarchical or opaque:
2785    - Hierarchical identifiers begin with one or two slashes and may
2786      use slashes to separate hierarchical components of the path.
2787      Examples are web pages and FTP sites::
2789          http://www.python.org
2791          ftp://ftp.python.org/pub/python
2793    - Opaque identifiers do not begin with slashes.  Examples are
2794      email addresses and newsgroups::
2796          mailto:someone@somewhere.com
2798          news:comp.lang.python
2800    With queries, fragments, and %-escape sequences, URIs can become
2801    quite complicated.  A reStructuredText parser must be able to
2802    recognize any absolute URI, as defined in RFC2396_ and RFC2732_.
2804 2. Standalone email addresses, which are treated as if they were
2805    absolute URIs with a "mailto:" scheme.  Example::
2807        someone@somewhere.com
2809 Punctuation at the end of a URI is not considered part of the URI,
2810 unless the URI is terminated by a closing angle bracket (">").
2811 Backslashes may be used in URIs to escape markup characters,
2812 specifically asterisks ("*") and underscores ("_") which are vaid URI
2813 characters (see `Escaping Mechanism`_ above).
2815 .. [#URI] Uniform Resource Identifier.  URIs are a general form of
2816    URLs (Uniform Resource Locators).  For the syntax of URIs see
2817    RFC2396_ and RFC2732_.
2820 Units
2821 =====
2823 (New in Docutils 0.3.10.)
2825 All measures consist of a positive floating point number in standard
2826 (non-scientific) notation and a unit, possibly separated by one or
2827 more spaces.
2829 Units are only supported where explicitly mentioned in the reference
2830 manuals.
2833 Length Units
2834 ------------
2836 The following length units are supported by the reStructuredText
2837 parser:
2839 * em (ems, the height of the element's font)
2840 * ex (x-height, the height of the letter "x")
2841 * px (pixels, relative to the canvas resolution)
2842 * in (inches; 1in=2.54cm)
2843 * cm (centimeters; 1cm=10mm)
2844 * mm (millimeters)
2845 * pt (points; 1pt=1/72in)
2846 * pc (picas; 1pc=12pt)
2848 (List and explanations taken from
2849 http://www.htmlhelp.com/reference/css/units.html#length.)
2851 The following are all valid length values: "1.5em", "20 mm", ".5in".
2854 Percentage Units
2855 ----------------
2857 Percentage values have a percent sign ("%") as unit.  Percentage
2858 values are relative to other values, depending on the context in which
2859 they occur.
2862 ----------------
2863  Error Handling
2864 ----------------
2866 Doctree element: system_message, problematic.
2868 Markup errors are handled according to the specification in `PEP
2869 258`_.
2872 .. _reStructuredText: http://docutils.sourceforge.net/rst.html
2873 .. _Docutils: http://docutils.sourceforge.net/
2874 .. _The Docutils Document Tree: ../doctree.html
2875 .. _Docutils Generic DTD: ../docutils.dtd
2876 .. _transforms:
2877    http://docutils.sourceforge.net/docutils/transforms/
2878 .. _Grouch: http://www.mems-exchange.org/software/grouch/
2879 .. _RFC822: http://www.rfc-editor.org/rfc/rfc822.txt
2880 .. _DocTitle transform:
2881 .. _DocInfo transform:
2882    http://docutils.sourceforge.net/docutils/transforms/frontmatter.py
2883 .. _getopt.py:
2884    http://www.python.org/doc/current/lib/module-getopt.html
2885 .. _GNU libc getopt_long():
2886    http://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html
2887 .. _doctest module:
2888    http://www.python.org/doc/current/lib/module-doctest.html
2889 .. _Emacs table mode: http://table.sourceforge.net/
2890 .. _Official IANA Registry of URI Schemes:
2891    http://www.iana.org/assignments/uri-schemes
2892 .. _Retired Index of WWW Addressing Schemes:
2893    http://www.w3.org/Addressing/schemes.html
2894 .. _World Wide Web Consortium: http://www.w3.org/
2895 .. _HTML Techniques for Web Content Accessibility Guidelines:
2896    http://www.w3.org/TR/WCAG10-HTML-TECHS/#link-text
2897 .. _image: directives.html#image
2898 .. _replace: directives.html#replace
2899 .. _meta: directives.html#meta
2900 .. _figure: directives.html#figure
2901 .. _admonition: directives.html#admonitions
2902 .. _reStructuredText Directives: directives.html
2903 .. _reStructuredText Interpreted Text Roles: roles.html
2904 .. _RFC2396: http://www.rfc-editor.org/rfc/rfc2396.txt
2905 .. _RFC2732: http://www.rfc-editor.org/rfc/rfc2732.txt
2906 .. _Zope: http://www.zope.com/
2907 .. _PEP 258: ../../peps/pep-0258.html
2911    Local Variables:
2912    mode: indented-text
2913    indent-tabs-mode: nil
2914    sentence-end-double-space: t
2915    fill-column: 70
2916    End: