Minor documentation edits.
[docutils.git] / docs / ref / rst / directives.txt
blobcc2d47ca7f514d366c49a7ae1d8ff50bfe27fe65
1 =============================
2  reStructuredText Directives
3 =============================
4 :Author: David Goodger
5 :Contact: docutils-develop@lists.sourceforge.net
6 :Revision: $Revision$
7 :Date: $Date$
8 :Copyright: This document has been placed in the public domain.
10 .. contents::
12 This document describes the directives implemented in the reference
13 reStructuredText parser.
15 Directives have the following syntax::
17     +-------+-------------------------------+
18     | ".. " | directive type "::" directive |
19     +-------+ block                         |
20             |                               |
21             +-------------------------------+
23 Directives begin with an explicit markup start (two periods and a
24 space), followed by the directive type and two colons (collectively,
25 the "directive marker").  The directive block begins immediately after
26 the directive marker, and includes all subsequent indented lines.  The
27 directive block is divided into arguments, options (a field list), and
28 content (in that order), any of which may appear.  See the Directives_
29 section in the `reStructuredText Markup Specification`_ for syntax
30 details.
32 Descriptions below list "doctree elements" (document tree element
33 names; XML DTD generic identifiers) corresponding to individual
34 directives.  For details on the hierarchy of elements, please see `The
35 Docutils Document Tree`_ and the `Docutils Generic DTD`_ XML document
36 type definition.  For directive implementation details, see `Creating
37 reStructuredText Directives`_.
39 .. _Directives: restructuredtext.html#directives
40 .. _reStructuredText Markup Specification: restructuredtext.html
41 .. _The Docutils Document Tree: ../doctree.html
42 .. _Docutils Generic DTD: ../docutils.dtd
43 .. _Creating reStructuredText Directives:
44    ../../howto/rst-directives.html
47 -------------
48  Admonitions
49 -------------
51 .. _attention:
52 .. _caution:
53 .. _danger:
54 .. _error:
55 .. _hint:
56 .. _important:
57 .. _note:
58 .. _tip:
59 .. _warning:
61 Specific Admonitions
62 ====================
64 :Directive Types: "attention", "caution", "danger", "error", "hint",
65                   "important", "note", "tip", "warning", "admonition"
66 :Doctree Elements: attention, caution, danger, error, hint, important,
67                    note, tip, warning, admonition_, title
68 :Directive Arguments: None.
69 :Directive Options: `:class:`_, `:name:`_
70 :Directive Content: Interpreted as body elements.
72 Admonitions are specially marked "topics" that can appear anywhere an
73 ordinary body element can.  They contain arbitrary body elements.
74 Typically, an admonition is rendered as an offset block in a document,
75 sometimes outlined or shaded, with a title matching the admonition
76 type.  For example::
78     .. DANGER::
79        Beware killer rabbits!
81 This directive might be rendered something like this::
83     +------------------------+
84     |        !DANGER!        |
85     |                        |
86     | Beware killer rabbits! |
87     +------------------------+
89 The following admonition directives have been implemented:
91 - attention
92 - caution
93 - danger
94 - error
95 - hint
96 - important
97 - note
98 - tip
99 - warning
101 Any text immediately following the directive indicator (on the same
102 line and/or indented on following lines) is interpreted as a directive
103 block and is parsed for normal body elements.  For example, the
104 following "note" admonition directive contains one paragraph and a
105 bullet list consisting of two list items::
107     .. note:: This is a note admonition.
108        This is the second line of the first paragraph.
110        - The note contains all indented body elements
111          following.
112        - It includes this bullet list.
115 Generic Admonition
116 ==================
118 :Directive Type: "admonition"
119 :Doctree Elements: admonition_, title
120 :Directive Arguments: One, required (admonition title)
121 :Directive Options: Possible, see below.
122 :Directive Content: Interpreted as body elements.
124 This is a generic, titled admonition.  The title may be anything the
125 author desires.
127 The author-supplied title is also used as a `"classes"`_ attribute value
128 after being converted into a valid identifier form (down-cased;
129 non-alphanumeric characters converted to single hyphens; "admonition-"
130 prefixed).  For example, this admonition::
132     .. admonition:: And, by the way...
134        You can make up your own admonition too.
136 becomes the following document tree (pseudo-XML)::
138     <document source="test data">
139         <admonition classes="admonition-and-by-the-way">
140             <title>
141                 And, by the way...
142             <paragraph>
143                 You can make up your own admonition too.
145 The `common options`_ are recognized:
147 ``class`` : text
148     Overrides the computed `"classes"`_ attribute value.
150 ``name`` : text
151   Add `text` to the `"names"`_ attribute of the admonition element.
154 --------
155  Images
156 --------
158 There are two image directives: "image" and "figure".
161 Image
162 =====
164 :Directive Type: "image"
165 :Doctree Element: image_
166 :Directive Arguments: One, required (image URI).
167 :Directive Options: Possible.
168 :Directive Content: None.
170 An "image" is a simple picture::
172     .. image:: picture.png
174 Inline images can be defined with an "image" directive in a `substitution
175 definition`_
177 The URI for the image source file is specified in the directive
178 argument.  As with hyperlink targets, the image URI may begin on the
179 same line as the explicit markup start and target name, or it may
180 begin in an indented text block immediately following, with no
181 intervening blank lines.  If there are multiple lines in the link
182 block, they are stripped of leading and trailing whitespace and joined
183 together.
185 Optionally, the image link block may contain a flat field list, the
186 _`image options`.  For example::
188     .. image:: picture.jpeg
189        :height: 100px
190        :width: 200 px
191        :scale: 50 %
192        :alt: alternate text
193        :align: right
195 The following options are recognized:
197 ``alt`` : text
198     Alternate text: a short description of the image, displayed by
199     applications that cannot display images, or spoken by applications
200     for visually impaired users.
202 ``height`` : `length`_
203     The desired height of the image.
204     Used to reserve space or scale the image vertically.  When the "scale"
205     option is also specified, they are combined.  For example, a height of
206     200px and a scale of 50 is equivalent to a height of 100px with no scale.
208 ``width`` : `length`_ or `percentage`_ of the current line width
209     The width of the image.
210     Used to reserve space or scale the image horizontally.  As with "height"
211     above, when the "scale" option is also specified, they are combined.
213     .. _length: restructuredtext.html#length-units
214     .. _percentage: restructuredtext.html#percentage-units
216 ``scale`` : integer percentage (the "%" symbol is optional)
217     The uniform scaling factor of the image.  The default is "100 %", i.e.
218     no scaling.
220     If no "height" or "width" options are specified, the `Python Imaging
221     Library`_ (PIL) may be used to determine them, if it is installed and
222     the image file is available.
224 ``align`` : "top", "middle", "bottom", "left", "center", or "right"
225     The alignment of the image, equivalent to the HTML ``<img>`` tag's
226     "align" attribute.  The values "top", "middle", and "bottom"
227     control an image's vertical alignment (relative to the text
228     baseline); they are only useful for inline images (substitutions).
229     The values "left", "center", and "right" control an image's
230     horizontal alignment, allowing the image to float and have the
231     text flow around it.  The specific behavior depends upon the
232     browser or rendering software used.
234 ``target`` : text (URI or reference name)
235     Makes the image into a hyperlink reference ("clickable").  The
236     option argument may be a URI (relative or absolute), or a
237     `reference name`_ with underscore suffix (e.g. ```a name`_``).
239 and the common options `:class:`_ and `:name:`_.
241 .. _substitution definition: restructuredtext.html#substitution-definitions
244 Figure
245 ======
247 :Directive Type: "figure"
248 :Doctree Elements: figure_, image_, caption_, legend_
249 :Directive Arguments: One, required (image URI).
250 :Directive Options: Possible.
251 :Directive Content: Interpreted as the figure caption and an optional
252                     legend.
254 A "figure" consists of image_ data (including `image options`_), an optional
255 caption (a single paragraph), and an optional legend (arbitrary body
256 elements). For page-based output media, figures might float to a different
257 position if this helps the page layout.
260     .. figure:: picture.png
261        :scale: 50 %
262        :alt: map to buried treasure
264        This is the caption of the figure (a simple paragraph).
266        The legend consists of all elements after the caption.  In this
267        case, the legend consists of this paragraph and the following
268        table:
270        +-----------------------+-----------------------+
271        | Symbol                | Meaning               |
272        +=======================+=======================+
273        | .. image:: tent.png   | Campground            |
274        +-----------------------+-----------------------+
275        | .. image:: waves.png  | Lake                  |
276        +-----------------------+-----------------------+
277        | .. image:: peak.png   | Mountain              |
278        +-----------------------+-----------------------+
280 There must be blank lines before the caption paragraph and before the
281 legend.  To specify a legend without a caption, use an empty comment
282 ("..") in place of the caption.
284 The "figure" directive supports all of the options of the "image"
285 directive (see `image options`_ above). These options (except
286 "align") are passed on to the contained image.
288 ``align`` : "left", "center", or "right"
289     The horizontal alignment of the figure, allowing the image to
290     float and have the text flow around it.  The specific behavior
291     depends upon the browser or rendering software used.
293 In addition, the following options are recognized:
295 ``figwidth`` : "image", length_, or percentage_ of current line width
296     The width of the figure.
297     Limits the horizontal space used by the figure.
298     A special value of "image" is allowed, in which case the
299     included image's actual width is used (requires the `Python Imaging
300     Library`_). If the image file is not found or the required software is
301     unavailable, this option is ignored.
303     Sets the "width" attribute of the "figure" doctree element.
305     This option does not scale the included image; use the "width"
306     `image`_ option for that. ::
308         +---------------------------+
309         |        figure             |
310         |                           |
311         |<------ figwidth --------->|
312         |                           |
313         |  +---------------------+  |
314         |  |     image           |  |
315         |  |                     |  |
316         |  |<--- width --------->|  |
317         |  +---------------------+  |
318         |                           |
319         |The figure's caption should|
320         |wrap at this width.        |
321         +---------------------------+
323 ``figclass`` : text
324     Set a `"classes"`_ attribute value on the figure element.  See the
325     class_ directive below.
327 .. _Python Imaging Library: http://www.pythonware.com/products/pil/
330 ---------------
331  Body Elements
332 ---------------
334 Topic
335 =====
337 :Directive Type: "topic"
338 :Doctree Element: topic_
339 :Directive Arguments: 1, required (topic title).
340 :Directive Options: `:class:`_, `:name:`_
341 :Directive Content: Interpreted as the topic body.
343 A topic is like a block quote with a title, or a self-contained
344 section with no subsections.  Use the "topic" directive to indicate a
345 self-contained idea that is separate from the flow of the document.
346 Topics may occur anywhere a section or transition may occur.  Body
347 elements and topics may not contain nested topics.
349 The directive's sole argument is interpreted as the topic title; the
350 next line must be blank.  All subsequent lines make up the topic body,
351 interpreted as body elements.  For example::
353     .. topic:: Topic Title
355         Subsequent indented lines comprise
356         the body of the topic, and are
357         interpreted as body elements.
360 Sidebar
361 =======
363 :Directive Type: "sidebar"
364 :Doctree Element: sidebar_
365 :Directive Arguments: One, required (sidebar title).
366 :Directive Options: Possible (see below).
367 :Directive Content: Interpreted as the sidebar body.
369 Sidebars are like miniature, parallel documents that occur inside
370 other documents, providing related or reference material.  A sidebar
371 is typically offset by a border and "floats" to the side of the page;
372 the document's main text may flow around it.  Sidebars can also be
373 likened to super-footnotes; their content is outside of the flow of
374 the document's main text.
376 Sidebars may occur anywhere a section or transition may occur.  Body
377 elements (including sidebars) may not contain nested sidebars.
379 The directive's sole argument is interpreted as the sidebar title,
380 which may be followed by a subtitle option (see below); the next line
381 must be blank.  All subsequent lines make up the sidebar body,
382 interpreted as body elements.  For example::
384     .. sidebar:: Sidebar Title
385        :subtitle: Optional Sidebar Subtitle
387        Subsequent indented lines comprise
388        the body of the sidebar, and are
389        interpreted as body elements.
391 The following options are recognized:
393 ``subtitle`` : text
394     The sidebar's subtitle.
396 and the common options `:class:`_ and `:name:`_.
399 Line Block
400 ==========
402 .. admonition:: Deprecated
404    The "line-block" directive is deprecated.  Use the `line block
405    syntax`_ instead.
407    .. _line block syntax: restructuredtext.html#line-blocks
409 :Directive Type: "line-block"
410 :Doctree Element: line_block_
411 :Directive Arguments: None.
412 :Directive Options: `:class:`_, `:name:`_
413 :Directive Content: Becomes the body of the line block.
415 The "line-block" directive constructs an element where line breaks and
416 initial indentation is significant and inline markup is supported.  It
417 is equivalent to a `parsed literal block`_ with different rendering:
418 typically in an ordinary serif typeface instead of a
419 typewriter/monospaced face, and not automatically indented.  (Have the
420 line-block directive begin a block quote to get an indented line
421 block.)  Line blocks are useful for address blocks and verse (poetry,
422 song lyrics), where the structure of lines is significant.  For
423 example, here's a classic::
425     "To Ma Own Beloved Lassie: A Poem on her 17th Birthday", by
426     Ewan McTeagle (for Lassie O'Shea):
428         .. line-block::
430             Lend us a couple of bob till Thursday.
431             I'm absolutely skint.
432             But I'm expecting a postal order and I can pay you back
433                 as soon as it comes.
434             Love, Ewan.
438 .. _parsed-literal:
440 Parsed Literal Block
441 ====================
443 :Directive Type: "parsed-literal"
444 :Doctree Element: literal_block_
445 :Directive Arguments: None.
446 :Directive Options: `:class:`_, `:name:`_
447 :Directive Content: Becomes the body of the literal block.
449 Unlike an ordinary literal block, the "parsed-literal" directive
450 constructs a literal block where the text is parsed for inline markup.
451 It is equivalent to a `line block`_ with different rendering:
452 typically in a typewriter/monospaced typeface, like an ordinary
453 literal block.  Parsed literal blocks are useful for adding hyperlinks
454 to code examples.
456 However, care must be taken with the text, because inline markup is
457 recognized and there is no protection from parsing.  Backslash-escapes
458 may be necessary to prevent unintended parsing.  And because the
459 markup characters are removed by the parser, care must also be taken
460 with vertical alignment.  Parsed "ASCII art" is tricky, and extra
461 whitespace may be necessary.
463 For example, all the element names in this content model are links::
465     .. parsed-literal::
467        ( (title_, subtitle_?)?,
468          decoration_?,
469          (docinfo_, transition_?)?,
470          `%structure.model;`_ )
472 Code
473 ====
475 :Directive Type: "code"
476 :Doctree Element: literal_block_, `inline elements`_
477 :Directive Arguments: One, optional (formal language).
478 :Directive Options: name, class, number-lines.
479 :Directive Content: Becomes the body of the literal block.
480 :Configuration Setting: syntax_highlight_.
482 (New in Docutils 0.9)
484 The "code" directive constructs a literal block. If the code language is
485 specified, the content is parsed by the Pygments_ syntax highlighter and
486 tokens are stored in nested `inline elements`_ with class arguments
487 according to their syntactic category. The actual highlighting can be
488 customized with a style-sheet (e.g. one `generated by Pygments`__).
490 The parsing can be turned off with the syntax_highlight_ configuration
491 setting and command line option or by specifying the language as `:class:`_
492 option instead of directive argument. This also avoids warnings
493 when Pygments_ is not installed or the language is not in the
494 `supported languages and markup formats`_.
496 For inline code, use the `"code" role`_.
498 __   http://pygments.org/docs/cmdline/#generating-styles
499 .. _Pygments: http://pygments.org/
500 .. _syntax_highlight: ../../user/config.html#syntax-highlight
501 .. _supported languages and markup formats: http://pygments.org/languages/
502 .. _"code" role: roles.html#code
505 The following options are recognized:
507 ``number-lines`` : [start line number]
508     Precede every line with a line number.
509     The optional argument is the number of the first line (defaut 1).
511 and the common options `:class:`_ and `:name:`_.
513 Example::
514   The content of the following directive ::
516    .. code:: python
518     def my_function():
519         "just a test"
520         print 8/2
522   is parsed and marked up as Python source code.
525 Math
526 ====
528 :Directive Type: "math"
529 :Doctree Element: math_block_
530 :Directive Arguments: One, optional: prepended to content.
531 :Directive Options: `:class:`_, `:name:`_
532 :Directive Content: Interpreted as math block(s).
533                     Content blocks separated by a blank line are put in
534                     separate math-block doctree elements.
535 :Configuration Setting: math_output_
537 (New in Docutils 0.8)
539 The "math" directive inserts block(s) with mathematical content
540 (display formulas, equations) into the document. The input format is
541 *LaTeX math syntax* (see, e.g. the `Short Math Guide`_) with support
542 for Unicode symbols, for example::
544   .. math::
546     α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)
548 For inline math, use the `"math" role`_.
550 Support for math may be limited by the output format. If a writer does
551 not support math typesetting, the content is inserted verbatim.
552 For HTML, the output format can be set with the `math_output`_
553 configuration setting (or the corresponding ``--math-output`` command
554 line option).
556 .. _Short Math Guide: ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
557 .. _"math" role: roles.html#math
558 .. _math_output: ../../user/config.html#math-output
560 Rubric
561 ======
563 :Directive Type: "rubric"
564 :Doctree Element: rubric_
565 :Directive Arguments: 1, required (rubric text).
566 :Directive Options: `:class:`_, `:name:`_
567 :Directive Content: None.
571      rubric n. 1. a title, heading, or the like, in a manuscript,
572      book, statute, etc., written or printed in red or otherwise
573      distinguished from the rest of the text. ...
575      -- Random House Webster's College Dictionary, 1991
577 The "rubric" directive inserts a "rubric" element into the document
578 tree.  A rubric is like an informal heading that doesn't correspond to
579 the document's structure.
582 Epigraph
583 ========
585 :Directive Type: "epigraph"
586 :Doctree Element: block_quote_
587 :Directive Arguments: None.
588 :Directive Options: None.
589 :Directive Content: Interpreted as the body of the block quote.
591 An epigraph is an apposite (suitable, apt, or pertinent) short
592 inscription, often a quotation or poem, at the beginning of a document
593 or section.
595 The "epigraph" directive produces an "epigraph"-class block quote.
596 For example, this input::
598      .. epigraph::
600         No matter where you go, there you are.
602         -- Buckaroo Banzai
604 becomes this document tree fragment::
606     <block_quote classes="epigraph">
607         <paragraph>
608             No matter where you go, there you are.
609         <attribution>
610             Buckaroo Banzai
613 Highlights
614 ==========
616 :Directive Type: "highlights"
617 :Doctree Element: block_quote_
618 :Directive Arguments: None.
619 :Directive Options: None.
620 :Directive Content: Interpreted as the body of the block quote.
622 Highlights summarize the main points of a document or section, often
623 consisting of a list.
625 The "highlights" directive produces a "highlights"-class block quote.
626 See Epigraph_ above for an analogous example.
629 Pull-Quote
630 ==========
632 :Directive Type: "pull-quote"
633 :Doctree Element: block_quote_
634 :Directive Arguments: None.
635 :Directive Options: None.
636 :Directive Content: Interpreted as the body of the block quote.
638 A pull-quote is a small selection of text "pulled out and quoted",
639 typically in a larger typeface.  Pull-quotes are used to attract
640 attention, especially in long articles.
642 The "pull-quote" directive produces a "pull-quote"-class block quote.
643 See Epigraph_ above for an analogous example.
646 Compound Paragraph
647 ==================
649 :Directive Type: "compound"
650 :Doctree Element: compound_
651 :Directive Arguments: None.
652 :Directive Options: `:class:`_, `:name:`_
653 :Directive Content: Interpreted as body elements.
655 (New in Docutils 0.3.6)
657 The "compound" directive is used to create a compound paragraph, which
658 is a single logical paragraph containing multiple physical body
659 elements such as simple paragraphs, literal blocks, tables, lists,
660 etc., instead of directly containing text and inline elements.  For
661 example::
663     .. compound::
665        The 'rm' command is very dangerous.  If you are logged
666        in as root and enter ::
668            cd /
669            rm -rf *
671        you will erase the entire contents of your file system.
673 In the example above, a literal block is "embedded" within a sentence
674 that begins in one physical paragraph and ends in another.
676 .. note::
678    The "compound" directive is *not* a generic block-level container
679    like HTML's ``<div>`` element.  Do not use it only to group a
680    sequence of elements, or you may get unexpected results.
682    If you need a generic block-level container, please use the
683    container_ directive, described below.
685 Compound paragraphs are typically rendered as multiple distinct text
686 blocks, with the possibility of variations to emphasize their logical
687 unity:
689 * If paragraphs are rendered with a first-line indent, only the first
690   physical paragraph of a compound paragraph should have that indent
691   -- second and further physical paragraphs should omit the indents;
692 * vertical spacing between physical elements may be reduced;
693 * and so on.
696 Container
697 =========
699 :Directive Type: "container"
700 :Doctree Element: container_
701 :Directive Arguments: One or more, optional (class names).
702 :Directive Options: `:name:`_
703 :Directive Content: Interpreted as body elements.
705 (New in Docutils 0.3.10)
707 The "container" directive surrounds its contents (arbitrary body
708 elements) with a generic block-level "container" element.  Combined
709 with the optional "classes_" attribute argument(s), this is an
710 extension mechanism for users & applications.  For example::
712     .. container:: custom
714        This paragraph might be rendered in a custom way.
716 Parsing the above results in the following pseudo-XML::
718     <container classes="custom">
719         <paragraph>
720             This paragraph might be rendered in a custom way.
722 The "container" directive is the equivalent of HTML's ``<div>``
723 element.  It may be used to group a sequence of elements for user- or
724 application-specific purposes.
728 --------
729  Tables
730 --------
732 Formal tables need more structure than the reStructuredText syntax
733 supplies.  Tables may be given titles with the table_ directive.
734 Sometimes reStructuredText tables are inconvenient to write, or table
735 data in a standard format is readily available.  The csv-table_
736 directive supports CSV data.
739 Table
740 =====
742 :Directive Type: "table"
743 :Doctree Element: table_
744 :Directive Arguments: 1, optional (table title).
745 :Directive Options: `:class:`_, `:name:`_
746 :Directive Content: A normal reStructuredText table.
748 (New in Docutils 0.3.1)
750 The "table" directive is used to create a titled table, to associate a
751 title with a table::
753     .. table:: Truth table for "not"
755        =====  =====
756          A    not A
757        =====  =====
758        False  True
759        True   False
760        =====  =====
763 .. _csv-table:
765 CSV Table
766 =========
768 :Directive Type: "csv-table"
769 :Doctree Element: table_
770 :Directive Arguments: 1, optional (table title).
771 :Directive Options: Possible (see below).
772 :Directive Content: A CSV (comma-separated values) table.
774 .. WARNING::
776    The "csv-table" directive's ":file:" and ":url:" options represent
777    a potential security holes.  They can be disabled with the
778    "file_insertion_enabled_" runtime setting.
780 (New in Docutils 0.3.4)
782 The "csv-table" directive is used to create a table from CSV
783 (comma-separated values) data.  CSV is a common data format generated
784 by spreadsheet applications and commercial databases.  The data may be
785 internal (an integral part of the document) or external (a separate
786 file).
788 Example::
790     .. csv-table:: Frozen Delights!
791        :header: "Treat", "Quantity", "Description"
792        :widths: 15, 10, 30
794        "Albatross", 2.99, "On a stick!"
795        "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
796        crunchy, now would it?"
797        "Gannet Ripple", 1.99, "On a stick!"
799 Block markup and inline markup within cells is supported.  Line ends
800 are recognized within cells.
802 Working limitations:
804 * Whitespace delimiters are supported only for external CSV files.
806 * There is no support for checking that the number of columns in each
807   row is the same.  However, this directive supports CSV generators
808   that do not insert "empty" entries at the end of short rows, by
809   automatically adding empty entries.
811   .. Add "strict" option to verify input?
813 The following options are recognized:
815 ``widths`` : integer [, integer...]
816     A comma- or space-separated list of relative column widths.  The
817     default is equal-width columns (100%/#columns).
819 ``header-rows`` : integer
820     The number of rows of CSV data to use in the table header.
821     Defaults to 0.
823 ``stub-columns`` : integer
824     The number of table columns to use as stubs (row titles, on the
825     left).  Defaults to 0.
827 ``header`` : CSV data
828     Supplemental data for the table header, added independently of and
829     before any ``header-rows`` from the main CSV data.  Must use the
830     same CSV format as the main CSV data.
832 ``file`` : string (newlines removed)
833     The local filesystem path to a CSV data file.
835 ``url`` : string (whitespace removed)
836     An Internet URL reference to a CSV data file.
838 ``encoding`` : name of text encoding
839     The text encoding of the external CSV data (file or URL).
840     Defaults to the document's encoding (if specified).
842 ``delim`` : char | "tab" | "space"
843     A one-character string used to separate fields.  Defaults to ``,``
844     (comma).  May be specified as a Unicode code point; see the
845     unicode_ directive for syntax details.
847 ``quote`` : char
848     A one-character string used to quote elements containing the
849     delimiter or which start with the quote character.  Defaults to
850     ``"`` (quote).  May be specified as a Unicode code point; see the
851     unicode_ directive for syntax details.
853 ``keepspace`` : flag
854     Treat whitespace immediately following the delimiter as
855     significant.  The default is to ignore such whitespace.
857 ``escape`` : char
858     A one-character string used to escape the delimiter or quote
859     characters.  May be specified as a Unicode code point; see the
860     unicode_ directive for syntax details.  Used when the delimiter is
861     used in an unquoted field, or when quote characters are used
862     within a field.  The default is to double-up the character,
863     e.g. "He said, ""Hi!"""
865     .. Add another possible value, "double", to explicitly indicate
866        the default case?
868 and the common options `:class:`_ and `:name:`_.
871 List Table
872 ==========
874 :Directive Type: "list-table"
875 :Doctree Element: table_
876 :Directive Arguments: 1, optional (table title).
877 :Directive Options: Possible (see below).
878 :Directive Content: A uniform two-level bullet list.
880 (New in Docutils 0.3.8.  This is an initial implementation; `further
881 ideas`__ may be implemented in the future.)
883 __ ../../dev/rst/alternatives.html#list-driven-tables
885 The "list-table" directive is used to create a table from data in a
886 uniform two-level bullet list.  "Uniform" means that each sublist
887 (second-level list) must contain the same number of list items.
889 Example::
891     .. list-table:: Frozen Delights!
892        :widths: 15 10 30
893        :header-rows: 1
895        * - Treat
896          - Quantity
897          - Description
898        * - Albatross
899          - 2.99
900          - On a stick!
901        * - Crunchy Frog
902          - 1.49
903          - If we took the bones out, it wouldn't be
904            crunchy, now would it?
905        * - Gannet Ripple
906          - 1.99
907          - On a stick!
909 The following options are recognized:
911 ``widths`` : integer [integer...]
912     A comma- or space-separated list of relative column widths.  The
913     default is equal-width columns (100%/#columns).
915 ``header-rows`` : integer
916     The number of rows of list data to use in the table header.
917     Defaults to 0.
919 ``stub-columns`` : integer
920     The number of table columns to use as stubs (row titles, on the
921     left).  Defaults to 0.
923 and the common options `:class:`_ and `:name:`_.
926 ----------------
927  Document Parts
928 ----------------
930 .. _contents:
932 Table of Contents
933 =================
935 :Directive Type: "contents"
936 :Doctree Elements: pending_, topic_
937 :Directive Arguments: One, optional: title.
938 :Directive Options: Possible.
939 :Directive Content: None.
941 The "contents" directive generates a table of contents (TOC) in a
942 topic_.  Topics, and therefore tables of contents, may occur anywhere
943 a section or transition may occur.  Body elements and topics may not
944 contain tables of contents.
946 Here's the directive in its simplest form::
948     .. contents::
950 Language-dependent boilerplate text will be used for the title.  The
951 English default title text is "Contents".
953 An explicit title may be specified::
955     .. contents:: Table of Contents
957 The title may span lines, although it is not recommended::
959     .. contents:: Here's a very long Table of
960        Contents title
962 Options may be specified for the directive, using a field list::
964     .. contents:: Table of Contents
965        :depth: 2
967 If the default title is to be used, the options field list may begin
968 on the same line as the directive marker::
970     .. contents:: :depth: 2
972 The following options are recognized:
974 ``depth`` : integer
975     The number of section levels that are collected in the table of
976     contents.  The default is unlimited depth.
978 ``local`` : flag (empty)
979     Generate a local table of contents.  Entries will only include
980     subsections of the section in which the directive is given.  If no
981     explicit title is given, the table of contents will not be titled.
983 ``backlinks`` : "entry" or "top" or "none"
984     Generate links from section headers back to the table of contents
985     entries, the table of contents itself, or generate no backlinks.
987 ``class`` : text
988     Set a `"classes"`_ attribute value on the topic element.  See the
989     class_ directive below.
992 .. _sectnum:
993 .. _section-autonumbering:
995 Automatic Section Numbering
996 ===========================
998 :Directive Type: "sectnum" or "section-autonumbering" (synonyms)
999 :Doctree Elements: pending_, generated_
1000 :Directive Arguments: None.
1001 :Directive Options: Possible.
1002 :Directive Content: None.
1003 :Configuration Setting: sectnum_xform_
1005 The "sectnum" (or "section-autonumbering") directive automatically numbers
1006 sections and subsections in a document (if not disabled by the
1007 ``--no-section-numbering`` command line option or the `sectnum_xform`_
1008 configuration setting).
1010 Section numbers are of the "multiple enumeration" form, where each
1011 level has a number, separated by periods.  For example, the title of section
1012 1, subsection 2, subsubsection 3 would have "1.2.3" prefixed.
1014 The "sectnum" directive does its work in two passes: the initial parse
1015 and a transform.  During the initial parse, a "pending" element is
1016 generated which acts as a placeholder, storing any options internally.
1017 At a later stage in the processing, the "pending" element triggers a
1018 transform, which adds section numbers to titles.  Section numbers are
1019 enclosed in a "generated" element, and titles have their "auto"
1020 attribute set to "1".
1022 The following options are recognized:
1024 ``depth`` : integer
1025     The number of section levels that are numbered by this directive.
1026     The default is unlimited depth.
1028 ``prefix`` : string
1029     An arbitrary string that is prefixed to the automatically
1030     generated section numbers.  It may be something like "3.2.", which
1031     will produce "3.2.1", "3.2.2", "3.2.2.1", and so on.  Note that
1032     any separating punctuation (in the example, a period, ".") must be
1033     explicitly provided.  The default is no prefix.
1035 ``suffix`` : string
1036     An arbitrary string that is appended to the automatically
1037     generated section numbers.  The default is no suffix.
1039 ``start`` : integer
1040     The value that will be used for the first section number.
1041     Combined with ``prefix``, this may be used to force the right
1042     numbering for a document split over several source files.  The
1043     default is 1.
1045 .. _sectnum_xform: ../../user/config.html#sectnum-xform
1048 .. _header:
1049 .. _footer:
1051 Document Header & Footer
1052 ========================
1054 :Directive Types: "header" and "footer"
1055 :Doctree Elements: decoration_, header, footer
1056 :Directive Arguments: None.
1057 :Directive Options: None.
1058 :Directive Content: Interpreted as body elements.
1060 (New in Docutils 0.3.8)
1062 The "header" and "footer" directives create document decorations,
1063 useful for page navigation, notes, time/datestamp, etc.  For example::
1065     .. header:: This space for rent.
1067 This will add a paragraph to the document header, which will appear at
1068 the top of the generated web page or at the top of every printed page.
1070 These directives may be used multiple times, cumulatively.  There is
1071 currently support for only one header and footer.
1073 .. note::
1075    While it is possible to use the "header" and "footer" directives to
1076    create navigational elements for web pages, you should be aware
1077    that Docutils is meant to be used for *document* processing, and
1078    that a navigation bar is not typically part of a document.
1080    Thus, you may soon find Docutils' abilities to be insufficient for
1081    these purposes.  At that time, you should consider using a
1082    documentation generator like Sphinx_ rather than the "header" and
1083    "footer" directives.
1085    .. _Sphinx: http://sphinx-doc.org/
1087 In addition to the use of these directives to populate header and
1088 footer content, content may also be added automatically by the
1089 processing system.  For example, if certain runtime settings are
1090 enabled, the document footer is populated with processing information
1091 such as a datestamp, a link to `the Docutils website`_, etc.
1093 .. _the Docutils website: http://docutils.sourceforge.net
1096 ------------
1097  References
1098 ------------
1100 .. _target-notes:
1102 Target Footnotes
1103 ================
1105 :Directive Type: "target-notes"
1106 :Doctree Elements: pending_, footnote_, footnote_reference_
1107 :Directive Arguments: None.
1108 :Directive Options: `:class:`_, `:name:`_
1109 :Directive Options: Possible.
1110 :Directive Content: None.
1112 The "target-notes" directive creates a footnote for each external
1113 target in the text, and corresponding footnote references after each
1114 reference.  For every explicit target (of the form, ``.. _target name:
1115 URL``) in the text, a footnote will be generated containing the
1116 visible URL as content.
1119 Footnotes
1120 =========
1122 **NOT IMPLEMENTED YET**
1124 :Directive Type: "footnotes"
1125 :Doctree Elements: pending_, topic_
1126 :Directive Arguments: None?
1127 :Directive Options: Possible?
1128 :Directive Content: None.
1133 Citations
1134 =========
1136 **NOT IMPLEMENTED YET**
1138 :Directive Type: "citations"
1139 :Doctree Elements: pending_, topic_
1140 :Directive Arguments: None?
1141 :Directive Options: Possible?
1142 :Directive Content: None.
1147 ---------------
1148  HTML-Specific
1149 ---------------
1151 Meta
1152 ====
1154 :Directive Type: "meta"
1155 :Doctree Element: meta (non-standard)
1156 :Directive Arguments: None.
1157 :Directive Options: None.
1158 :Directive Content: Must contain a flat field list.
1160 The "meta" directive is used to specify HTML metadata stored in HTML
1161 META tags.  "Metadata" is data about data, in this case data about web
1162 pages.  Metadata is used to describe and classify web pages in the
1163 World Wide Web, in a form that is easy for search engines to extract
1164 and collate.
1166 Within the directive block, a flat field list provides the syntax for
1167 metadata.  The field name becomes the contents of the "name" attribute
1168 of the META tag, and the field body (interpreted as a single string
1169 without inline markup) becomes the contents of the "content"
1170 attribute.  For example::
1172     .. meta::
1173        :description: The reStructuredText plaintext markup language
1174        :keywords: plaintext, markup language
1176 This would be converted to the following HTML::
1178     <meta name="description"
1179         content="The reStructuredText plaintext markup language">
1180     <meta name="keywords" content="plaintext, markup language">
1182 Support for other META attributes ("http-equiv", "scheme", "lang",
1183 "dir") are provided through field arguments, which must be of the form
1184 "attr=value"::
1186     .. meta::
1187        :description lang=en: An amusing story
1188        :description lang=fr: Une histoire amusante
1190 And their HTML equivalents::
1192     <meta name="description" lang="en" content="An amusing story">
1193     <meta name="description" lang="fr" content="Une histoire amusante">
1195 Some META tags use an "http-equiv" attribute instead of the "name"
1196 attribute.  To specify "http-equiv" META tags, simply omit the name::
1198     .. meta::
1199        :http-equiv=Content-Type: text/html; charset=ISO-8859-1
1201 HTML equivalent::
1203     <meta http-equiv="Content-Type"
1204          content="text/html; charset=ISO-8859-1">
1207 Imagemap
1208 ========
1210 **NOT IMPLEMENTED YET**
1212 Non-standard element: imagemap.
1215 -----------------------------------------
1216  Directives for Substitution Definitions
1217 -----------------------------------------
1219 The directives in this section may only be used in substitution
1220 definitions.  They may not be used directly, in standalone context.
1221 The `image`_ directive may be used both in substitution definitions
1222 and in the standalone context.
1225 .. _replace:
1227 Replacement Text
1228 ================
1230 :Directive Type: "replace"
1231 :Doctree Element: Text & `inline elements`_
1232 :Directive Arguments: None.
1233 :Directive Options: None.
1234 :Directive Content: A single paragraph; may contain inline markup.
1236 The "replace" directive is used to indicate replacement text for a
1237 substitution reference.  It may be used within substitution
1238 definitions only.  For example, this directive can be used to expand
1239 abbreviations::
1241     .. |reST| replace:: reStructuredText
1243     Yes, |reST| is a long word, so I can't blame anyone for wanting to
1244     abbreviate it.
1246 As reStructuredText doesn't support nested inline markup, the only way
1247 to create a reference with styled text is to use substitutions with
1248 the "replace" directive::
1250     I recommend you try |Python|_.
1252     .. |Python| replace:: Python, *the* best language around
1253     .. _Python: http://www.python.org/
1256 .. _unicode:
1258 Unicode Character Codes
1259 =======================
1261 :Directive Type: "unicode"
1262 :Doctree Element: Text
1263 :Directive Arguments: One or more, required (Unicode character codes,
1264                       optional text, and comments).
1265 :Directive Options: Possible.
1266 :Directive Content: None.
1268 The "unicode" directive converts Unicode character codes (numerical
1269 values) to characters, and may be used in substitution definitions
1270 only.
1272 The arguments, separated by spaces, can be:
1274 * **character codes** as
1276   - decimal numbers or
1278   - hexadecimal numbers, prefixed by ``0x``, ``x``, ``\x``, ``U+``,
1279     ``u``, or ``\u`` or as XML-style hexadecimal character entities,
1280     e.g. ``&#x1a2b;``
1282 * **text**, which is used as-is.
1284 Text following " .. " is a comment and is ignored.  The spaces between
1285 the arguments are ignored and thus do not appear in the output.
1286 Hexadecimal codes are case-insensitive.
1288 For example, the following text::
1290     Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1291     all rights reserved.
1293     .. |copy| unicode:: 0xA9 .. copyright sign
1294     .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1295        .. with trademark sign
1296     .. |---| unicode:: U+02014 .. em dash
1297        :trim:
1299 results in:
1301     Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1302     all rights reserved.
1304     .. |copy| unicode:: 0xA9 .. copyright sign
1305     .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1306        .. with trademark sign
1307     .. |---| unicode:: U+02014 .. em dash
1308        :trim:
1310 The following options are recognized:
1312 ``ltrim`` : flag
1313     Whitespace to the left of the substitution reference is removed.
1315 ``rtrim`` : flag
1316     Whitespace to the right of the substitution reference is removed.
1318 ``trim`` : flag
1319     Equivalent to ``ltrim`` plus ``rtrim``; whitespace on both sides
1320     of the substitution reference is removed.
1323 Date
1324 ====
1326 :Directive Type: "date"
1327 :Doctree Element: Text
1328 :Directive Arguments: One, optional (date format).
1329 :Directive Options: None.
1330 :Directive Content: None.
1332 The "date" directive generates the current local date and inserts it
1333 into the document as text.  This directive may be used in substitution
1334 definitions only.
1336 The optional directive content is interpreted as the desired date
1337 format, using the same codes as Python's time.strftime function.  The
1338 default format is "%Y-%m-%d" (ISO 8601 date), but time fields can also
1339 be used.  Examples::
1341     .. |date| date::
1342     .. |time| date:: %H:%M
1344     Today's date is |date|.
1346     This document was generated on |date| at |time|.
1349 ---------------
1350  Miscellaneous
1351 ---------------
1353 .. _include:
1355 Including an External Document Fragment
1356 =======================================
1358 :Directive Type: "include"
1359 :Doctree Elements: Depend on data being included
1360                    (literal_block_ with ``code`` or ``literal`` option).
1361 :Directive Arguments: One, required (path to the file to include).
1362 :Directive Options: Possible.
1363 :Directive Content: None.
1364 :Configuration Setting: file_insertion_enabled_
1366 .. WARNING::
1368    The "include" directive represents a potential security hole.  It
1369    can be disabled with the "file_insertion_enabled_" runtime setting.
1371    .. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
1373 The "include" directive reads a text file. The directive argument is
1374 the path to the file to be included, relative to the document
1375 containing the directive. Unless the options ``literal`` or ``code``
1376 are given, the file is parsed in the current document's context at the
1377 point of the directive. For example::
1379     This first example will be parsed at the document level, and can
1380     thus contain any construct, including section headers.
1382     .. include:: inclusion.txt
1384     Back in the main document.
1386         This second example will be parsed in a block quote context.
1387         Therefore it may only contain body elements.  It may not
1388         contain section headers.
1390         .. include:: inclusion.txt
1392 If an included document fragment contains section structure, the title
1393 adornments must match those of the master document.
1395 Standard data files intended for inclusion in reStructuredText
1396 documents are distributed with the Docutils source code, located in
1397 the "docutils" package in the ``docutils/parsers/rst/include``
1398 directory.  To access these files, use the special syntax for standard
1399 "include" data files, angle brackets around the file name::
1401     .. include:: <isonum.txt>
1403 The current set of standard "include" data files consists of sets of
1404 substitution definitions.  See `reStructuredText Standard Definition
1405 Files`__ for details.
1407 __ definitions.html
1409 The following options are recognized:
1411 ``start-line`` : integer
1412     Only the content starting from this line will be included.
1413     (As usual in Python, the first line has index 0 and negative values
1414     count from the end.)
1416 ``end-line`` : integer
1417     Only the content up to (but excluding) this line will be included.
1419 ``start-after`` : text to find in the external data file
1420     Only the content after the first occurrence of the specified text
1421     will be included.
1423 ``end-before`` : text to find in the external data file
1424     Only the content before the first occurrence of the specified text
1425     (but after any ``after`` text) will be included.
1427 ``literal`` : flag (empty)
1428     The entire included text is inserted into the document as a single
1429     literal block.
1431 ``code`` : formal language (optional)
1432     The argument and the content of the included file are passed to
1433     the code_ directive (useful for program listings).
1434     (New in Docutils 0.9)
1436 ``number-lines`` : [start line number]
1437     Precede every code line with a line number.
1438     The optional argument is the number of the first line (defaut 1).
1439     Works only with ``code`` or ``literal``.
1440     (New in Docutils 0.9)
1442 ``encoding`` : name of text encoding
1443     The text encoding of the external data file.  Defaults to the
1444     document's input_encoding_.
1446     .. _input_encoding: ../../user/config.html#input-encoding
1448 ``tab-width`` :  integer
1449     Number of spaces for hard tab expansion.
1450     A negative value prevents expansion of hard tabs. Defaults to the
1451     tab_width_ configuration setting.
1453     .. _tab_width: ../../user/config.html#tab-width
1456 With ``code`` or ``literal`` the common options `:class:`_ and
1457 `:name:`_ are recognized as well.
1459 Combining ``start/end-line`` and ``start-after/end-before`` is possible. The
1460 text markers will be searched in the specified lines (further limiting the
1461 included content).
1463 .. _raw-directive:
1465 Raw Data Pass-Through
1466 =====================
1468 :Directive Type: "raw"
1469 :Doctree Element: raw_
1470 :Directive Arguments: One or more, required (output format types).
1471 :Directive Options: Possible.
1472 :Directive Content: Stored verbatim, uninterpreted.  None (empty) if a
1473                     "file" or "url" option given.
1474 :Configuration Setting: raw_enabled_
1476 .. WARNING::
1478    The "raw" directive represents a potential security hole.  It can
1479    be disabled with the "raw_enabled_" or "file_insertion_enabled_"
1480    runtime settings.
1482    .. _raw_enabled: ../../user/config.html#raw-enabled
1484 .. Caution::
1486    The "raw" directive is a stop-gap measure allowing the author to
1487    bypass reStructuredText's markup.  It is a "power-user" feature
1488    that should not be overused or abused.  The use of "raw" ties
1489    documents to specific output formats and makes them less portable.
1491    If you often need to use the "raw" directive or a "raw"-derived
1492    interpreted text role, that is a sign either of overuse/abuse or
1493    that functionality may be missing from reStructuredText.  Please
1494    describe your situation in a message to the Docutils-users_ mailing
1495    list.
1497 .. _Docutils-users: ../../user/mailing-lists.html#docutils-users
1499 The "raw" directive indicates non-reStructuredText data that is to be
1500 passed untouched to the Writer.  The names of the output formats are
1501 given in the directive arguments.  The interpretation of the raw data
1502 is up to the Writer.  A Writer may ignore any raw output not matching
1503 its format.
1505 For example, the following input would be passed untouched by an HTML
1506 Writer::
1508     .. raw:: html
1510        <hr width=50 size=10>
1512 A LaTeX Writer could insert the following raw content into its
1513 output stream::
1515     .. raw:: latex
1517        \setlength{\parindent}{0pt}
1519 Raw data can also be read from an external file, specified in a
1520 directive option.  In this case, the content block must be empty.  For
1521 example::
1523     .. raw:: html
1524        :file: inclusion.html
1526 Inline equivalents of the "raw" directive can be defined via
1527 `custom interpreted text roles`_ derived from the `"raw" role`_.
1529 The following options are recognized:
1531 ``file`` : string (newlines removed)
1532     The local filesystem path of a raw data file to be included.
1534 ``url`` : string (whitespace removed)
1535     An Internet URL reference to a raw data file to be included.
1537 ``encoding`` : name of text encoding
1538     The text encoding of the external raw data (file or URL).
1539     Defaults to the document's encoding (if specified).
1541 .. _"raw" role: roles.html#raw
1544 .. _classes:
1546 Class
1547 =====
1549 :Directive Type: "class"
1550 :Doctree Element: pending_
1551 :Directive Arguments: One or more, required (class names / attribute
1552                       values).
1553 :Directive Options: None.
1554 :Directive Content: Optional.  If present, it is interpreted as body
1555                     elements.
1557 The "class" directive sets the `"classes"`_ attribute value on its content
1558 or on the first immediately following non-comment element [#]_.  For
1559 details of the "classes" attribute, see `its entry`__ in `The Docutils
1560 Document Tree`_.
1562 The directive argument consists of one or more space-separated class
1563 names. The names are transformed to conform to the regular expression
1564 ``[a-z](-?[a-z0-9]+)*`` by converting
1566 * alphabetic characters to lowercase,
1567 * accented characters to the base character,
1568 * non-alphanumeric characters to hyphens,
1569 * consecutive hyphens into one hyphen.
1571 For example "Rot-Gelb.Blau Grün:+2008" becomes "rot-gelb-blau grun-2008".
1572 (For the rationale_, see below.)
1574 __ ../doctree.html#classes
1576 Examples::
1578     .. class:: special
1580     This is a "special" paragraph.
1582     .. class:: exceptional remarkable
1584     An Exceptional Section
1585     ======================
1587     This is an ordinary paragraph.
1589     .. class:: multiple
1591        First paragraph.
1593        Second paragraph.
1595 The text above is parsed and transformed into this doctree fragment::
1597     <paragraph classes="special">
1598         This is a "special" paragraph.
1599     <section classes="exceptional remarkable">
1600         <title>
1601             An Exceptional Section
1602         <paragraph>
1603             This is an ordinary paragraph.
1604         <paragraph classes="multiple">
1605             First paragraph.
1606         <paragraph classes="multiple">
1607             Second paragraph.
1609 .. [#] To set a "classes" attribute value on a block quote, the
1610    "class" directive must be followed by an empty comment::
1612        .. class:: highlights
1613        ..
1615            Block quote text.
1617    Without the empty comment, the indented text would be interpreted as the
1618    "class" directive's content, and the classes would be applied to each
1619    element (paragraph, in this case) individually, instead of to the block
1620    quote as a whole.
1622 .. _rationale:
1624 .. topic:: Rationale for "classes" Attribute Value Conversion
1627     Docutils identifiers are converted to conform to the regular
1628     expression ``[a-z](-?[a-z0-9]+)*``.  For HTML + CSS compatibility,
1629     identifiers (the "classes" and "id" attributes) should have no
1630     underscores, colons, or periods.  Hyphens may be used.
1632     - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:
1634           ID and NAME tokens must begin with a letter ([A-Za-z]) and
1635           may be followed by any number of letters, digits ([0-9]),
1636           hyphens ("-"), underscores ("_"), colons (":"), and periods
1637           (".").
1639     - The `CSS1 spec`_ defines identifiers based on the "name" token
1640       ("flex" tokenizer notation below; "latin1" and "escape" 8-bit
1641       characters have been replaced with XML entities)::
1643           unicode     \\[0-9a-f]{1,4}
1644           latin1      [&iexcl;-&yuml;]
1645           escape      {unicode}|\\[ -~&iexcl;-&yuml;]
1646           nmchar      [-A-Za-z0-9]|{latin1}|{escape}
1647           name        {nmchar}+
1649     The CSS rule does not include underscores ("_"), colons (":"), or
1650     periods ("."), therefore "classes" and "id" attributes should not
1651     contain these characters.  Combined with HTML's requirements (the
1652     first character must be a letter; no "unicode", "latin1", or
1653     "escape" characters), this results in the regular expression
1654     ``[A-Za-z][-A-Za-z0-9]*``. Docutils adds a normalisation by
1655     downcasing and merge of consecutive hyphens.
1657     .. _HTML 4.01 spec: http://www.w3.org/TR/html401/
1658     .. _CSS1 spec: http://www.w3.org/TR/REC-CSS1
1661 .. _role:
1663 Custom Interpreted Text Roles
1664 =============================
1666 :Directive Type: "role"
1667 :Doctree Element: None; affects subsequent parsing.
1668 :Directive Arguments: Two; one required (new role name), one optional
1669                       (base role name, in parentheses).
1670 :Directive Options: Possible (depends on base role).
1671 :Directive Content: depends on base role.
1673 (New in Docutils 0.3.2)
1675 The "role" directive dynamically creates a custom interpreted text
1676 role and registers it with the parser.  This means that after
1677 declaring a role like this::
1679     .. role:: custom
1681 the document may use the new "custom" role::
1683     An example of using :custom:`interpreted text`
1685 This will be parsed into the following document tree fragment::
1687     <paragraph>
1688         An example of using
1689         <inline classes="custom">
1690             interpreted text
1692 The role must be declared in a document before it can be used.
1694 The new role may be based on an existing role, specified as a second
1695 argument in parentheses (whitespace optional)::
1697     .. role:: custom(emphasis)
1699     :custom:`text`
1701 The parsed result is as follows::
1703     <paragraph>
1704         <emphasis classes="custom">
1705             text
1707 A special case is the `"raw" role`_: derived roles enable
1708 inline `raw data pass-through`_, e.g.::
1710    .. role:: raw-role(raw)
1711       :format: html latex
1713    :raw-role:`raw text`
1715 If no base role is explicitly specified, a generic custom role is
1716 automatically used.  Subsequent interpreted text will produce an
1717 "inline" element with a `"classes"`_ attribute, as in the first example
1718 above.
1720 With most roles, the ":class:" option can be used to set a "classes"
1721 attribute that is different from the role name.  For example::
1723     .. role:: custom
1724        :class: special
1726     :custom:`interpreted text`
1728 This is the parsed result::
1730     <paragraph>
1731         <inline classes="special">
1732             interpreted text
1734 .. _role class:
1736 The following option is recognized by the "role" directive for most
1737 base roles:
1739 ``class`` : text
1740     Set the `"classes"`_ attribute value on the element produced
1741     (``inline``, or element associated with a base class) when the
1742     custom interpreted text role is used.  If no directive options are
1743     specified, a "class" option with the directive argument (role
1744     name) as the value is implied.  See the class_ directive above.
1746 Specific base roles may support other options and/or directive
1747 content.  See the `reStructuredText Interpreted Text Roles`_ document
1748 for details.
1750 .. _reStructuredText Interpreted Text Roles: roles.html
1753 .. _default-role:
1755 Setting the Default Interpreted Text Role
1756 =========================================
1758 :Directive Type: "default-role"
1759 :Doctree Element: None; affects subsequent parsing.
1760 :Directive Arguments: One, optional (new default role name).
1761 :Directive Options: None.
1762 :Directive Content: None.
1764 (New in Docutils 0.3.10)
1766 The "default-role" directive sets the default interpreted text role,
1767 the role that is used for interpreted text without an explicit role.
1768 For example, after setting the default role like this::
1770     .. default-role:: subscript
1772 any subsequent use of implicit-role interpreted text in the document
1773 will use the "subscript" role::
1775     An example of a `default` role.
1777 This will be parsed into the following document tree fragment::
1779     <paragraph>
1780         An example of a
1781         <subscript>
1782             default
1783          role.
1785 Custom roles may be used (see the "role_" directive above), but it
1786 must have been declared in a document before it can be set as the
1787 default role.  See the `reStructuredText Interpreted Text Roles`_
1788 document for details of built-in roles.
1790 The directive may be used without an argument to restore the initial
1791 default interpreted text role, which is application-dependent.  The
1792 initial default interpreted text role of the standard reStructuredText
1793 parser is "title-reference".
1796 Metadata Document Title
1797 =======================
1799 :Directive Type: "title"
1800 :Doctree Element: None.
1801 :Directive Arguments: 1, required (the title text).
1802 :Directive Options: None.
1803 :Directive Content: None.
1805 The "title" directive specifies the document title as metadata, which
1806 does not become part of the document body.  It overrides a
1807 document-supplied title.  For example, in HTML output the metadata
1808 document title appears in the title bar of the browser window.
1811 Restructuredtext-Test-Directive
1812 ===============================
1814 :Directive Type: "restructuredtext-test-directive"
1815 :Doctree Element: system_warning
1816 :Directive Arguments: None.
1817 :Directive Options: None.
1818 :Directive Content: Interpreted as a literal block.
1820 This directive is provided for test purposes only.  (Nobody is
1821 expected to type in a name *that* long!)  It is converted into a
1822 level-1 (info) system message showing the directive data, possibly
1823 followed by a literal block containing the rest of the directive
1824 block.
1826 --------------
1827 Common Options
1828 --------------
1830 Most of the directives that generate doctree elements support the following
1831 options:
1833 _`:class:` : text
1834     Set a `"classes"`_ attribute value on the doctree element generated by
1835     the directive. See also the class_ directive.
1837 _`:name:` : text
1838     Add `text` to the `"names"`_ attribute of the doctree element generated
1839     by the directive. This allows `hyperlink references`_ to the element
1840     using `text` as `reference name`_.
1842     Specifying the `name` option of a directive, e.g., ::
1844       .. image:: bild.png
1845          :name: my picture
1847     is a concise syntax alternative to preceding it with a `hyperlink
1848     target`_ ::
1850       .. _my picture:
1852       .. image:: bild.png
1854     New in Docutils 0.8.
1857 .. _reference name: restructuredtext.html#reference-names
1858 .. _hyperlink target: restructuredtext.html#hyperlink-targets
1859 .. _hyperlink references: restructuredtext.html#hyperlink-references
1860 .. _"classes": ../doctree.html#classes
1861 .. _"names": ../doctree.html#names
1862 .. _admonition: ../doctree.html#admonition
1863 .. _block_quote: ../doctree.html#block-quote
1864 .. _caption: ../doctree.html#caption
1865 .. _compound: ../doctree.html#compound
1866 .. _container: ../doctree.html#container
1867 .. _decoration: ../doctree.html#decoration
1868 .. _figure: ../doctree.html#figure
1869 .. _footnote: ../doctree.html#footnote
1870 .. _footnote_reference: ../doctree.html#footnote-reference
1871 .. _generated: ../doctree.html#generated
1872 .. _image: ../doctree.html#image
1873 .. _inline elements: ../doctree.html#inline-elements
1874 .. _literal_block: ../doctree.html#literal-block
1875 .. _legend: ../doctree.html#legend
1876 .. _line_block: ../doctree.html#line-block
1877 .. _math_block: ../doctree.html#math-block
1878 .. _pending: ../doctree.html#pending
1879 .. _raw: ../doctree.html#raw
1880 .. _rubric: ../doctree.html#rubric
1881 .. _sidebar: ../doctree.html#sidebar
1882 .. _table: ../doctree.html#table
1883 .. _title: ../doctree.html#title
1884 .. _topic: ../doctree.html#topic
1889    Local Variables:
1890    mode: indented-text
1891    indent-tabs-mode: nil
1892    sentence-end-double-space: t
1893    fill-column: 70
1894    End: