Change default of "syntax highlight" option to "long",
[docutils.git] / docs / ref / rst / directives.txt
blob71cfe6d09f1c84ac271ba30d009d8dbcca880cbc
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 The URI for the image source file is specified in the directive
175 argument.  As with hyperlink targets, the image URI may begin on the
176 same line as the explicit markup start and target name, or it may
177 begin in an indented text block immediately following, with no
178 intervening blank lines.  If there are multiple lines in the link
179 block, they are stripped of leading and trailing whitespace and joined
180 together.
182 Optionally, the image link block may contain a flat field list, the
183 _`image options`.  For example::
185     .. image:: picture.jpeg
186        :height: 100px
187        :width: 200 px
188        :scale: 50 %
189        :alt: alternate text
190        :align: right
192 The following options are recognized:
194 ``alt`` : text
195     Alternate text: a short description of the image, displayed by
196     applications that cannot display images, or spoken by applications
197     for visually impaired users.
199 ``height`` : `length`_
200     The desired height of the image.
201     Used to reserve space or scale the image vertically.  When the "scale"
202     option is also specified, they are combined.  For example, a height of
203     200px and a scale of 50 is equivalent to a height of 100px with no scale.
205 ``width`` : `length`_ or `percentage`_ of the current line width
206     The width of the image.
207     Used to reserve space or scale the image horizontally.  As with "height"
208     above, when the "scale" option is also specified, they are combined.
210     .. _length: restructuredtext.html#length-units
211     .. _percentage: restructuredtext.html#percentage-units
213 ``scale`` : integer percentage (the "%" symbol is optional)
214     The uniform scaling factor of the image.  The default is "100 %", i.e.
215     no scaling.
217     If no "height" or "width" options are specified, the `Python Imaging
218     Library`_ (PIL) may be used to determine them, if it is installed and
219     the image file is available.
221 ``align`` : "top", "middle", "bottom", "left", "center", or "right"
222     The alignment of the image, equivalent to the HTML ``<img>`` tag's
223     "align" attribute.  The values "top", "middle", and "bottom"
224     control an image's vertical alignment (relative to the text
225     baseline); they are only useful for inline images (substitutions).
226     The values "left", "center", and "right" control an image's
227     horizontal alignment, allowing the image to float and have the
228     text flow around it.  The specific behavior depends upon the
229     browser or rendering software used.
231 ``target`` : text (URI or reference name)
232     Makes the image into a hyperlink reference ("clickable").  The
233     option argument may be a URI (relative or absolute), or a
234     `reference name`_ with underscore suffix (e.g. ```a name`_``).
236 and the common options `:class:`_ and `:name:`_.
239 Figure
240 ======
242 :Directive Type: "figure"
243 :Doctree Elements: figure_, image_, caption_, legend_
244 :Directive Arguments: One, required (image URI).
245 :Directive Options: Possible.
246 :Directive Content: Interpreted as the figure caption and an optional
247                     legend.
249 A "figure" consists of image_ data (including `image options`_), an optional
250 caption (a single paragraph), and an optional legend (arbitrary body
251 elements). For page-based output media, figures might float to a different
252 position if this helps the page layout.
255     .. figure:: picture.png
256        :scale: 50 %
257        :alt: map to buried treasure
259        This is the caption of the figure (a simple paragraph).
261        The legend consists of all elements after the caption.  In this
262        case, the legend consists of this paragraph and the following
263        table:
265        +-----------------------+-----------------------+
266        | Symbol                | Meaning               |
267        +=======================+=======================+
268        | .. image:: tent.png   | Campground            |
269        +-----------------------+-----------------------+
270        | .. image:: waves.png  | Lake                  |
271        +-----------------------+-----------------------+
272        | .. image:: peak.png   | Mountain              |
273        +-----------------------+-----------------------+
275 There must be blank lines before the caption paragraph and before the
276 legend.  To specify a legend without a caption, use an empty comment
277 ("..") in place of the caption.
279 The "figure" directive supports all of the options of the "image"
280 directive (see `image options`_ above). These options (except
281 "align") are passed on to the contained image.
283 ``align`` : "left", "center", or "right"
284     The horizontal alignment of the figure, allowing the image to
285     float and have the text flow around it.  The specific behavior
286     depends upon the browser or rendering software used.
288 In addition, the following options are recognized:
290 ``figwidth`` : "image", length_, or percentage_ of current line width
291     The width of the figure.
292     Limits the horizontal space used by the figure.
293     A special value of "image" is allowed, in which case the
294     included image's actual width is used (requires the `Python Imaging
295     Library`_). If the image file is not found or the required software is
296     unavailable, this option is ignored.
298     Sets the "width" attribute of the "figure" doctree element.
300     This option does not scale the included image; use the "width"
301     `image`_ option for that. ::
303         +---------------------------+
304         |        figure             |
305         |                           |
306         |<------ figwidth --------->|
307         |                           |
308         |  +---------------------+  |
309         |  |     image           |  |
310         |  |                     |  |
311         |  |<--- width --------->|  |
312         |  +---------------------+  |
313         |                           |
314         |The figure's caption should|
315         |wrap at this width.        |
316         +---------------------------+
318 ``figclass`` : text
319     Set a `"classes"`_ attribute value on the figure element.  See the
320     class_ directive below.
322 .. _Python Imaging Library: http://www.pythonware.com/products/pil/
325 ---------------
326  Body Elements
327 ---------------
329 Topic
330 =====
332 :Directive Type: "topic"
333 :Doctree Element: topic_
334 :Directive Arguments: 1, required (topic title).
335 :Directive Options: `:class:`_, `:name:`_
336 :Directive Content: Interpreted as the topic body.
338 A topic is like a block quote with a title, or a self-contained
339 section with no subsections.  Use the "topic" directive to indicate a
340 self-contained idea that is separate from the flow of the document.
341 Topics may occur anywhere a section or transition may occur.  Body
342 elements and topics may not contain nested topics.
344 The directive's sole argument is interpreted as the topic title; the
345 next line must be blank.  All subsequent lines make up the topic body,
346 interpreted as body elements.  For example::
348     .. topic:: Topic Title
350         Subsequent indented lines comprise
351         the body of the topic, and are
352         interpreted as body elements.
355 Sidebar
356 =======
358 :Directive Type: "sidebar"
359 :Doctree Element: sidebar_
360 :Directive Arguments: One, required (sidebar title).
361 :Directive Options: Possible (see below).
362 :Directive Content: Interpreted as the sidebar body.
364 Sidebars are like miniature, parallel documents that occur inside
365 other documents, providing related or reference material.  A sidebar
366 is typically offset by a border and "floats" to the side of the page;
367 the document's main text may flow around it.  Sidebars can also be
368 likened to super-footnotes; their content is outside of the flow of
369 the document's main text.
371 Sidebars may occur anywhere a section or transition may occur.  Body
372 elements (including sidebars) may not contain nested sidebars.
374 The directive's sole argument is interpreted as the sidebar title,
375 which may be followed by a subtitle option (see below); the next line
376 must be blank.  All subsequent lines make up the sidebar body,
377 interpreted as body elements.  For example::
379     .. sidebar:: Sidebar Title
380        :subtitle: Optional Sidebar Subtitle
382        Subsequent indented lines comprise
383        the body of the sidebar, and are
384        interpreted as body elements.
386 The following options are recognized:
388 ``subtitle`` : text
389     The sidebar's subtitle.
391 and the common options `:class:`_ and `:name:`_.
394 Line Block
395 ==========
397 .. admonition:: Deprecated
399    The "line-block" directive is deprecated.  Use the `line block
400    syntax`_ instead.
402    .. _line block syntax: restructuredtext.html#line-blocks
404 :Directive Type: "line-block"
405 :Doctree Element: line_block_
406 :Directive Arguments: None.
407 :Directive Options: `:class:`_, `:name:`_
408 :Directive Content: Becomes the body of the line block.
410 The "line-block" directive constructs an element where line breaks and
411 initial indentation is significant and inline markup is supported.  It
412 is equivalent to a `parsed literal block`_ with different rendering:
413 typically in an ordinary serif typeface instead of a
414 typewriter/monospaced face, and not automatically indented.  (Have the
415 line-block directive begin a block quote to get an indented line
416 block.)  Line blocks are useful for address blocks and verse (poetry,
417 song lyrics), where the structure of lines is significant.  For
418 example, here's a classic::
420     "To Ma Own Beloved Lassie: A Poem on her 17th Birthday", by
421     Ewan McTeagle (for Lassie O'Shea):
423         .. line-block::
425             Lend us a couple of bob till Thursday.
426             I'm absolutely skint.
427             But I'm expecting a postal order and I can pay you back
428                 as soon as it comes.
429             Love, Ewan.
433 .. _parsed-literal:
435 Parsed Literal Block
436 ====================
438 :Directive Type: "parsed-literal"
439 :Doctree Element: literal_block_
440 :Directive Arguments: None.
441 :Directive Options: `:class:`_, `:name:`_
442 :Directive Content: Becomes the body of the literal block.
444 Unlike an ordinary literal block, the "parsed-literal" directive
445 constructs a literal block where the text is parsed for inline markup.
446 It is equivalent to a `line block`_ with different rendering:
447 typically in a typewriter/monospaced typeface, like an ordinary
448 literal block.  Parsed literal blocks are useful for adding hyperlinks
449 to code examples.
451 However, care must be taken with the text, because inline markup is
452 recognized and there is no protection from parsing.  Backslash-escapes
453 may be necessary to prevent unintended parsing.  And because the
454 markup characters are removed by the parser, care must also be taken
455 with vertical alignment.  Parsed "ASCII art" is tricky, and extra
456 whitespace may be necessary.
458 For example, all the element names in this content model are links::
460     .. parsed-literal::
462        ( (title_, subtitle_?)?,
463          decoration_?,
464          (docinfo_, transition_?)?,
465          `%structure.model;`_ )
467 Code
468 ====
470 :Directive Type: "code"
471 :Doctree Element: literal_block_, `inline elements`_
472 :Directive Arguments: One, optional (formal language).
473 :Directive Options: name, class, number-lines.
474 :Directive Content: Becomes the body of the literal block.
475 :Configuration Setting: syntax_highlight_.
477 (New in Docutils 0.9)
479 The "code" directive constructs a literal block. If the code language is
480 specified, the content is parsed by the Pygments_ syntax highlighter and
481 tokens are stored in nested `inline elements`_ with class arguments
482 according to their syntactic category. The actual highlighting can be
483 customized with a style-sheet (e.g. one `generated by Pygments`__).
485 The parsing can be turned off with the syntax_highlight_ configuration
486 setting and command line option or by specifying the language as `:class:`_
487 option instead of directive argument. This also avoids warnings
488 when Pygments_ is not installed or the language is not in the
489 `supported languages and markup formats`_.
491 __   http://pygments.org/docs/cmdline/#generating-styles
492 .. _Pygments: http://pygments.org/
493 .. _syntax_highlight: ../../user/config.html#syntax-highlight
494 .. _supported languages and markup formats: http://pygments.org/languages/
497 The following options are recognized:
499 ``number-lines`` : [start line number]
500     Precede every line with a line number.
501     The optional argument is the number of the first line (defaut 1).
503 and the common options `:class:`_ and `:name:`_.
505 Example::
506   The content of the following directive ::
508    .. code:: python
510     def my_function():
511         "just a test"
512         print 8/2
514   is parsed and marked up as Python source code.
517 Math
518 ====
520 :Directive Type: "math"
521 :Doctree Element: math_block_
522 :Directive Arguments: One, optional: prepended to content.
523 :Directive Options: `:class:`_, `:name:`_
524 :Directive Content: Interpreted as math block(s).
525                     Content blocks separated by a blank line are put in
526                     separate math-block doctree elements.
527 :Configuration Setting: math_output_
529 (New in Docutils 0.8)
531 The "math" directive inserts block(s) with mathematical content
532 (display formulas, equations) into the document. The input format is
533 *LaTeX math syntax* (see, e.g. the `Short Math Guide`_) with support
534 for Unicode symbols, for example::
536   .. math::
538     α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)
540 For inline math, use the `"math" role`_.
542 Support for math may be limited by the output format. If a writer does
543 not support math typesetting, the content is inserted verbatim.
544 For HTML, the output format can be set with the `math_output`_
545 configuration setting (or the corresponding ``--math-output`` command
546 line option).
548 .. _Short Math Guide: ftp://ftp.ams.org/ams/doc/amsmath/short-math-guide.pdf
549 .. _"math" role: roles.html#math
550 .. _math_output: ../../user/config.html#math-output
552 Rubric
553 ======
555 :Directive Type: "rubric"
556 :Doctree Element: rubric_
557 :Directive Arguments: 1, required (rubric text).
558 :Directive Options: `:class:`_, `:name:`_
559 :Directive Content: None.
563      rubric n. 1. a title, heading, or the like, in a manuscript,
564      book, statute, etc., written or printed in red or otherwise
565      distinguished from the rest of the text. ...
567      -- Random House Webster's College Dictionary, 1991
569 The "rubric" directive inserts a "rubric" element into the document
570 tree.  A rubric is like an informal heading that doesn't correspond to
571 the document's structure.
574 Epigraph
575 ========
577 :Directive Type: "epigraph"
578 :Doctree Element: block_quote_
579 :Directive Arguments: None.
580 :Directive Options: None.
581 :Directive Content: Interpreted as the body of the block quote.
583 An epigraph is an apposite (suitable, apt, or pertinent) short
584 inscription, often a quotation or poem, at the beginning of a document
585 or section.
587 The "epigraph" directive produces an "epigraph"-class block quote.
588 For example, this input::
590      .. epigraph::
592         No matter where you go, there you are.
594         -- Buckaroo Banzai
596 becomes this document tree fragment::
598     <block_quote classes="epigraph">
599         <paragraph>
600             No matter where you go, there you are.
601         <attribution>
602             Buckaroo Banzai
605 Highlights
606 ==========
608 :Directive Type: "highlights"
609 :Doctree Element: block_quote_
610 :Directive Arguments: None.
611 :Directive Options: None.
612 :Directive Content: Interpreted as the body of the block quote.
614 Highlights summarize the main points of a document or section, often
615 consisting of a list.
617 The "highlights" directive produces a "highlights"-class block quote.
618 See Epigraph_ above for an analogous example.
621 Pull-Quote
622 ==========
624 :Directive Type: "pull-quote"
625 :Doctree Element: block_quote_
626 :Directive Arguments: None.
627 :Directive Options: None.
628 :Directive Content: Interpreted as the body of the block quote.
630 A pull-quote is a small selection of text "pulled out and quoted",
631 typically in a larger typeface.  Pull-quotes are used to attract
632 attention, especially in long articles.
634 The "pull-quote" directive produces a "pull-quote"-class block quote.
635 See Epigraph_ above for an analogous example.
638 Compound Paragraph
639 ==================
641 :Directive Type: "compound"
642 :Doctree Element: compound_
643 :Directive Arguments: None.
644 :Directive Options: `:class:`_, `:name:`_
645 :Directive Content: Interpreted as body elements.
647 (New in Docutils 0.3.6)
649 The "compound" directive is used to create a compound paragraph, which
650 is a single logical paragraph containing multiple physical body
651 elements such as simple paragraphs, literal blocks, tables, lists,
652 etc., instead of directly containing text and inline elements.  For
653 example::
655     .. compound::
657        The 'rm' command is very dangerous.  If you are logged
658        in as root and enter ::
660            cd /
661            rm -rf *
663        you will erase the entire contents of your file system.
665 In the example above, a literal block is "embedded" within a sentence
666 that begins in one physical paragraph and ends in another.
668 .. note::
670    The "compound" directive is *not* a generic block-level container
671    like HTML's ``<div>`` element.  Do not use it only to group a
672    sequence of elements, or you may get unexpected results.
674    If you need a generic block-level container, please use the
675    container_ directive, described below.
677 Compound paragraphs are typically rendered as multiple distinct text
678 blocks, with the possibility of variations to emphasize their logical
679 unity:
681 * If paragraphs are rendered with a first-line indent, only the first
682   physical paragraph of a compound paragraph should have that indent
683   -- second and further physical paragraphs should omit the indents;
684 * vertical spacing between physical elements may be reduced;
685 * and so on.
688 Container
689 =========
691 :Directive Type: "container"
692 :Doctree Element: container_
693 :Directive Arguments: One or more, optional (class names).
694 :Directive Options: `:name:`_
695 :Directive Content: Interpreted as body elements.
697 (New in Docutils 0.3.10)
699 The "container" directive surrounds its contents (arbitrary body
700 elements) with a generic block-level "container" element.  Combined
701 with the optional "classes_" attribute argument(s), this is an
702 extension mechanism for users & applications.  For example::
704     .. container:: custom
706        This paragraph might be rendered in a custom way.
708 Parsing the above results in the following pseudo-XML::
710     <container classes="custom">
711         <paragraph>
712             This paragraph might be rendered in a custom way.
714 The "container" directive is the equivalent of HTML's ``<div>``
715 element.  It may be used to group a sequence of elements for user- or
716 application-specific purposes.
720 --------
721  Tables
722 --------
724 Formal tables need more structure than the reStructuredText syntax
725 supplies.  Tables may be given titles with the table_ directive.
726 Sometimes reStructuredText tables are inconvenient to write, or table
727 data in a standard format is readily available.  The csv-table_
728 directive supports CSV data.
731 Table
732 =====
734 :Directive Type: "table"
735 :Doctree Element: table_
736 :Directive Arguments: 1, optional (table title).
737 :Directive Options: `:class:`_, `:name:`_
738 :Directive Content: A normal reStructuredText table.
740 (New in Docutils 0.3.1)
742 The "table" directive is used to create a titled table, to associate a
743 title with a table::
745     .. table:: Truth table for "not"
747        =====  =====
748          A    not A
749        =====  =====
750        False  True
751        True   False
752        =====  =====
755 .. _csv-table:
757 CSV Table
758 =========
760 :Directive Type: "csv-table"
761 :Doctree Element: table_
762 :Directive Arguments: 1, optional (table title).
763 :Directive Options: Possible (see below).
764 :Directive Content: A CSV (comma-separated values) table.
766 .. WARNING::
768    The "csv-table" directive's ":file:" and ":url:" options represent
769    a potential security holes.  They can be disabled with the
770    "file_insertion_enabled_" runtime setting.
772 (New in Docutils 0.3.4)
774 The "csv-table" directive is used to create a table from CSV
775 (comma-separated values) data.  CSV is a common data format generated
776 by spreadsheet applications and commercial databases.  The data may be
777 internal (an integral part of the document) or external (a separate
778 file).
780 Example::
782     .. csv-table:: Frozen Delights!
783        :header: "Treat", "Quantity", "Description"
784        :widths: 15, 10, 30
786        "Albatross", 2.99, "On a stick!"
787        "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
788        crunchy, now would it?"
789        "Gannet Ripple", 1.99, "On a stick!"
791 Block markup and inline markup within cells is supported.  Line ends
792 are recognized within cells.
794 Working limitations:
796 * Whitespace delimiters are supported only for external CSV files.
798 * There is no support for checking that the number of columns in each
799   row is the same.  However, this directive supports CSV generators
800   that do not insert "empty" entries at the end of short rows, by
801   automatically adding empty entries.
803   .. Add "strict" option to verify input?
805 The following options are recognized:
807 ``widths`` : integer [, integer...]
808     A comma- or space-separated list of relative column widths.  The
809     default is equal-width columns (100%/#columns).
811 ``header-rows`` : integer
812     The number of rows of CSV data to use in the table header.
813     Defaults to 0.
815 ``stub-columns`` : integer
816     The number of table columns to use as stubs (row titles, on the
817     left).  Defaults to 0.
819 ``header`` : CSV data
820     Supplemental data for the table header, added independently of and
821     before any ``header-rows`` from the main CSV data.  Must use the
822     same CSV format as the main CSV data.
824 ``file`` : string (newlines removed)
825     The local filesystem path to a CSV data file.
827 ``url`` : string (whitespace removed)
828     An Internet URL reference to a CSV data file.
830 ``encoding`` : name of text encoding
831     The text encoding of the external CSV data (file or URL).
832     Defaults to the document's encoding (if specified).
834 ``delim`` : char | "tab" | "space"
835     A one-character string used to separate fields.  Defaults to ``,``
836     (comma).  May be specified as a Unicode code point; see the
837     unicode_ directive for syntax details.
839 ``quote`` : char
840     A one-character string used to quote elements containing the
841     delimiter or which start with the quote character.  Defaults to
842     ``"`` (quote).  May be specified as a Unicode code point; see the
843     unicode_ directive for syntax details.
845 ``keepspace`` : flag
846     Treat whitespace immediately following the delimiter as
847     significant.  The default is to ignore such whitespace.
849 ``escape`` : char
850     A one-character string used to escape the delimiter or quote
851     characters.  May be specified as a Unicode code point; see the
852     unicode_ directive for syntax details.  Used when the delimiter is
853     used in an unquoted field, or when quote characters are used
854     within a field.  The default is to double-up the character,
855     e.g. "He said, ""Hi!"""
857     .. Add another possible value, "double", to explicitly indicate
858        the default case?
860 and the common options `:class:`_ and `:name:`_.
863 List Table
864 ==========
866 :Directive Type: "list-table"
867 :Doctree Element: table_
868 :Directive Arguments: 1, optional (table title).
869 :Directive Options: Possible (see below).
870 :Directive Content: A uniform two-level bullet list.
872 (New in Docutils 0.3.8.  This is an initial implementation; `further
873 ideas`__ may be implemented in the future.)
875 __ ../../dev/rst/alternatives.html#list-driven-tables
877 The "list-table" directive is used to create a table from data in a
878 uniform two-level bullet list.  "Uniform" means that each sublist
879 (second-level list) must contain the same number of list items.
881 Example::
883     .. list-table:: Frozen Delights!
884        :widths: 15 10 30
885        :header-rows: 1
887        * - Treat
888          - Quantity
889          - Description
890        * - Albatross
891          - 2.99
892          - On a stick!
893        * - Crunchy Frog
894          - 1.49
895          - If we took the bones out, it wouldn't be
896            crunchy, now would it?
897        * - Gannet Ripple
898          - 1.99
899          - On a stick!
901 The following options are recognized:
903 ``widths`` : integer [integer...]
904     A comma- or space-separated list of relative column widths.  The
905     default is equal-width columns (100%/#columns).
907 ``header-rows`` : integer
908     The number of rows of list data to use in the table header.
909     Defaults to 0.
911 ``stub-columns`` : integer
912     The number of table columns to use as stubs (row titles, on the
913     left).  Defaults to 0.
915 and the common options `:class:`_ and `:name:`_.
918 ----------------
919  Document Parts
920 ----------------
922 .. _contents:
924 Table of Contents
925 =================
927 :Directive Type: "contents"
928 :Doctree Elements: pending_, topic_
929 :Directive Arguments: One, optional: title.
930 :Directive Options: Possible.
931 :Directive Content: None.
933 The "contents" directive generates a table of contents (TOC) in a
934 topic_.  Topics, and therefore tables of contents, may occur anywhere
935 a section or transition may occur.  Body elements and topics may not
936 contain tables of contents.
938 Here's the directive in its simplest form::
940     .. contents::
942 Language-dependent boilerplate text will be used for the title.  The
943 English default title text is "Contents".
945 An explicit title may be specified::
947     .. contents:: Table of Contents
949 The title may span lines, although it is not recommended::
951     .. contents:: Here's a very long Table of
952        Contents title
954 Options may be specified for the directive, using a field list::
956     .. contents:: Table of Contents
957        :depth: 2
959 If the default title is to be used, the options field list may begin
960 on the same line as the directive marker::
962     .. contents:: :depth: 2
964 The following options are recognized:
966 ``depth`` : integer
967     The number of section levels that are collected in the table of
968     contents.  The default is unlimited depth.
970 ``local`` : flag (empty)
971     Generate a local table of contents.  Entries will only include
972     subsections of the section in which the directive is given.  If no
973     explicit title is given, the table of contents will not be titled.
975 ``backlinks`` : "entry" or "top" or "none"
976     Generate links from section headers back to the table of contents
977     entries, the table of contents itself, or generate no backlinks.
979 ``class`` : text
980     Set a `"classes"`_ attribute value on the topic element.  See the
981     class_ directive below.
984 .. _sectnum:
985 .. _section-autonumbering:
987 Automatic Section Numbering
988 ===========================
990 :Directive Type: "sectnum" or "section-autonumbering" (synonyms)
991 :Doctree Elements: pending_, generated_
992 :Directive Arguments: None.
993 :Directive Options: Possible.
994 :Directive Content: None.
995 :Configuration Setting: sectnum_xform_
997 The "sectnum" (or "section-autonumbering") directive automatically numbers
998 sections and subsections in a document (if not disabled by the
999 ``--no-section-numbering`` command line option or the `sectnum_xform`_
1000 configuration setting).
1002 Section numbers are of the "multiple enumeration" form, where each
1003 level has a number, separated by periods.  For example, the title of section
1004 1, subsection 2, subsubsection 3 would have "1.2.3" prefixed.
1006 The "sectnum" directive does its work in two passes: the initial parse
1007 and a transform.  During the initial parse, a "pending" element is
1008 generated which acts as a placeholder, storing any options internally.
1009 At a later stage in the processing, the "pending" element triggers a
1010 transform, which adds section numbers to titles.  Section numbers are
1011 enclosed in a "generated" element, and titles have their "auto"
1012 attribute set to "1".
1014 The following options are recognized:
1016 ``depth`` : integer
1017     The number of section levels that are numbered by this directive.
1018     The default is unlimited depth.
1020 ``prefix`` : string
1021     An arbitrary string that is prefixed to the automatically
1022     generated section numbers.  It may be something like "3.2.", which
1023     will produce "3.2.1", "3.2.2", "3.2.2.1", and so on.  Note that
1024     any separating punctuation (in the example, a period, ".") must be
1025     explicitly provided.  The default is no prefix.
1027 ``suffix`` : string
1028     An arbitrary string that is appended to the automatically
1029     generated section numbers.  The default is no suffix.
1031 ``start`` : integer
1032     The value that will be used for the first section number.
1033     Combined with ``prefix``, this may be used to force the right
1034     numbering for a document split over several source files.  The
1035     default is 1.
1037 .. _sectnum_xform: ../../user/config.html#sectnum-xform
1040 .. _header:
1041 .. _footer:
1043 Document Header & Footer
1044 ========================
1046 :Directive Types: "header" and "footer"
1047 :Doctree Elements: decoration_, header, footer
1048 :Directive Arguments: None.
1049 :Directive Options: None.
1050 :Directive Content: Interpreted as body elements.
1052 (New in Docutils 0.3.8)
1054 The "header" and "footer" directives create document decorations,
1055 useful for page navigation, notes, time/datestamp, etc.  For example::
1057     .. header:: This space for rent.
1059 This will add a paragraph to the document header, which will appear at
1060 the top of the generated web page or at the top of every printed page.
1062 These directives may be used multiple times, cumulatively.  There is
1063 currently support for only one header and footer.
1065 .. note::
1067    While it is possible to use the "header" and "footer" directives to
1068    create navigational elements for web pages, you should be aware
1069    that Docutils is meant to be used for *document* processing, and
1070    that a navigation bar is not typically part of a document.
1072    Thus, you may soon find Docutils' abilities to be insufficient for
1073    these purposes.  At that time, you should consider using a
1074    templating system (like ht2html_) rather than the "header" and
1075    "footer" directives.
1077    .. _ht2html: http://ht2html.sourceforge.net/
1079 In addition to the use of these directives to populate header and
1080 footer content, content may also be added automatically by the
1081 processing system.  For example, if certain runtime settings are
1082 enabled, the document footer is populated with processing information
1083 such as a datestamp, a link to `the Docutils website`_, etc.
1085 .. _the Docutils website: http://docutils.sourceforge.net
1088 ------------
1089  References
1090 ------------
1092 .. _target-notes:
1094 Target Footnotes
1095 ================
1097 :Directive Type: "target-notes"
1098 :Doctree Elements: pending_, footnote_, footnote_reference_
1099 :Directive Arguments: None.
1100 :Directive Options: `:class:`_, `:name:`_
1101 :Directive Options: Possible.
1102 :Directive Content: None.
1104 The "target-notes" directive creates a footnote for each external
1105 target in the text, and corresponding footnote references after each
1106 reference.  For every explicit target (of the form, ``.. _target name:
1107 URL``) in the text, a footnote will be generated containing the
1108 visible URL as content.
1111 Footnotes
1112 =========
1114 **NOT IMPLEMENTED YET**
1116 :Directive Type: "footnotes"
1117 :Doctree Elements: pending_, topic_
1118 :Directive Arguments: None?
1119 :Directive Options: Possible?
1120 :Directive Content: None.
1125 Citations
1126 =========
1128 **NOT IMPLEMENTED YET**
1130 :Directive Type: "citations"
1131 :Doctree Elements: pending_, topic_
1132 :Directive Arguments: None?
1133 :Directive Options: Possible?
1134 :Directive Content: None.
1139 ---------------
1140  HTML-Specific
1141 ---------------
1143 Meta
1144 ====
1146 :Directive Type: "meta"
1147 :Doctree Element: meta (non-standard)
1148 :Directive Arguments: None.
1149 :Directive Options: None.
1150 :Directive Content: Must contain a flat field list.
1152 The "meta" directive is used to specify HTML metadata stored in HTML
1153 META tags.  "Metadata" is data about data, in this case data about web
1154 pages.  Metadata is used to describe and classify web pages in the
1155 World Wide Web, in a form that is easy for search engines to extract
1156 and collate.
1158 Within the directive block, a flat field list provides the syntax for
1159 metadata.  The field name becomes the contents of the "name" attribute
1160 of the META tag, and the field body (interpreted as a single string
1161 without inline markup) becomes the contents of the "content"
1162 attribute.  For example::
1164     .. meta::
1165        :description: The reStructuredText plaintext markup language
1166        :keywords: plaintext, markup language
1168 This would be converted to the following HTML::
1170     <meta name="description"
1171         content="The reStructuredText plaintext markup language">
1172     <meta name="keywords" content="plaintext, markup language">
1174 Support for other META attributes ("http-equiv", "scheme", "lang",
1175 "dir") are provided through field arguments, which must be of the form
1176 "attr=value"::
1178     .. meta::
1179        :description lang=en: An amusing story
1180        :description lang=fr: Une histoire amusante
1182 And their HTML equivalents::
1184     <meta name="description" lang="en" content="An amusing story">
1185     <meta name="description" lang="fr" content="Une histoire amusante">
1187 Some META tags use an "http-equiv" attribute instead of the "name"
1188 attribute.  To specify "http-equiv" META tags, simply omit the name::
1190     .. meta::
1191        :http-equiv=Content-Type: text/html; charset=ISO-8859-1
1193 HTML equivalent::
1195     <meta http-equiv="Content-Type"
1196          content="text/html; charset=ISO-8859-1">
1199 Imagemap
1200 ========
1202 **NOT IMPLEMENTED YET**
1204 Non-standard element: imagemap.
1207 -----------------------------------------
1208  Directives for Substitution Definitions
1209 -----------------------------------------
1211 The directives in this section may only be used in substitution
1212 definitions.  They may not be used directly, in standalone context.
1213 The `image`_ directive may be used both in substitution definitions
1214 and in the standalone context.
1217 .. _replace:
1219 Replacement Text
1220 ================
1222 :Directive Type: "replace"
1223 :Doctree Element: Text & `inline elements`_
1224 :Directive Arguments: None.
1225 :Directive Options: None.
1226 :Directive Content: A single paragraph; may contain inline markup.
1228 The "replace" directive is used to indicate replacement text for a
1229 substitution reference.  It may be used within substitution
1230 definitions only.  For example, this directive can be used to expand
1231 abbreviations::
1233     .. |reST| replace:: reStructuredText
1235     Yes, |reST| is a long word, so I can't blame anyone for wanting to
1236     abbreviate it.
1238 As reStructuredText doesn't support nested inline markup, the only way
1239 to create a reference with styled text is to use substitutions with
1240 the "replace" directive::
1242     I recommend you try |Python|_.
1244     .. |Python| replace:: Python, *the* best language around
1245     .. _Python: http://www.python.org/
1248 .. _unicode:
1250 Unicode Character Codes
1251 =======================
1253 :Directive Type: "unicode"
1254 :Doctree Element: Text
1255 :Directive Arguments: One or more, required (Unicode character codes,
1256                       optional text, and comments).
1257 :Directive Options: Possible.
1258 :Directive Content: None.
1260 The "unicode" directive converts Unicode character codes (numerical
1261 values) to characters, and may be used in substitution definitions
1262 only.
1264 The arguments, separated by spaces, can be:
1266 * **character codes** as
1268   - decimal numbers or
1270   - hexadecimal numbers, prefixed by ``0x``, ``x``, ``\x``, ``U+``,
1271     ``u``, or ``\u`` or as XML-style hexadecimal character entities,
1272     e.g. ``&#x1a2b;``
1274 * **text**, which is used as-is.
1276 Text following " .. " is a comment and is ignored.  The spaces between
1277 the arguments are ignored and thus do not appear in the output.
1278 Hexadecimal codes are case-insensitive.
1280 For example, the following text::
1282     Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1283     all rights reserved.
1285     .. |copy| unicode:: 0xA9 .. copyright sign
1286     .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1287        .. with trademark sign
1288     .. |---| unicode:: U+02014 .. em dash
1289        :trim:
1291 results in:
1293     Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1294     all rights reserved.
1296     .. |copy| unicode:: 0xA9 .. copyright sign
1297     .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1298        .. with trademark sign
1299     .. |---| unicode:: U+02014 .. em dash
1300        :trim:
1302 The following options are recognized:
1304 ``ltrim`` : flag
1305     Whitespace to the left of the substitution reference is removed.
1307 ``rtrim`` : flag
1308     Whitespace to the right of the substitution reference is removed.
1310 ``trim`` : flag
1311     Equivalent to ``ltrim`` plus ``rtrim``; whitespace on both sides
1312     of the substitution reference is removed.
1315 Date
1316 ====
1318 :Directive Type: "date"
1319 :Doctree Element: Text
1320 :Directive Arguments: One, optional (date format).
1321 :Directive Options: None.
1322 :Directive Content: None.
1324 The "date" directive generates the current local date and inserts it
1325 into the document as text.  This directive may be used in substitution
1326 definitions only.
1328 The optional directive content is interpreted as the desired date
1329 format, using the same codes as Python's time.strftime function.  The
1330 default format is "%Y-%m-%d" (ISO 8601 date), but time fields can also
1331 be used.  Examples::
1333     .. |date| date::
1334     .. |time| date:: %H:%M
1336     Today's date is |date|.
1338     This document was generated on |date| at |time|.
1341 ---------------
1342  Miscellaneous
1343 ---------------
1345 .. _include:
1347 Including an External Document Fragment
1348 =======================================
1350 :Directive Type: "include"
1351 :Doctree Elements: Depend on data being included
1352                    (literal_block_ with ``code`` or ``literal`` option).
1353 :Directive Arguments: One, required (path to the file to include).
1354 :Directive Options: Possible.
1355 :Directive Content: None.
1356 :Configuration Setting: file_insertion_enabled_
1358 .. WARNING::
1360    The "include" directive represents a potential security hole.  It
1361    can be disabled with the "file_insertion_enabled_" runtime setting.
1363    .. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
1365 The "include" directive reads a text file. The directive argument is
1366 the path to the file to be included, relative to the document
1367 containing the directive. Unless the options ``literal`` or ``code``
1368 are given, the file is parsed in the current document's context at the
1369 point of the directive. For example::
1371     This first example will be parsed at the document level, and can
1372     thus contain any construct, including section headers.
1374     .. include:: inclusion.txt
1376     Back in the main document.
1378         This second example will be parsed in a block quote context.
1379         Therefore it may only contain body elements.  It may not
1380         contain section headers.
1382         .. include:: inclusion.txt
1384 If an included document fragment contains section structure, the title
1385 adornments must match those of the master document.
1387 Standard data files intended for inclusion in reStructuredText
1388 documents are distributed with the Docutils source code, located in
1389 the "docutils" package in the ``docutils/parsers/rst/include``
1390 directory.  To access these files, use the special syntax for standard
1391 "include" data files, angle brackets around the file name::
1393     .. include:: <isonum.txt>
1395 The current set of standard "include" data files consists of sets of
1396 substitution definitions.  See `reStructuredText Standard Definition
1397 Files`__ for details.
1399 __ definitions.html
1401 The following options are recognized:
1403 ``start-line`` : integer
1404     Only the content starting from this line will be included.
1405     (As usual in Python, the first line has index 0 and negative values
1406     count from the end.)
1408 ``end-line`` : integer
1409     Only the content up to (but excluding) this line will be included.
1411 ``start-after`` : text to find in the external data file
1412     Only the content after the first occurrence of the specified text
1413     will be included.
1415 ``end-before`` : text to find in the external data file
1416     Only the content before the first occurrence of the specified text
1417     (but after any ``after`` text) will be included.
1419 ``literal`` : flag (empty)
1420     The entire included text is inserted into the document as a single
1421     literal block.
1423 ``code`` : formal language (optional)
1424     The argument and the content of the included file are passed to
1425     the code_ directive (useful for program listings).
1426     (New in Docutils 0.9)
1428 ``number-lines`` : [start line number]
1429     Precede every code line with a line number.
1430     The optional argument is the number of the first line (defaut 1).
1431     Works only with ``code`` or ``literal``.
1432     (New in Docutils 0.9)
1434 ``encoding`` : name of text encoding
1435     The text encoding of the external data file.  Defaults to the
1436     document's input_encoding_.
1438     .. _input_encoding: ../../user/config.html#input-encoding
1440 ``tab-width`` :  integer
1441     Number of spaces for hard tab expansion.
1442     A negative value prevents expansion of hard tabs. Defaults to the
1443     tab_width_ configuration setting.
1445     .. _tab_width: ../../user/config.html#tab-width
1448 With ``code`` or ``literal`` the common options `:class:`_ and
1449 `:name:`_ are recognized as well.
1451 Combining ``start/end-line`` and ``start-after/end-before`` is possible. The
1452 text markers will be searched in the specified lines (further limiting the
1453 included content).
1455 .. _raw-directive:
1457 Raw Data Pass-Through
1458 =====================
1460 :Directive Type: "raw"
1461 :Doctree Element: raw_
1462 :Directive Arguments: One or more, required (output format types).
1463 :Directive Options: Possible.
1464 :Directive Content: Stored verbatim, uninterpreted.  None (empty) if a
1465                     "file" or "url" option given.
1466 :Configuration Setting: raw_enabled_
1468 .. WARNING::
1470    The "raw" directive represents a potential security hole.  It can
1471    be disabled with the "raw_enabled_" or "file_insertion_enabled_"
1472    runtime settings.
1474    .. _raw_enabled: ../../user/config.html#raw-enabled
1476 .. Caution::
1478    The "raw" directive is a stop-gap measure allowing the author to
1479    bypass reStructuredText's markup.  It is a "power-user" feature
1480    that should not be overused or abused.  The use of "raw" ties
1481    documents to specific output formats and makes them less portable.
1483    If you often need to use the "raw" directive or a "raw"-derived
1484    interpreted text role, that is a sign either of overuse/abuse or
1485    that functionality may be missing from reStructuredText.  Please
1486    describe your situation in a message to the Docutils-users_ mailing
1487    list.
1489 .. _Docutils-users: ../../user/mailing-lists.html#docutils-users
1491 The "raw" directive indicates non-reStructuredText data that is to be
1492 passed untouched to the Writer.  The names of the output formats are
1493 given in the directive arguments.  The interpretation of the raw data
1494 is up to the Writer.  A Writer may ignore any raw output not matching
1495 its format.
1497 For example, the following input would be passed untouched by an HTML
1498 Writer::
1500     .. raw:: html
1502        <hr width=50 size=10>
1504 A LaTeX Writer could insert the following raw content into its
1505 output stream::
1507     .. raw:: latex
1509        \setlength{\parindent}{0pt}
1511 Raw data can also be read from an external file, specified in a
1512 directive option.  In this case, the content block must be empty.  For
1513 example::
1515     .. raw:: html
1516        :file: inclusion.html
1518 Inline equivalents of the "raw" directive can be defined via
1519 `custom interpreted text roles`_ derived from the `"raw" role`_.
1521 The following options are recognized:
1523 ``file`` : string (newlines removed)
1524     The local filesystem path of a raw data file to be included.
1526 ``url`` : string (whitespace removed)
1527     An Internet URL reference to a raw data file to be included.
1529 ``encoding`` : name of text encoding
1530     The text encoding of the external raw data (file or URL).
1531     Defaults to the document's encoding (if specified).
1533 .. _"raw" role: roles.html#raw
1536 .. _classes:
1538 Class
1539 =====
1541 :Directive Type: "class"
1542 :Doctree Element: pending_
1543 :Directive Arguments: One or more, required (class names / attribute
1544                       values).
1545 :Directive Options: None.
1546 :Directive Content: Optional.  If present, it is interpreted as body
1547                     elements.
1549 The "class" directive sets the `"classes"`_ attribute value on its content
1550 or on the first immediately following non-comment element [#]_.  For
1551 details of the "classes" attribute, see `its entry`__ in `The Docutils
1552 Document Tree`_.
1554 The directive argument consists of one or more space-separated class
1555 names. The names are transformed to conform to the regular expression
1556 ``[a-z](-?[a-z0-9]+)*`` by converting
1558 * alphabetic characters to lowercase,
1559 * accented characters to the base character,
1560 * non-alphanumeric characters to hyphens,
1561 * consecutive hyphens into one hyphen.
1563 For example "Rot-Gelb.Blau Grün:+2008" becomes "rot-gelb-blau grun-2008".
1564 (For the rationale_, see below.)
1566 __ ../doctree.html#classes
1568 Examples::
1570     .. class:: special
1572     This is a "special" paragraph.
1574     .. class:: exceptional remarkable
1576     An Exceptional Section
1577     ======================
1579     This is an ordinary paragraph.
1581     .. class:: multiple
1583        First paragraph.
1585        Second paragraph.
1587 The text above is parsed and transformed into this doctree fragment::
1589     <paragraph classes="special">
1590         This is a "special" paragraph.
1591     <section classes="exceptional remarkable">
1592         <title>
1593             An Exceptional Section
1594         <paragraph>
1595             This is an ordinary paragraph.
1596         <paragraph classes="multiple">
1597             First paragraph.
1598         <paragraph classes="multiple">
1599             Second paragraph.
1601 .. [#] To set a "classes" attribute value on a block quote, the
1602    "class" directive must be followed by an empty comment::
1604        .. class:: highlights
1605        ..
1607            Block quote text.
1609    Without the empty comment, the indented text would be interpreted as the
1610    "class" directive's content, and the classes would be applied to each
1611    element (paragraph, in this case) individually, instead of to the block
1612    quote as a whole.
1614 .. _rationale:
1616 .. topic:: Rationale for "classes" Attribute Value Conversion
1619     Docutils identifiers are converted to conform to the regular
1620     expression ``[a-z](-?[a-z0-9]+)*``.  For HTML + CSS compatibility,
1621     identifiers (the "classes" and "id" attributes) should have no
1622     underscores, colons, or periods.  Hyphens may be used.
1624     - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:
1626           ID and NAME tokens must begin with a letter ([A-Za-z]) and
1627           may be followed by any number of letters, digits ([0-9]),
1628           hyphens ("-"), underscores ("_"), colons (":"), and periods
1629           (".").
1631     - The `CSS1 spec`_ defines identifiers based on the "name" token
1632       ("flex" tokenizer notation below; "latin1" and "escape" 8-bit
1633       characters have been replaced with XML entities)::
1635           unicode     \\[0-9a-f]{1,4}
1636           latin1      [&iexcl;-&yuml;]
1637           escape      {unicode}|\\[ -~&iexcl;-&yuml;]
1638           nmchar      [-A-Za-z0-9]|{latin1}|{escape}
1639           name        {nmchar}+
1641     The CSS rule does not include underscores ("_"), colons (":"), or
1642     periods ("."), therefore "classes" and "id" attributes should not
1643     contain these characters.  Combined with HTML's requirements (the
1644     first character must be a letter; no "unicode", "latin1", or
1645     "escape" characters), this results in the regular expression
1646     ``[A-Za-z][-A-Za-z0-9]*``. Docutils adds a normalisation by
1647     downcasing and merge of consecutive hyphens.
1649     .. _HTML 4.01 spec: http://www.w3.org/TR/html401/
1650     .. _CSS1 spec: http://www.w3.org/TR/REC-CSS1
1653 .. _role:
1655 Custom Interpreted Text Roles
1656 =============================
1658 :Directive Type: "role"
1659 :Doctree Element: None; affects subsequent parsing.
1660 :Directive Arguments: Two; one required (new role name), one optional
1661                       (base role name, in parentheses).
1662 :Directive Options: Possible (depends on base role).
1663 :Directive Content: depends on base role.
1665 (New in Docutils 0.3.2)
1667 The "role" directive dynamically creates a custom interpreted text
1668 role and registers it with the parser.  This means that after
1669 declaring a role like this::
1671     .. role:: custom
1673 the document may use the new "custom" role::
1675     An example of using :custom:`interpreted text`
1677 This will be parsed into the following document tree fragment::
1679     <paragraph>
1680         An example of using
1681         <inline classes="custom">
1682             interpreted text
1684 The role must be declared in a document before it can be used.
1686 The new role may be based on an existing role, specified as a second
1687 argument in parentheses (whitespace optional)::
1689     .. role:: custom(emphasis)
1691     :custom:`text`
1693 The parsed result is as follows::
1695     <paragraph>
1696         <emphasis classes="custom">
1697             text
1699 A special case is the `"raw" role`_: derived roles enable
1700 inline `raw data pass-through`_, e.g.::
1702    .. role:: raw-role(raw)
1703       :format: html latex
1705    :raw-role:`raw text`
1707 If no base role is explicitly specified, a generic custom role is
1708 automatically used.  Subsequent interpreted text will produce an
1709 "inline" element with a `"classes"`_ attribute, as in the first example
1710 above.
1712 With most roles, the ":class:" option can be used to set a "classes"
1713 attribute that is different from the role name.  For example::
1715     .. role:: custom
1716        :class: special
1718     :custom:`interpreted text`
1720 This is the parsed result::
1722     <paragraph>
1723         <inline classes="special">
1724             interpreted text
1726 .. _role class:
1728 The following option is recognized by the "role" directive for most
1729 base roles:
1731 ``class`` : text
1732     Set the `"classes"`_ attribute value on the element produced
1733     (``inline``, or element associated with a base class) when the
1734     custom interpreted text role is used.  If no directive options are
1735     specified, a "class" option with the directive argument (role
1736     name) as the value is implied.  See the class_ directive above.
1738 Specific base roles may support other options and/or directive
1739 content.  See the `reStructuredText Interpreted Text Roles`_ document
1740 for details.
1742 .. _reStructuredText Interpreted Text Roles: roles.html
1745 .. _default-role:
1747 Setting the Default Interpreted Text Role
1748 =========================================
1750 :Directive Type: "default-role"
1751 :Doctree Element: None; affects subsequent parsing.
1752 :Directive Arguments: One, optional (new default role name).
1753 :Directive Options: None.
1754 :Directive Content: None.
1756 (New in Docutils 0.3.10)
1758 The "default-role" directive sets the default interpreted text role,
1759 the role that is used for interpreted text without an explicit role.
1760 For example, after setting the default role like this::
1762     .. default-role:: subscript
1764 any subsequent use of implicit-role interpreted text in the document
1765 will use the "subscript" role::
1767     An example of a `default` role.
1769 This will be parsed into the following document tree fragment::
1771     <paragraph>
1772         An example of a
1773         <subscript>
1774             default
1775          role.
1777 Custom roles may be used (see the "role_" directive above), but it
1778 must have been declared in a document before it can be set as the
1779 default role.  See the `reStructuredText Interpreted Text Roles`_
1780 document for details of built-in roles.
1782 The directive may be used without an argument to restore the initial
1783 default interpreted text role, which is application-dependent.  The
1784 initial default interpreted text role of the standard reStructuredText
1785 parser is "title-reference".
1788 Metadata Document Title
1789 =======================
1791 :Directive Type: "title"
1792 :Doctree Element: None.
1793 :Directive Arguments: 1, required (the title text).
1794 :Directive Options: None.
1795 :Directive Content: None.
1797 The "title" directive specifies the document title as metadata, which
1798 does not become part of the document body.  It overrides a
1799 document-supplied title.  For example, in HTML output the metadata
1800 document title appears in the title bar of the browser window.
1803 Restructuredtext-Test-Directive
1804 ===============================
1806 :Directive Type: "restructuredtext-test-directive"
1807 :Doctree Element: system_warning
1808 :Directive Arguments: None.
1809 :Directive Options: None.
1810 :Directive Content: Interpreted as a literal block.
1812 This directive is provided for test purposes only.  (Nobody is
1813 expected to type in a name *that* long!)  It is converted into a
1814 level-1 (info) system message showing the directive data, possibly
1815 followed by a literal block containing the rest of the directive
1816 block.
1818 --------------
1819 Common Options
1820 --------------
1822 Most of the directives that generate doctree elements support the following
1823 options:
1825 _`:class:` : text
1826     Set a `"classes"`_ attribute value on the doctree element generated by
1827     the directive. See also the class_ directive.
1829 _`:name:` : text
1830     Add `text` to the `"names"`_ attribute of the doctree element generated
1831     by the directive. This allows `hyperlink references`_ to the element
1832     using `text` as `reference name`_.
1834     Specifying the `name` option of a directive, e.g., ::
1836       .. image:: bild.png
1837          :name: my picture
1839     is a concise syntax alternative to preceding it with a `hyperlink
1840     target`_ ::
1842       .. _my picture:
1844       .. image:: bild.png
1846     New in Docutils 0.8.
1849 .. _reference name: restructuredtext.html#reference-names
1850 .. _hyperlink target: restructuredtext.html#hyperlink-targets
1851 .. _hyperlink references: restructuredtext.html#hyperlink-references
1852 .. _"classes": ../doctree.html#classes
1853 .. _"names": ../doctree.html#names
1854 .. _admonition: ../doctree.html#admonition
1855 .. _block_quote: ../doctree.html#block-quote
1856 .. _caption: ../doctree.html#caption
1857 .. _compound: ../doctree.html#compound
1858 .. _container: ../doctree.html#container
1859 .. _decoration: ../doctree.html#decoration
1860 .. _figure: ../doctree.html#figure
1861 .. _footnote: ../doctree.html#footnote
1862 .. _footnote_reference: ../doctree.html#footnote-reference
1863 .. _generated: ../doctree.html#generated
1864 .. _image: ../doctree.html#image
1865 .. _inline elements: ../doctree.html#inline-elements
1866 .. _literal_block: ../doctree.html#literal-block
1867 .. _legend: ../doctree.html#legend
1868 .. _line_block: ../doctree.html#line-block
1869 .. _math_block: ../doctree.html#math-block
1870 .. _pending: ../doctree.html#pending
1871 .. _raw: ../doctree.html#raw
1872 .. _rubric: ../doctree.html#rubric
1873 .. _sidebar: ../doctree.html#sidebar
1874 .. _table: ../doctree.html#table
1875 .. _title: ../doctree.html#title
1876 .. _topic: ../doctree.html#topic
1881    Local Variables:
1882    mode: indented-text
1883    indent-tabs-mode: nil
1884    sentence-end-double-space: t
1885    fill-column: 70
1886    End: