Debian Codegraph @

docs/source/_extra/directives.txt

raw
1 =============================
2 reStructuredText Directives
3 =============================
4 :Author: David Goodger
5 :Contact: [email protected]
6 :Revision: $Revision: 8959 $
7 :Date: $Date: 2022-01-21 14:45:42 +0100 (Fr, 21. Jan 2022) $
8 :Copyright: This document has been placed in the public domain.
9
10 .. contents::
11 :depth: 2
12
13 This document describes the directives implemented in the reference
14 reStructuredText parser.
15
16 Directives have the following syntax::
17
18 +-------+-------------------------------+
19 | ".. " | directive type "::" directive |
20 +-------+ block |
21 | |
22 +-------------------------------+
23
24 Directives begin with an explicit markup start (two periods and a
25 space), followed by the directive type and two colons (collectively,
26 the "directive marker"). The directive block begins immediately after
27 the directive marker, and includes all subsequent indented lines. The
28 directive block is divided into arguments, options (a field list), and
29 content (in that order), any of which may appear. See the Directives_
30 section in the `reStructuredText Markup Specification`_ for syntax
31 details.
32
33 Descriptions below list "doctree elements" (document tree element
34 names; XML DTD generic identifiers) corresponding to individual
35 directives. For details on the hierarchy of elements, please see `The
36 Docutils Document Tree`_ and the `Docutils Generic DTD`_ XML document
37 type definition. For directive implementation details, see `Creating
38 reStructuredText Directives`_.
39
40 .. _Directives: restructuredtext.html#directives
41 .. _reStructuredText Markup Specification: restructuredtext.html
42 .. _The Docutils Document Tree: ../doctree.html
43 .. _Docutils Generic DTD: ../docutils.dtd
44 .. _Creating reStructuredText Directives:
45 ../../howto/rst-directives.html
46
47
48 -------------
49 Admonitions
50 -------------
51
52 .. From Webster's Revised Unabridged Dictionary (1913) [web1913]:
53 Admonition
54 Gentle or friendly reproof; counseling against a fault or
55 error; expression of authoritative advice; friendly caution
56 or warning.
57
58 Syn: {Admonition}, {Reprehension}, {Reproof}.
59
60 Usage: Admonition is prospective, and relates to moral delinquencies;
61 its object is to prevent further transgression.
62
63 .. _attention:
64 .. _caution:
65 .. _danger:
66 .. _error:
67 .. _hint:
68 .. _important:
69 .. _note:
70 .. _tip:
71 .. _warning:
72
73 Specific Admonitions
74 ====================
75
76 :Directive Types: "attention", "caution", "danger", "error", "hint",
77 "important", "note", "tip", "warning", "admonition"
78 :Doctree Elements: attention, caution, danger, error, hint, important,
79 note, tip, warning, admonition_, title_
80 :Directive Arguments: None.
81 :Directive Options: class_, name_
82 :Directive Content: Interpreted as body elements.
83
84 Admonitions are specially marked "topics" that can appear anywhere an
85 ordinary body element can. They contain arbitrary body elements.
86 Typically, an admonition is rendered as an offset block in a document,
87 sometimes outlined or shaded, with a title matching the admonition
88 type. For example::
89
90 .. DANGER::
91 Beware killer rabbits!
92
93 This directive might be rendered something like this::
94
95 +------------------------+
96 | !DANGER! |
97 | |
98 | Beware killer rabbits! |
99 +------------------------+
100
101 The following admonition directives have been implemented:
102
103 - attention
104 - caution
105 - danger
106 - error
107 - hint
108 - important
109 - note
110 - tip
111 - warning
112
113 Any text immediately following the directive indicator (on the same
114 line and/or indented on following lines) is interpreted as a directive
115 block and is parsed for normal body elements. For example, the
116 following "note" admonition directive contains one paragraph and a
117 bullet list consisting of two list items::
118
119 .. note:: This is a note admonition.
120 This is the second line of the first paragraph.
121
122 - The note contains all indented body elements
123 following.
124 - It includes this bullet list.
125
126
127 Generic Admonition
128 ==================
129
130 :Directive Type: "admonition"
131 :Doctree Elements: admonition_, title_
132 :Directive Arguments: One, required (admonition title)
133 :Directive Options: class_, name_
134 :Directive Content: Interpreted as body elements.
135
136 This is a generic, titled admonition. The title may be anything the
137 author desires.
138
139 The author-supplied title is also used as a `"classes"`_ attribute value
140 after being converted into a valid identifier form (down-cased;
141 non-alphanumeric characters converted to single hyphens; "admonition-"
142 prefixed). For example, this admonition::
143
144 .. admonition:: And, by the way...
145
146 You can make up your own admonition too.
147
148 becomes the following document tree (pseudo-XML)
149
150 .. code-block:: xml
151
152 <document source="test data">
153 <admonition classes="admonition-and-by-the-way">
154 <title>
155 And, by the way...
156 <paragraph>
157 You can make up your own admonition too.
158
159 The class_ option overrides the computed `"classes"`_ attribute
160 value.
161
162
163 --------
164 Images
165 --------
166
167 There are two image directives: "image" and "figure".
168
169 It is up to the author to ensure compatibility of the image data format
170 with the output format or user agent (LaTeX__ engine, `HTML5 browser`__,
171 ODT, ...). The following, non exhaustive table provides an overview
172
173 .. [#] The html5 writer uses the ``<video>`` tag if the image URI points
174 to a file with an extension matching one of the listed video formats
175 (since Docutils 0.17).
176
177 .. [#] The html4 writer uses an ``<object>`` tag for SVG images for better
178 compatibility with older browsers.
179
180 .. [#] When compiling with ``pdflatex``, ``xelatex``, or ``lualatex``.
181 The original ``latex`` engine supports only the EPS image format.
182 Some build systems, e.g. rubber_ support additional formats via
183 on-the-fly image conversion.
184
185 __ ../../user/latex.html#image-inclusion
186 __ https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types
187 .. _rubber: https://github.com/petrhosek/rubber
188
189 Image
190 =====
191
192 :Directive Type: "image"
193 :Doctree Element: image_
194 :Directive Arguments: One, required (image URI).
195 :Directive Options: Possible (see below).
196 :Directive Content: None.
197
198 An "image" is a simple picture::
199
200 .. image:: picture.png
201
202 Inline images can be defined with an "image" directive in a `substitution
203 definition`_
204
205 The URI for the image source file is specified in the directive
206 argument. As with hyperlink targets, the image URI may begin on the
207 same line as the explicit markup start and target name, or it may
208 begin in an indented text block immediately following, with no
209 intervening blank lines. If there are multiple lines in the link
210 block, they are stripped of leading and trailing whitespace and joined
211 together.
212
213 Optionally, the image link block may contain a flat field list, the
214 _`image options`. For example::
215
216 .. image:: picture.jpeg
217 :height: 100px
218 :width: 200 px
219 :scale: 50 %
220 :alt: alternate text
221 :align: right
222
223 The following options are recognized:
224
225 ``alt`` : text
226 Alternate text: a short description of the image, displayed by
227 applications that cannot display images, or spoken by applications
228 for visually impaired users.
229
230 ``height`` : `length`_
231 The desired height of the image.
232 Used to reserve space or scale the image vertically. When the "scale"
233 option is also specified, they are combined. For example, a height of
234 200px and a scale of 50 is equivalent to a height of 100px with no scale.
235
236 ``width`` : `length`_ or `percentage`_ of the current line width
237 The width of the image.
238 Used to reserve space or scale the image horizontally. As with "height"
239 above, when the "scale" option is also specified, they are combined.
240
241 ``scale`` : integer percentage (the "%" symbol is optional)
242 The uniform scaling factor of the image. The default is "100Â %", i.e.
243 no scaling.
244
245 If no "height" or "width" options are specified, the `Python
246 Imaging Library` (PIL/Pillow_) may be used to determine them, if
247 it is installed and the image file is available.
248
249 ``align`` : "top", "middle", "bottom", "left", "center", or "right"
250 The alignment of the image, equivalent to the HTML ``<img>`` tag's
251 deprecated "align" attribute or the corresponding "vertical-align" and
252 "text-align" CSS properties.
253 The values "top", "middle", and "bottom"
254 control an image's vertical alignment (relative to the text
255 baseline); they are only useful for inline images (substitutions).
256 The values "left", "center", and "right" control an image's
257 horizontal alignment, allowing the image to float and have the
258 text flow around it. The specific behavior depends upon the
259 browser or rendering software used.
260
261 ``target`` : text (URI or reference name)
262 Makes the image into a hyperlink reference ("clickable"). The
263 option argument may be a URI (relative or absolute), or a
264 `reference name`_ with underscore suffix (e.g. ```a name`_``).
265
266 and the common options class_ and name_.
267
268
269 Figure
270 ======
271
272 :Directive Type: "figure"
273 :Doctree Elements: figure_, image_, caption_, legend_
274 :Directive Arguments: One, required (image URI).
275 :Directive Options: Possible (see below).
276 :Directive Content: Interpreted as the figure caption and an optional
277 legend.
278
279 A "figure" consists of image_ data (including `image options`_), an optional
280 caption (a single paragraph), and an optional legend (arbitrary body
281 elements). For page-based output media, figures might float to a different
282 position if this helps the page layout.
283 ::
284
285 .. figure:: picture.png
286 :scale: 50 %
287 :alt: map to buried treasure
288
289 This is the caption of the figure (a simple paragraph).
290
291 There must be blank lines before the caption paragraph and before the
292 legend. To specify a legend without a caption, use an empty comment
293 ("..") in place of the caption.
294
295 The "figure" directive supports all of the options of the "image"
296 directive (see `image options`_ above). These options (except
297 "align") are passed on to the contained image.
298
299 ``align`` : "left", "center", or "right"
300 The horizontal alignment of the figure, allowing the image to
301 float and have the text flow around it. The specific behavior
302 depends upon the browser or rendering software used.
303
304 In addition, the following options are recognized:
305
306 ``figwidth`` : "image", length_, or percentage_ of current line width
307 The width of the figure.
308 Limits the horizontal space used by the figure.
309 A special value of "image" is allowed, in which case the
310 included image's actual width is used (requires the `Python Imaging
311 Library`_). If the image file is not found or the required software is
312 unavailable, this option is ignored.
313
314 Sets the "width" attribute of the "figure" doctree element.
315
316 This option does not scale the included image; use the "width"
317 `image`_ option for that.
318
319 ``figclass`` : text
320 Set a `"classes"`_ attribute value on the figure element. See the
321 class_ directive below.
322
323 .. _Python Imaging Library:
324 .. _Pillow: https://pypi.org/project/Pillow/
325
326
327 ---------------
328 Body Elements
329 ---------------
330
331 Topic
332 =====
333
334 :Directive Type: "topic"
335 :Doctree Element: topic_
336 :Directive Arguments: One, required (topic title).
337 :Directive Options: class_, name_
338 :Directive Content: Interpreted as the topic body.
339
340 A topic is like a block quote with a title, or a self-contained
341 section with no subsections. Use the "topic" directive to indicate a
342 self-contained idea that is separate from the flow of the document.
343 Topics may occur anywhere a section or transition may occur. Body
344 elements and topics may not contain nested topics.
345
346 The directive's sole argument is interpreted as the topic title; the
347 next line must be blank. All subsequent lines make up the topic body,
348 interpreted as body elements. For example::
349
350 .. topic:: Topic Title
351
352 Subsequent indented lines comprise
353 the body of the topic, and are
354 interpreted as body elements.
355
356
357 Sidebar
358 =======
359
360 :Directive Type: "sidebar"
361 :Doctree Element: sidebar_
362 :Directive Arguments: One, optional (sidebar title).
363 :Directive Options: Possible (see below).
364 :Directive Content: Interpreted as the sidebar body.
365
366 Sidebars are like miniature, parallel documents that occur inside
367 other documents, providing related or reference material. A sidebar
368 is typically offset by a border and "floats" to the side of the page;
369 the document's main text may flow around it. Sidebars can also be
370 likened to super-footnotes; their content is outside of the flow of
371 the document's main text.
372
373 Sidebars may occur anywhere a section or transition may occur. Body
374 elements (including sidebars) may not contain nested sidebars.
375
376 The directive's sole argument is interpreted as the sidebar title,
377 which may be followed by a subtitle option (see below); the next line
378 must be blank. All subsequent lines make up the sidebar body,
379 interpreted as body elements. For example::
380
381 .. sidebar:: Optional Sidebar Title
382 :subtitle: Optional Sidebar Subtitle
383
384 Subsequent indented lines comprise
385 the body of the sidebar, and are
386 interpreted as body elements.
387
388 The following options are recognized:
389
390 ``subtitle`` : text
391 The sidebar's subtitle.
392
393 and the common options class_ and name_.
394
395
396 Line Block
397 ==========
398
399 .. admonition:: Deprecated
400
401 The "line-block" directive is deprecated. Use the `line block
402 syntax`_ instead.
403
404 .. _line block syntax: restructuredtext.html#line-blocks
405
406 :Directive Type: "line-block"
407 :Doctree Element: line_block_
408 :Directive Arguments: None.
409 :Directive Options: class_, name_
410 :Directive Content: Becomes the body of the line block.
411
412 The "line-block" directive constructs an element where line breaks and
413 initial indentation is significant and inline markup is supported. It
414 is equivalent to a `parsed literal block`_ with different rendering:
415 typically in an ordinary serif typeface instead of a
416 typewriter/monospaced face, and not automatically indented. (Have the
417 line-block directive begin a block quote to get an indented line
418 block.) Line blocks are useful for address blocks and verse (poetry,
419 song lyrics), where the structure of lines is significant. For
420 example, here's a classic::
421
422 "To Ma Own Beloved Lassie: A Poem on her 17th Birthday", by
423 Ewan McTeagle (for Lassie O'Shea):
424
425 .. line-block::
426
427 Lend us a couple of bob till Thursday.
428 I'm absolutely skint.
429 But I'm expecting a postal order and I can pay you back
430 as soon as it comes.
431 Love, Ewan.
432
433
434
435 .. _parsed-literal:
436
437 Parsed Literal Block
438 ====================
439
440 :Directive Type: "parsed-literal"
441 :Doctree Element: literal_block_
442 :Directive Arguments: None.
443 :Directive Options: class_, name_
444 :Directive Content: Becomes the body of the literal block.
445
446 Unlike an ordinary literal block, the "parsed-literal" directive
447 constructs a literal block where the text is parsed for inline markup.
448 It is equivalent to a `line block`_ with different rendering:
449 typically in a typewriter/monospaced typeface, like an ordinary
450 literal block. Parsed literal blocks are useful for adding hyperlinks
451 to code examples.
452
453 However, care must be taken with the text, because inline markup is
454 recognized and there is no protection from parsing. Backslash-escapes
455 may be necessary to prevent unintended parsing. And because the
456 markup characters are removed by the parser, care must also be taken
457 with vertical alignment. Parsed "ASCII art" is tricky, and extra
458 whitespace may be necessary.
459
460 For example, all the element names in this content model are links::
461
462 .. parsed-literal::
463
464 ( (title_, subtitle_?)?,
465 decoration_?,
466 (docinfo_, transition_?)?,
467 `%structure.model;`_ )
468
469 Code
470 ====
471
472 :Directive Type: "code"
473 :Doctree Element: literal_block_, `inline elements`_
474 :Directive Arguments: One, optional (formal language).
475 :Directive Options: name, class, number-lines.
476 :Directive Content: Becomes the body of the literal block.
477 :Configuration Setting: syntax_highlight_.
478
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 requires
483 a style-sheet (e.g. one `generated by Pygments`__, see the
484 `sandbox/stylesheets`__ for examples).
485
486 The parsing can be turned off with the syntax_highlight_ configuration
487 setting and command line option or by specifying the language as class_
488 option instead of directive argument. This also avoids warnings
489 when Pygments_ is not installed or the language is not in the
490 `supported languages and markup formats`_.
491
492 For inline code, use the `"code" role`_.
493
494 __ https://pygments.org/docs/cmdline/#generating-styles
495 __ https://docutils.sourceforge.io/sandbox/stylesheets/
496 .. _Pygments: https://pygments.org/
497 .. _syntax_highlight: ../../user/config.html#syntax-highlight
498 .. _supported languages and markup formats: https://pygments.org/languages/
499 .. _"code" role: roles.html#code
500
501
502 The following options are recognized:
503
504 ``number-lines`` : [integer] (start line number)
505 Precede every line with a line number.
506 The optional argument is the number of the first line (default 1).
507
508 and the common options class_ and name_.
509
510 Example::
511 The content of the following directive ::
512
513 .. code:: python
514
515 def my_function():
516 "just a test"
517 print 8/2
518
519 is parsed and marked up as Python source code.
520
521
522 Math
523 ====
524
525 :Directive Type: "math"
526 :Doctree Element: math_block_
527 :Directive Arguments: None.
528 :Directive Options: class_, name_
529 :Directive Content: Becomes the body of the math block.
530 (Content blocks separated by a blank line are put in
531 adjacent math blocks.)
532 :Configuration Setting: math_output_
533
534 The "math" directive inserts blocks with mathematical content
535 (display formulas, equations) into the document. The input format is
536 `LaTeX math syntax`_ with support for Unicode symbols, for example::
537
538 .. math::
539
540 α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)
541
542 Support is limited to a subset of *LaTeX math* by the conversion
543 required for many output formats. For HTML, the `math_output`_
544 configuration setting (or the corresponding ``--math-output``
545 command line option) select between alternative output formats with
546 different subsets of supported elements. If a writer does not
547 support math typesetting, the content is inserted verbatim.
548
549 For inline formulas, use the `"math" role`_.
550
551 .. _LaTeX math syntax: ../../ref/rst/mathematics.html
552 .. _"math" role: roles.html#math
553 .. _math_output: ../../user/config.html#math-output
554
555
556 Rubric
557 ======
558
559 :Directive Type: "rubric"
560 :Doctree Element: rubric_
561 :Directive Arguments: One, required (rubric text).
562 :Directive Options: class_, name_
563 :Directive Content: None.
564
565 ..
566
567 rubric n. 1. a title, heading, or the like, in a manuscript,
568 book, statute, etc., written or printed in red or otherwise
569 distinguished from the rest of the text. ...
570
571 -- Random House Webster's College Dictionary, 1991
572
573 The "rubric" directive inserts a "rubric" element into the document
574 tree. A rubric is like an informal heading that doesn't correspond to
575 the document's structure.
576
577
578 Epigraph
579 ========
580
581 :Directive Type: "epigraph"
582 :Doctree Element: block_quote_
583 :Directive Arguments: None.
584 :Directive Options: None.
585 :Directive Content: Interpreted as the body of the block quote.
586
587 An epigraph is an apposite (suitable, apt, or pertinent) short
588 inscription, often a quotation or poem, at the beginning of a document
589 or section.
590
591 The "epigraph" directive produces an "epigraph"-class block quote.
592 For example, this input::
593
594 .. epigraph::
595
596 No matter where you go, there you are.
597
598 -- Buckaroo Banzai
599
600 becomes this document tree fragment::
601
602 <block_quote classes="epigraph">
603 <paragraph>
604 No matter where you go, there you are.
605 <attribution>
606 Buckaroo Banzai
607
608
609 Highlights
610 ==========
611
612 :Directive Type: "highlights"
613 :Doctree Element: block_quote_
614 :Directive Arguments: None.
615 :Directive Options: None.
616 :Directive Content: Interpreted as the body of the block quote.
617
618 Highlights summarize the main points of a document or section, often
619 consisting of a list.
620
621 The "highlights" directive produces a "highlights"-class block quote.
622 See Epigraph_ above for an analogous example.
623
624
625 Pull-Quote
626 ==========
627
628 :Directive Type: "pull-quote"
629 :Doctree Element: block_quote_
630 :Directive Arguments: None.
631 :Directive Options: None.
632 :Directive Content: Interpreted as the body of the block quote.
633
634 A pull-quote is a small selection of text "pulled out and quoted",
635 typically in a larger typeface. Pull-quotes are used to attract
636 attention, especially in long articles.
637
638 The "pull-quote" directive produces a "pull-quote"-class block quote.
639 See Epigraph_ above for an analogous example.
640
641
642 Compound Paragraph
643 ==================
644
645 :Directive Type: "compound"
646 :Doctree Element: compound_
647 :Directive Arguments: None.
648 :Directive Options: class_, name_
649 :Directive Content: Interpreted as body elements.
650
651 The "compound" directive is used to create a compound paragraph, which
652 is a single logical paragraph containing multiple physical body
653 elements such as simple paragraphs, literal blocks, tables, lists,
654 etc., instead of directly containing text and inline elements. For
655 example::
656
657 .. compound::
658
659 The 'rm' command is very dangerous. If you are logged
660 in as root and enter ::
661
662 cd /
663 rm -rf *
664
665 you will erase the entire contents of your file system.
666
667 In the example above, a literal block is "embedded" within a sentence
668 that begins in one physical paragraph and ends in another.
669
670 .. note::
671
672 The "compound" directive is *not* a generic block-level container
673 like HTML's ``<div>`` element. Do not use it only to group a
674 sequence of elements, or you may get unexpected results.
675
676 If you need a generic block-level container, please use the
677 container_ directive, described below.
678
679 Compound paragraphs are typically rendered as multiple distinct text
680 blocks, with the possibility of variations to emphasize their logical
681 unity:
682
683 * If paragraphs are rendered with a first-line indent, only the first
684 physical paragraph of a compound paragraph should have that indent
685 -- second and further physical paragraphs should omit the indents;
686 * vertical spacing between physical elements may be reduced;
687 * and so on.
688
689
690 Container
691 =========
692
693 :Directive Type: "container"
694 :Doctree Element: `container <container element_>`__
695 :Directive Arguments: One or more, optional (class names).
696 :Directive Options: name_
697 :Directive Content: Interpreted as body elements.
698
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::
703
704 .. container:: custom
705
706 This paragraph might be rendered in a custom way.
707
708 Parsing the above results in the following pseudo-XML
709
710 .. code-block:: xml
711
712 <container classes="custom">
713 <paragraph>
714 This paragraph might be rendered in a custom way.
715
716 The "container" directive is the equivalent of HTML's ``<div>``
717 element. It may be used to group a sequence of elements for user- or
718 application-specific purposes.
719
720
721
722 --------
723 Tables
724 --------
725
726 Formal tables need more structure than the reStructuredText syntax
727 supplies. Tables may be given titles with the table_ directive.
728 Sometimes reStructuredText tables are inconvenient to write, or table
729 data in a standard format is readily available. The csv-table_
730 directive supports CSV data.
731
732
733 Table
734 =====
735
736 :Directive Type: "table"
737 :Doctree Element: table_
738 :Directive Arguments: One, optional (table title).
739 :Directive Options: Possible (see below).
740 :Directive Content: A normal `reStructuredText table`_.
741
742 The "table" directive is used to associate a
743 title with a table or specify options, e.g.::
744
745 .. table:: Truth table for "not"
746 :widths: auto
747
748 ===== =====
749 A not A
750 ===== =====
751 False True
752 True False
753 ===== =====
754
755 The following options are recognized:
756
757 ``align`` : "left", "center", or "right"
758 The horizontal alignment of the table (new in Docutils 0.13).
759
760 ``width`` : `length`_ or `percentage`_
761 Sets the width of the table to the specified length or percentage
762 of the line width. If omitted, the renderer determines the width
763 of the table based on its contents or the column ``widths``.
764
765 .. _column-widths:
766
767 ``widths`` : "auto", "grid", or a list of integers
768 A list of relative column widths.
769 The default is the width of the input columns (in characters).
770
771 *"auto"* delegates the determination of column widths to the backend
772 (LaTeX, the HTML browser, ...).
773
774 *"grid"* restores the default, overriding a `table_style`_ or class
775 value "colwidths-auto".
776
777 Plus the common options class_ and name_.
778
779 .. _reStructuredText table: restructuredtext.html#tables
780 .. _table_style: ../../user/config.html#table-style
781
782
783 .. _csv-table:
784
785 CSV Table
786 =========
787
788 :Directive Type: "csv-table"
789 :Doctree Element: table_
790 :Directive Arguments: One, optional (table title).
791 :Directive Options: Possible (see below).
792 :Directive Content: A CSV (comma-separated values) table.
793
794 .. WARNING::
795
796 The "csv-table" directive's ":file:" and ":url:" options represent
797 a potential security holes. They can be disabled with the
798 "file_insertion_enabled_" runtime setting.
799
800 The "csv-table" directive is used to create a table from CSV
801 (comma-separated values) data. CSV is a common data format generated
802 by spreadsheet applications and commercial databases. The data may be
803 internal (an integral part of the document) or external (a separate
804 file).
805
806 * Block markup and inline markup within cells is supported. Line ends
807 are recognized within cells.
808
809 * There is no support for checking that the number of columns in each
810 row is the same. The directive automatically adds empty entries at
811 the end of short rows.
812
813 .. Add "strict" option to verify input?
814
815 Example::
816
817 .. csv-table:: Frozen Delights!
818 :header: "Treat", "Quantity", "Description"
819 :widths: 15, 10, 30
820
821 "Albatross", 2.99, "On a stick!"
822 "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
823 crunchy, now would it?"
824 "Gannet Ripple", 1.99, "On a stick!"
825
826 The following options are recognized:
827
828 ``align`` : "left", "center", or "right"
829 The horizontal alignment of the table. (New in Docutils 0.13)
830
831 ``delim`` : char | "tab" | "space" [#whitespace-delim]_
832 A one-character string\ [#ASCII-char]_ used to separate fields.
833 Defaults to ``,`` (comma). May be specified as a Unicode code
834 point; see the unicode_ directive for syntax details.
835
836 ``encoding`` : string
837 The text encoding of the external CSV data (file or URL).
838 Defaults to the document's input_encoding_.
839
840 ``escape`` : char
841 A one-character\ [#ASCII-char]_ string used to escape the
842 delimiter or quote characters. May be specified as a Unicode
843 code point; see the unicode_ directive for syntax details. Used
844 when the delimiter is used in an unquoted field, or when quote
845 characters are used within a field. The default is to double-up
846 the character, e.g. "He said, ""Hi!"""
847
848 .. Add another possible value, "double", to explicitly indicate
849 the default case?
850
851 ``file`` : string (newlines removed)
852 The local filesystem path to a CSV data file.
853
854 ``header`` : CSV data
855 Supplemental data for the table header, added independently of and
856 before any ``header-rows`` from the main CSV data. Must use the
857 same CSV format as the main CSV data.
858
859 ``header-rows`` : integer
860 The number of rows of CSV data to use in the table header.
861 Defaults to 0.
862
863 ``keepspace`` : flag (empty)
864 Treat whitespace immediately following the delimiter as
865 significant. The default is to ignore such whitespace.
866
867 ``quote`` : char
868 A one-character string\ [#ASCII-char]_ used to quote elements
869 containing the delimiter or which start with the quote
870 character. Defaults to ``"`` (quote). May be specified as a
871 Unicode code point; see the unicode_ directive for syntax
872 details.
873
874 ``stub-columns`` : integer
875 The number of table columns to use as stubs (row titles, on the
876 left). Defaults to 0.
877
878 ``url`` : string (whitespace removed)
879 An Internet URL reference to a CSV data file.
880
881 ``widths`` : integer [integer...] or "auto"
882 A list of relative column widths.
883 The default is equal-width columns (100%/#columns).
884
885 "auto" delegates the determination of column widths to the backend
886 (LaTeX, the HTML browser, ...).
887
888 ``width`` : `length`_ or `percentage`_
889 Sets the width of the table to the specified length or percentage
890 of the line width. If omitted, the renderer determines the width
891 of the table based on its contents or the column ``widths``.
892
893 and the common options class_ and name_.
894
895 .. [#whitespace-delim] Whitespace delimiters are supported only for external
896 CSV files.
897
898 .. [#ASCII-char] With Python 2, the values for the ``delimiter``,
899 ``quote``, and ``escape`` options must be ASCII characters. (The csv
900 module does not support Unicode and all non-ASCII characters are
901 encoded as multi-byte utf-8 string). This limitation does not exist
902 under Python 3.
903
904
905 List Table
906 ==========
907
908 :Directive Type: "list-table"
909 :Doctree Element: table_
910 :Directive Arguments: One, optional (table title).
911 :Directive Options: Possible (see below).
912 :Directive Content: A uniform two-level bullet list.
913
914 (This is an initial implementation; `further ideas`__ may be implemented
915 in the future.)
916
917 __ ../../dev/rst/alternatives.html#list-driven-tables
918
919 The "list-table" directive is used to create a table from data in a
920 uniform two-level bullet list. "Uniform" means that each sublist
921 (second-level list) must contain the same number of list items.
922
923 Example::
924
925 .. list-table:: Frozen Delights!
926 :widths: 15 10 30
927 :header-rows: 1
928
929 * - Treat
930 - Quantity
931 - Description
932 * - Albatross
933 - 2.99
934 - On a stick!
935 * - Crunchy Frog
936 - 1.49
937 - If we took the bones out, it wouldn't be
938 crunchy, now would it?
939 * - Gannet Ripple
940 - 1.99
941 - On a stick!
942
943 The following options are recognized:
944
945
946 ``align`` : "left", "center", or "right"
947 The horizontal alignment of the table.
948 (New in Docutils 0.13)
949
950 ``header-rows`` : integer
951 The number of rows of list data to use in the table header.
952 Defaults to 0.
953
954 ``stub-columns`` : integer
955 The number of table columns to use as stubs (row titles, on the
956 left). Defaults to 0.
957
958 .. _table width:
959
960 ``width`` : `length`_ or `percentage`_
961 Sets the width of the table to the specified length or percentage
962 of the line width. If omitted, the renderer determines the width
963 of the table based on its contents or the column ``widths``.
964
965 .. _column widths:
966
967 ``widths`` : integer [integer...] or "auto"
968 A list of relative column widths.
969 The default is equal-width columns (100%/#columns).
970
971 "auto" delegates the determination of column widths to the backend
972 (LaTeX, the HTML browser, ...).
973
974 and the common options class_ and name_.
975
976
977 ----------------
978 Document Parts
979 ----------------
980
981 .. _contents:
982
983 Table of Contents
984 =================
985
986 :Directive Type: "contents"
987 :Doctree Elements: pending_, topic_
988 :Directive Arguments: One, optional: title.
989 :Directive Options: Possible (see below).
990 :Directive Content: None.
991
992 The "contents" directive generates a table of contents (TOC) in a
993 topic_. Topics, and therefore tables of contents, may occur anywhere
994 a section or transition may occur. Body elements and topics may not
995 contain tables of contents.
996
997 Here's the directive in its simplest form::
998
999 .. contents::
1000
1001 Language-dependent boilerplate text will be used for the title. The
1002 English default title text is "Contents".
1003
1004 An explicit title may be specified::
1005
1006 .. contents:: Table of Contents
1007
1008 The title may span lines, although it is not recommended::
1009
1010 .. contents:: Here's a very long Table of
1011 Contents title
1012
1013 Options may be specified for the directive, using a field list::
1014
1015 .. contents:: Table of Contents
1016 :depth: 2
1017
1018 If the default title is to be used, the options field list may begin
1019 on the same line as the directive marker::
1020
1021 .. contents:: :depth: 2
1022
1023 The following options are recognized:
1024
1025 ``depth`` : integer
1026 The number of section levels that are collected in the table of
1027 contents. The default is unlimited depth.
1028
1029 ``local`` : flag (empty)
1030 Generate a local table of contents. Entries will only include
1031 subsections of the section in which the directive is given. If no
1032 explicit title is given, the table of contents will not be titled.
1033
1034 ``backlinks`` : "entry" or "top" or "none"
1035 Generate links from section headers back to the table of contents
1036 entries, the table of contents itself, or generate no back-links.
1037
1038 ``class`` : text
1039 Set a `"classes"`_ attribute value on the topic element. See the
1040 class_ directive below.
1041
1042
1043 .. _sectnum:
1044 .. _section-numbering:
1045
1046 Automatic Section Numbering
1047 ===========================
1048
1049 :Directive Type: "sectnum" or "section-numbering" (synonyms)
1050 :Doctree Elements: pending_, generated_
1051 :Directive Arguments: None.
1052 :Directive Options: Possible (see below).
1053 :Directive Content: None.
1054 :Configuration Setting: sectnum_xform_
1055
1056 The "sectnum" (or "section-numbering") directive automatically numbers
1057 sections and subsections in a document (if not disabled by the
1058 ``--no-section-numbering`` command line option or the `sectnum_xform`_
1059 configuration setting).
1060
1061 Section numbers are of the "multiple enumeration" form, where each
1062 level has a number, separated by periods. For example, the title of section
1063 1, subsection 2, subsubsection 3 would have "1.2.3" prefixed.
1064
1065 The "sectnum" directive does its work in two passes: the initial parse
1066 and a transform. During the initial parse, a "pending" element is
1067 generated which acts as a placeholder, storing any options internally.
1068 At a later stage in the processing, the "pending" element triggers a
1069 transform, which adds section numbers to titles. Section numbers are
1070 enclosed in a "generated" element, and titles have their "auto"
1071 attribute set to "1".
1072
1073 The following options are recognized:
1074
1075 ``depth`` : integer
1076 The number of section levels that are numbered by this directive.
1077 The default is unlimited depth.
1078
1079 ``prefix`` : string
1080 An arbitrary string that is prefixed to the automatically
1081 generated section numbers. It may be something like "3.2.", which
1082 will produce "3.2.1", "3.2.2", "3.2.2.1", and so on. Note that
1083 any separating punctuation (in the example, a period, ".") must be
1084 explicitly provided. The default is no prefix.
1085
1086 ``suffix`` : string
1087 An arbitrary string that is appended to the automatically
1088 generated section numbers. The default is no suffix.
1089
1090 ``start`` : integer
1091 The value that will be used for the first section number.
1092 Combined with ``prefix``, this may be used to force the right
1093 numbering for a document split over several source files. The
1094 default is 1.
1095
1096 .. _sectnum_xform: ../../user/config.html#sectnum-xform
1097
1098
1099 .. _header:
1100 .. _footer:
1101
1102 Document Header & Footer
1103 ========================
1104
1105 :Directive Types: "header" and "footer"
1106 :Doctree Elements: decoration_, header, footer
1107 :Directive Arguments: None.
1108 :Directive Options: None.
1109 :Directive Content: Interpreted as body elements.
1110
1111 The "header" and "footer" directives create document decorations,
1112 useful for page navigation, notes, time/datestamp, etc. For example::
1113
1114 .. header:: This space for rent.
1115
1116 This will add a paragraph to the document header, which will appear at
1117 the top of the generated web page or at the top of every printed page.
1118
1119 These directives may be used multiple times, cumulatively. There is
1120 currently support for only one header and footer.
1121
1122 .. note::
1123
1124 While it is possible to use the "header" and "footer" directives to
1125 create navigational elements for web pages, you should be aware
1126 that Docutils is meant to be used for *document* processing, and
1127 that a navigation bar is not typically part of a document.
1128
1129 Thus, you may soon find Docutils' abilities to be insufficient for
1130 these purposes. At that time, you should consider using a
1131 documentation generator like Sphinx_ rather than the "header" and
1132 "footer" directives.
1133
1134 .. _Sphinx: http://sphinx-doc.org/
1135
1136 In addition to the use of these directives to populate header and
1137 footer content, content may also be added automatically by the
1138 processing system. For example, if certain runtime settings are
1139 enabled, the document footer is populated with processing information
1140 such as a datestamp, a link to `the Docutils website`_, etc.
1141
1142 .. _the Docutils website: https://docutils.sourceforge.io
1143
1144
1145 ------------
1146 References
1147 ------------
1148
1149 .. _target-notes:
1150
1151 Target Footnotes
1152 ================
1153
1154 :Directive Type: "target-notes"
1155 :Doctree Elements: pending_, footnote_, footnote_reference_
1156 :Directive Arguments: None.
1157 :Directive Options: class_, name_
1158 :Directive Options: Possible (see below).
1159 :Directive Content: None.
1160
1161 The "target-notes" directive creates a footnote for each external
1162 target in the text, and corresponding footnote references after each
1163 reference. For every explicit target (of the form, ``.. _target name:
1164 URL``) in the text, a footnote will be generated containing the
1165 visible URL as content.
1166
1167
1168 Footnotes
1169 =========
1170
1171 **NOT IMPLEMENTED YET**
1172
1173 :Directive Type: "footnotes"
1174 :Doctree Elements: pending_, topic_
1175 :Directive Arguments: None?
1176 :Directive Options: Possible?
1177 :Directive Content: None.
1178
1179 @@@
1180
1181
1182 Citations
1183 =========
1184
1185 **NOT IMPLEMENTED YET**
1186
1187 :Directive Type: "citations"
1188 :Doctree Elements: pending_, topic_
1189 :Directive Arguments: None?
1190 :Directive Options: Possible?
1191 :Directive Content: None.
1192
1193 @@@
1194
1195
1196 ---------------
1197 HTML-Specific
1198 ---------------
1199
1200 Imagemap
1201 ========
1202
1203 **NOT IMPLEMENTED YET**
1204
1205 Non-standard element: imagemap.
1206
1207
1208 -----------------------------------------
1209 Directives for Substitution Definitions
1210 -----------------------------------------
1211
1212 The directives in this section may only be used in `substitution
1213 definitions`_. They may not be used directly, in standalone context.
1214 The `image`_ directive may be used both in substitution definitions
1215 and in the standalone context.
1216
1217 .. _substitution definitions:
1218 .. _substitution definition: restructuredtext.html#substitution-definitions
1219
1220 .. _replace:
1221
1222 Replacement Text
1223 ================
1224
1225 :Directive Type: "replace"
1226 :Doctree Element: Text & `inline elements`_
1227 :Directive Arguments: None.
1228 :Directive Options: None.
1229 :Directive Content: A single paragraph; may contain inline markup.
1230
1231 The "replace" directive is used to indicate replacement text for a
1232 substitution reference. It may be used within `substitution
1233 definitions`_ only. For example, this directive can be used to expand
1234 abbreviations::
1235
1236 .. |reST| replace:: reStructuredText
1237
1238 Yes, |reST| is a long word, so I can't blame anyone for wanting to
1239 abbreviate it.
1240
1241 As reStructuredText doesn't support nested inline markup, the only way
1242 to create a reference with styled text is to use substitutions with
1243 the "replace" directive::
1244
1245 I recommend you try |Python|_.
1246
1247 .. |Python| replace:: Python, *the* best language around
1248 .. _Python: https://www.python.org/
1249
1250
1251 .. _unicode:
1252
1253 Unicode Character Codes
1254 =======================
1255
1256 :Directive Type: "unicode"
1257 :Doctree Element: Text
1258 :Directive Arguments: One or more, required (Unicode character codes,
1259 optional text, and comments).
1260 :Directive Options: Possible (see below).
1261 :Directive Content: None.
1262
1263 The "unicode" directive converts Unicode character codes (numerical
1264 values) to characters, and may be used in `substitution definitions`_
1265 only.
1266
1267 The arguments, separated by spaces, can be:
1268
1269 * **character codes** as
1270
1271 - decimal numbers or
1272
1273 - hexadecimal numbers, prefixed by ``0x``, ``x``, ``\x``, ``U+``, ``u``, or ``\u`` or as XML-style hexadecimal character entities, e.g. ``&#x1a2b;``
1274
1275 * **text**, which is used as-is.
1276
1277 Text following " .. " is a comment and is ignored. The spaces between
1278 the arguments are ignored and thus do not appear in the output.
1279 Hexadecimal codes are case-insensitive.
1280
1281 For example, the following text::
1282
1283 Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1284 all rights reserved.
1285
1286 .. |copy| unicode:: 0xA9 .. copyright sign
1287 .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1288 .. with trademark sign
1289 .. |---| unicode:: U+02014 .. em dash
1290 :trim:
1291
1292 results in:
1293
1294 Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1295 all rights reserved.
1296
1297 .. |copy| unicode:: 0xA9 .. copyright sign
1298 .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1299 .. with trademark sign
1300 .. |---| unicode:: U+02014 .. em dash
1301 :trim:
1302
1303 The following options are recognized:
1304
1305 ``ltrim`` : flag (empty)
1306 Whitespace to the left of the substitution reference is removed.
1307
1308 ``rtrim`` : flag (empty)
1309 Whitespace to the right of the substitution reference is removed.
1310
1311 ``trim`` : flag (empty)
1312 Equivalent to ``ltrim`` plus ``rtrim``; whitespace on both sides
1313 of the substitution reference is removed.
1314
1315
1316 Date
1317 ====
1318
1319 :Directive Type: "date"
1320 :Doctree Element: Text
1321 :Directive Arguments: One, optional (date format).
1322 :Directive Options: None.
1323 :Directive Content: None.
1324
1325 The "date" directive generates the current local date and inserts it
1326 into the document as text. This directive may be used in substitution
1327 definitions only.
1328
1329 The optional directive content is interpreted as the desired date
1330 format, using the same codes as Python's `time.strftime()`__ function. The
1331 default format is "%Y-%m-%d" (ISO 8601 date), but time fields can also
1332 be used. Examples::
1333
1334 .. |date| date::
1335 .. |time| date:: %H:%M
1336
1337 Today's date is |date|.
1338
1339 This document was generated on |date| at |time|.
1340
1341 __ https://docs.python.org/3/library/time.html#time.strftime
1342
1343
1344 ---------------
1345 Miscellaneous
1346 ---------------
1347
1348 .. _include:
1349
1350 Including an External Document Fragment
1351 =======================================
1352
1353 :Directive Type: "include"
1354 :Doctree Elements: Depend on data being included
1355 (literal_block_ with ``code`` or ``literal`` option).
1356 :Directive Arguments: One, required (path to the file to include).
1357 :Directive Options: Possible (see below).
1358 :Directive Content: None.
1359 :Configuration Setting: file_insertion_enabled_
1360
1361 .. WARNING::
1362
1363 The "include" directive represents a potential security hole. It
1364 can be disabled with the "file_insertion_enabled_" runtime setting.
1365
1366 .. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
1367
1368 The "include" directive reads a text file. The directive argument is
1369 the path to the file to be included, relative to the document containing
1370 the directive. Unless the options ``literal``, ``code``, or ``parser``
1371 are given, the file is parsed in the current document's context at the
1372 point of the directive. For example::
1373
1374 This first example will be parsed at the document level, and can
1375 thus contain any construct, including section headers.
1376
1377 .. include:: inclusion.txt
1378
1379 Back in the main document.
1380
1381 This second example will be parsed in a block quote context.
1382 Therefore it may only contain body elements. It may not
1383 contain section headers.
1384
1385 .. include:: inclusion.txt
1386
1387 If an included document fragment contains section structure, the title
1388 adornments must match those of the master document.
1389
1390 Standard data files intended for inclusion in reStructuredText
1391 documents are distributed with the Docutils source code, located in
1392 the "docutils" package in the ``docutils/parsers/rst/include``
1393 directory. To access these files, use the special syntax for standard
1394 "include" data files, angle brackets around the file name::
1395
1396 .. include:: <isonum.txt>
1397
1398 The current set of standard "include" data files consists of sets of
1399 substitution definitions. See `reStructuredText Standard Definition
1400 Files`__ for details.
1401
1402 __ definitions.html
1403
1404 The following options are recognized:
1405
1406 ``start-line`` : integer
1407 Only the content starting from this line will be included.
1408 (As usual in Python, the first line has index 0 and negative values
1409 count from the end.)
1410
1411 ``end-line`` : integer
1412 Only the content up to (but excluding) this line will be included.
1413
1414 ``start-after`` : text to find in the external data file
1415 Only the content after the first occurrence of the specified text
1416 will be included.
1417
1418 ``end-before`` : text to find in the external data file
1419 Only the content before the first occurrence of the specified text
1420 (but after any ``after`` text) will be included.
1421
1422 ``parser`` : parser name
1423 Parse the included content with the specified parser.
1424 (New in Docutils 0.17)
1425
1426 ``literal`` : flag (empty)
1427 The entire included text is inserted into the document as a single
1428 literal block.
1429
1430 ``code`` : [string] (formal language)
1431 The argument and the included content are passed to
1432 the code_ directive (useful for program listings).
1433
1434 ``number-lines`` : [integer] (start line number)
1435 Precede every code line with a line number.
1436 The optional argument is the number of the first line (default 1).
1437 Works only with ``code`` or ``literal``.
1438
1439 ``encoding`` : string
1440 The text encoding of the external data file. Defaults to the
1441 document's input_encoding_.
1442
1443 .. _input_encoding: ../../user/config.html#input-encoding
1444
1445 ``tab-width`` : integer
1446 Number of spaces for hard tab expansion.
1447 A negative value prevents expansion of hard tabs. Defaults to the
1448 tab_width_ configuration setting.
1449
1450 .. _tab_width: ../../user/config.html#tab-width
1451
1452 With ``code`` or ``literal`` the common options class_ and
1453 name_ are recognized as well.
1454
1455 Combining ``start/end-line`` and ``start-after/end-before`` is possible. The
1456 text markers will be searched in the specified lines (further limiting the
1457 included content).
1458
1459 .. _raw-directive:
1460
1461 Raw Data Pass-Through
1462 =====================
1463
1464 :Directive Type: "raw"
1465 :Doctree Element: raw_
1466 :Directive Arguments: One or more, required (output format types).
1467 :Directive Options: Possible (see below).
1468 :Directive Content: Stored verbatim, uninterpreted. None (empty) if a
1469 "file" or "url" option given.
1470 :Configuration Setting: raw_enabled_
1471
1472 .. WARNING::
1473
1474 The "raw" directive represents a potential security hole. It can
1475 be disabled with the "raw_enabled_" or "file_insertion_enabled_"
1476 runtime settings.
1477
1478 .. _raw_enabled: ../../user/config.html#raw-enabled
1479
1480 .. Caution::
1481
1482 The "raw" directive is a stop-gap measure allowing the author to
1483 bypass reStructuredText's markup. It is a "power-user" feature
1484 that should not be overused or abused. The use of "raw" ties
1485 documents to specific output formats and makes them less portable.
1486
1487 If you often need to use the "raw" directive or a "raw"-derived
1488 interpreted text role, that is a sign either of overuse/abuse or
1489 that functionality may be missing from reStructuredText. Please
1490 describe your situation in a message to the Docutils-users_ mailing
1491 list.
1492
1493 .. _Docutils-users: ../../user/mailing-lists.html#docutils-users
1494
1495 The "raw" directive indicates non-reStructuredText data that is to be
1496 passed untouched to the Writer. The names of the output formats are
1497 given in the directive arguments. The interpretation of the raw data
1498 is up to the Writer. A Writer may ignore any raw output not matching
1499 its format.
1500
1501 For example, the following input would be passed untouched by an HTML
1502 Writer::
1503
1504 .. raw:: html
1505
1506 <hr width=50 size=10>
1507
1508 A LaTeX Writer could insert the following raw content into its
1509 output stream::
1510
1511 .. raw:: latex
1512
1513 \setlength{\parindent}{0pt}
1514
1515 Raw data can also be read from an external file, specified in a
1516 directive option. In this case, the content block must be empty. For
1517 example::
1518
1519 .. raw:: html
1520 :file: inclusion.html
1521
1522 Inline equivalents of the "raw" directive can be defined via
1523 `custom interpreted text roles`_ derived from the `"raw" role`_.
1524
1525 The following options are recognized:
1526
1527 ``file`` : string (newlines removed)
1528 The local filesystem path of a raw data file to be included.
1529
1530 ``url`` : string (whitespace removed)
1531 An Internet URL reference to a raw data file to be included.
1532
1533 ``encoding`` : string
1534 The text encoding of the external raw data (file or URL).
1535 Defaults to the document's encoding (if specified).
1536
1537 and the common option class_.
1538
1539
1540 .. _"raw" role: roles.html#raw
1541
1542
1543 .. _classes:
1544
1545 Class
1546 =====
1547
1548 :Directive Type: "class"
1549 :Doctree Element: pending_
1550 :Directive Arguments: One or more, required (class names / attribute
1551 values).
1552 :Directive Options: None.
1553 :Directive Content: Optional. If present, it is interpreted as body
1554 elements.
1555
1556 The "class" directive sets the `"classes"`_ attribute value on its content
1557 or on the first immediately following [#]_ non-comment element [#]_.
1558 The directive argument consists of one or more space-separated class
1559 names. The names are transformed to conform to the regular expression
1560 ``[a-z](-?[a-z0-9]+)*`` (see `Identifier Normalization`_ below).
1561
1562 Examples::
1563
1564 .. class:: special
1565
1566 This is a "special" paragraph.
1567
1568 .. class:: exceptional remarkable
1569
1570 An Exceptional Section
1571 ======================
1572
1573 This is an ordinary paragraph.
1574
1575 .. class:: multiple
1576
1577 First paragraph.
1578
1579 Second paragraph.
1580
1581 The text above is parsed and transformed into this doctree fragment::
1582
1583 .. code-block:: xml
1584
1585 <paragraph classes="special">
1586 This is a "special" paragraph.
1587 <section classes="exceptional remarkable">
1588 <title>
1589 An Exceptional Section
1590 <paragraph>
1591 This is an ordinary paragraph.
1592 <paragraph classes="multiple">
1593 First paragraph.
1594 <paragraph classes="multiple">
1595 Second paragraph.
1596
1597
1598 .. [#] This is also true, if the class directive is "nested" at the end of
1599 an indented text block, for example::
1600
1601 .. note:: the class values set in this directive-block do not apply to
1602 the note but the next paragraph.
1603
1604 .. class:: special
1605
1606 This is a paragraph with class value "special".
1607
1608 This allows the "classification" of individual list items (except the
1609 first, as a preceding class directive applies to the list as a whole)::
1610
1611 * bullet list
1612
1613 .. class:: classy item
1614
1615 * second item, with class argument
1616
1617 .. [#] To set a "classes" attribute value on a block quote, the
1618 "class" directive must be followed by an empty comment::
1619
1620 .. class:: highlights
1621 ..
1622
1623 Block quote text.
1624
1625 Without the empty comment, the indented text would be interpreted as the
1626 "class" directive's content, and the classes would be applied to each
1627 element (paragraph, in this case) individually, instead of to the block
1628 quote as a whole.
1629
1630
1631 Identifier Normalization
1632 ~~~~~~~~~~~~~~~~~~~~~~~~
1633
1634 Docutils `class names`_ and `identifier keys`_ are normalized to conform
1635 to the regular expression "``[a-z](-?[a-z0-9]+)*``" by converting
1636
1637 * alphabetic characters to lowercase,
1638 * accented characters to the base character,
1639 * non-alphanumeric characters to hyphens,
1640 * consecutive hyphens into one hyphen
1641
1642 and stripping
1643
1644 * leading hyphens and number characters, and
1645 * trailing hyphens.
1646
1647 For example ``"Rot.Gelb&Grün:+2008"`` becomes ``"rot-gelb-grun-2008"`` and
1648 ``"1000_Steps!"`` becomes ``"steps"``.
1649
1650 .. topic:: Rationale:
1651
1652 Identifier keys must be valid in all supported output formats.
1653
1654 For HTMLÂ 4.1 + CSS1 compatibility, identifiers should have no
1655 underscores, colons, or periods. Hyphens may be used.
1656
1657 - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:
1658
1659 ID and NAME tokens must begin with a letter ([A-Za-z]) and
1660 may be followed by any number of letters, digits ([0-9]),
1661 hyphens ("-"), underscores ("_"), colons (":"), and periods
1662 (".").
1663
1664 -- https://www.w3.org/TR/html401/types.html#type-name
1665
1666 - The `CSS1 spec`_ defines identifiers based on the "name" token
1667 ("flex" tokenizer notation below; "latin1" and "escape" 8-bit
1668 characters have been replaced with XML entities)::
1669
1670 unicode \\[0-9a-f]{1,4}
1671 latin1 [&iexcl;-&yuml;]
1672 escape {unicode}|\\[ -~&iexcl;-&yuml;]
1673 nmchar [-A-Za-z0-9]|{latin1}|{escape}
1674 name {nmchar}+
1675
1676 The CSS1 rule requires underscores ("_"), colons (":"), and
1677 periods (".") to be escaped [#]_,
1678 therefore `"classes"`_ and `"ids"`_ attributes should not
1679 contain these characters. Combined with HTML4.1 requirements (the
1680 first character must be a letter; no "unicode", "latin1", or
1681 "escape" characters), this results in the regular expression
1682 ``[A-Za-z][-A-Za-z0-9]*``. Docutils adds a normalization by
1683 downcasing and merge of consecutive hyphens.
1684
1685 .. [#] CSS identifiers may use underscores ("_") directly in
1686 `CSS Level 1`__, `CSS2.1`__, CSS2.2__, and CSS3__.
1687
1688 __ https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
1689 __ https://www.w3.org/TR/CSS/#css-level-1
1690 __ https://www.w3.org/TR/CSS22/syndata.html
1691 __ https://www.w3.org/TR/css-syntax-3/#typedef-ident-token
1692
1693 .. _HTML 4.01 spec: https://www.w3.org/TR/html401/
1694 .. _CSS1 spec: https://www.w3.org/TR/REC-CSS1
1695
1696 .. _role:
1697
1698 Custom Interpreted Text Roles
1699 =============================
1700
1701 :Directive Type: "role"
1702 :Doctree Element: None; affects subsequent parsing.
1703 :Directive Arguments: Two; one required (new `role name`_), one optional
1704 (base role name, in parentheses).
1705 :Directive Options: Possible (depends on base role).
1706 :Directive Content: depends on base role.
1707
1708 The "role" directive dynamically creates a custom `interpreted text
1709 role`_ and registers it with the parser. This means that after
1710 declaring a role like this::
1711
1712 .. role:: custom
1713
1714 the document may use the new "custom" role::
1715
1716 An example of using :custom:`interpreted text`
1717
1718 This will be parsed into the following document tree fragment::
1719
1720 .. code-block:: xml
1721
1722 <paragraph>
1723 An example of using
1724 <inline classes="custom">
1725 interpreted text
1726
1727 The role must be declared in a document before it can be used.
1728
1729 .. _role name:
1730
1731 Role names are case insensitive and must conform to the rules of
1732 simple `reference names`_ (but do not share a namespace with
1733 hyperlinks, footnotes, and citations).
1734
1735 The new role may be based on an existing role, specified as a second
1736 argument in parentheses (whitespace optional)::
1737
1738 .. role:: custom(emphasis)
1739
1740 :custom:`text`
1741
1742 The parsed result is as follows::
1743
1744 .. code-block:: xml
1745
1746 <paragraph>
1747 <emphasis classes="custom">
1748 text
1749
1750 A special case is the `"raw" role`_: derived roles enable
1751 inline `raw data pass-through`_, e.g.::
1752
1753 .. role:: raw-role(raw)
1754 :format: html latex
1755
1756 :raw-role:`raw text`
1757
1758 If no base role is explicitly specified, a generic custom role is
1759 automatically used. Subsequent interpreted text will produce an
1760 "inline" element with a `"classes"`_ attribute, as in the first example
1761 above.
1762
1763 With most roles, the ":class:" option can be used to set a "classes"
1764 attribute that is different from the role name. For example::
1765
1766 .. role:: custom
1767 :class: special
1768
1769 :custom:`interpreted text`
1770
1771 This is the parsed result::
1772
1773 .. code-block:: xml
1774
1775 <paragraph>
1776 <inline classes="special">
1777 interpreted text
1778
1779 .. _role class:
1780
1781 The following option is recognized by the "role" directive for most
1782 base roles:
1783
1784 ``class`` : text
1785 Set the `"classes"`_ attribute value on the element produced
1786 (``inline``, or element associated with a base class) when the
1787 custom interpreted text role is used. If no directive options are
1788 specified, a "class" option with the directive argument (role
1789 name) as the value is implied. See the class_ directive above.
1790
1791 Specific base roles may support other options and/or directive
1792 content. See the `reStructuredText Interpreted Text Roles`_ document
1793 for details.
1794
1795 .. _reStructuredText Interpreted Text Roles: roles.html
1796
1797
1798 .. _default-role:
1799
1800 Setting the Default Interpreted Text Role
1801 =========================================
1802
1803 :Directive Type: "default-role"
1804 :Doctree Element: None; affects subsequent parsing.
1805 :Directive Arguments: One, optional (new default role name).
1806 :Directive Options: None.
1807 :Directive Content: None.
1808
1809 The "default-role" directive sets the default interpreted text role,
1810 the role that is used for interpreted text without an explicit role.
1811 For example, after setting the default role like this::
1812
1813 .. default-role:: subscript
1814
1815 any subsequent use of implicit-role interpreted text in the document
1816 will use the "subscript" role::
1817
1818 An example of a `default` role.
1819
1820 This will be parsed into the following document tree fragment
1821
1822 .. code-block:: xml
1823
1824 <paragraph>
1825 An example of a
1826 <subscript>
1827 default
1828 role.
1829
1830 Custom roles may be used (see the "role_" directive above), but it
1831 must have been declared in a document before it can be set as the
1832 default role. See the `reStructuredText Interpreted Text Roles`_
1833 document for details of built-in roles.
1834
1835 The directive may be used without an argument to restore the initial
1836 default interpreted text role, which is application-dependent. The
1837 initial default interpreted text role of the standard reStructuredText
1838 parser is "title-reference".
1839
1840
1841 Metadata
1842 ========
1843
1844 :Directive Type: "meta"
1845 :Doctree Element: meta_
1846 :Directive Arguments: None.
1847 :Directive Options: None.
1848 :Directive Content: Must contain a flat field list.
1849
1850 The "meta" directive is used to specify metadata\ [#]_ to be stored
1851 in, e.g., `HTML meta elements`_ or as `ODT file properties`_. The
1852 LaTeX writer passes it to the ``pdfinfo`` option of the hyperref_
1853 package. If an output format does not support "invisible" metadata,
1854 content is silently dropped by the writer.
1855
1856 .. note:: Data from some `bibliographic fields`_ is automatically
1857 extracted and stored as metadata, too. However, Bibliographic
1858 Fields are also displayed in the document's screen rendering or
1859 printout.
1860
1861 For an "invisible" *document title*, see the `metadata document
1862 title`_ directive below.
1863
1864 Within the directive block, a flat field list provides the syntax for
1865 metadata. The field name becomes the contents of the "name" attribute
1866 of the META tag, and the field body (interpreted as a single string
1867 without inline markup) becomes the contents of the "content"
1868 attribute. For example::
1869
1870 .. meta::
1871 :description: The reStructuredText plaintext markup language
1872 :keywords: plaintext, markup language
1873
1874 This would be converted to the following HTML
1875
1876 .. code-block:: html
1877
1878 <meta name="description"
1879 content="The reStructuredText plaintext markup language">
1880 <meta name="keywords" content="plaintext, markup language">
1881
1882 Support for other META attributes ("http-equiv", "scheme", "lang",
1883 "dir") are provided through field arguments, which must be of the form
1884 "attr=value"::
1885
1886 .. meta::
1887 :description lang=en: An amusing story
1888 :description lang=fr: Une histoire amusante
1889
1890 And their HTML equivalents
1891
1892 .. code-block:: html
1893
1894 <meta name="description" lang="en" content="An amusing story">
1895 <meta name="description" lang="fr" content="Une histoire amusante">
1896
1897 Some META tags use an "http-equiv" attribute instead of the "name"
1898 attribute. To specify "http-equiv" META tags, simply omit the name::
1899
1900 .. meta::
1901 :http-equiv=Content-Type: text/html; charset=ISO-8859-1
1902
1903 HTML equivalent
1904
1905 .. code-block:: html
1906
1907 <meta http-equiv="Content-Type"
1908 content="text/html; charset=ISO-8859-1">
1909
1910 .. [#] "Metadata" is data about data, in this case data about the
1911 document. Metadata is, e.g., used to describe and classify web
1912 pages in the World Wide Web, in a form that is easy for search
1913 engines to extract and collate.
1914
1915 .. _HTML meta elements:
1916 https://html.spec.whatwg.org/multipage/semantics.html#the-meta-element
1917 .. _ODT file properties:
1918 https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Metadata
1919 .. _hyperref: https://ctan.org/pkg/hyperref
1920 .. _bibliographic fields: restructuredtext.html#bibliographic-fields
1921
1922
1923 Metadata Document Title
1924 =======================
1925
1926 :Directive Type: "title"
1927 :Doctree Element: Sets the document's `title attribute`_.
1928 :Directive Arguments: One, required (the title text).
1929 :Directive Options: None.
1930 :Directive Content: None.
1931
1932 The "title" directive specifies the document title as metadata, which
1933 does not become part of the document body. It overrides the
1934 document-supplied `document title`_ and the `"title" configuration
1935 setting`_. For example, in HTML output the metadata document title
1936 appears in the title bar of the browser window.
1937
1938 .. _document title: restructuredtext.html#document-title
1939 .. _"title" configuration setting: ../../user/config.html#title
1940
1941 Restructuredtext-Test-Directive
1942 ===============================
1943
1944 :Directive Type: "restructuredtext-test-directive"
1945 :Doctree Element: system_warning
1946 :Directive Arguments: None.
1947 :Directive Options: None.
1948 :Directive Content: Interpreted as a literal block.
1949
1950 This directive is provided for test purposes only. (Nobody is
1951 expected to type in a name *that* long!) It is converted into a
1952 level-1 (info) system message showing the directive data, possibly
1953 followed by a literal block containing the rest of the directive
1954 block.
1955
1956 --------------
1957 Common Options
1958 --------------
1959
1960 Most of the directives that generate doctree elements support the following
1961 options:
1962
1963 .. _class-option:
1964 .. _class:
1965
1966 ``class`` : text (space separated list of `class names`_)
1967 Set a `"classes"`_ attribute value on the doctree element generated by
1968 the directive. See also the class_ directive.
1969
1970 .. _name:
1971
1972 ``name`` : text
1973 Add `text` to the `"names"`_ attribute of the doctree element generated
1974 by the directive. This allows `hyperlink references`_ to the element
1975 using `text` as `reference name`_.
1976
1977 Specifying the `name` option of a directive, e.g., ::
1978
1979 .. image:: bild.png
1980 :name: my picture
1981
1982 is a concise syntax alternative to preceding it with a `hyperlink
1983 target`_ ::
1984
1985 .. _my picture:
1986
1987 .. image:: bild.png
1988
1989
1990 .. _reference name:
1991 .. _reference names: restructuredtext.html#reference-names
1992 .. _hyperlink target: restructuredtext.html#hyperlink-targets
1993 .. _hyperlink references: restructuredtext.html#hyperlink-references
1994 .. _class names: ../doctree.html#classnames-type
1995 .. _"classes": ../doctree.html#classes
1996 .. _identifier keys: ../doctree.html#ids-type
1997 .. _"ids": ../doctree.html#ids
1998 .. _"names": ../doctree.html#names
1999 .. _admonition: ../doctree.html#admonition
2000 .. _block_quote: ../doctree.html#block-quote
2001 .. _caption: ../doctree.html#caption
2002 .. _compound: ../doctree.html#compound
2003 .. _container element: ../doctree.html#container
2004 .. _decoration: ../doctree.html#decoration
2005 .. _figure: ../doctree.html#figure
2006 .. _footnote: ../doctree.html#footnote
2007 .. _footnote_reference: ../doctree.html#footnote-reference
2008 .. _generated: ../doctree.html#generated
2009 .. _image: ../doctree.html#image
2010 .. _inline elements: ../doctree.html#inline-elements
2011 .. _interpreted text role: roles.html
2012 .. _literal_block: ../doctree.html#literal-block
2013 .. _legend: ../doctree.html#legend
2014 .. _length: restructuredtext.html#length-units
2015 .. _line_block: ../doctree.html#line-block
2016 .. _math_block: ../doctree.html#math-block
2017 .. _meta: ../doctree.html#meta
2018 .. _pending: ../doctree.html#pending
2019 .. _percentage: restructuredtext.html#percentage-units
2020 .. _raw: ../doctree.html#raw
2021 .. _rubric: ../doctree.html#rubric
2022 .. _sidebar: ../doctree.html#sidebar
2023 .. _table: ../doctree.html#table
2024 .. _title: ../doctree.html#title
2025 .. _title attribute: ../doctree.html#title-attribute
2026 .. _topic: ../doctree.html#topic
2027
2028
2029
2030 ..
2031 Local Variables:
2032 mode: indented-text
2033 indent-tabs-mode: nil
2034 sentence-end-double-space: t
2035 fill-column: 70
2036 End: