Debian Codegraph @

tests/test_vectors/directives.rst

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
512 The content of the following directive ::
513
514 .. code:: python
515
516 def my_function():
517 "just a test"
518 print 8/2
519
520 is parsed and marked up as Python source code.
521
522
523 Math
524 ====
525
526 :Directive Type: "math"
527 :Doctree Element: math_block_
528 :Directive Arguments: None.
529 :Directive Options: class_, name_
530 :Directive Content: Becomes the body of the math block.
531 (Content blocks separated by a blank line are put in
532 adjacent math blocks.)
533 :Configuration Setting: math_output_
534
535 The "math" directive inserts blocks with mathematical content
536 (display formulas, equations) into the document. The input format is
537 `LaTeX math syntax`_ with support for Unicode symbols, for example::
538
539 .. math::
540
541 α_t(i) = P(O_1, O_2, … O_t, q_t = S_i λ)
542
543 Support is limited to a subset of *LaTeX math* by the conversion
544 required for many output formats. For HTML, the `math_output`_
545 configuration setting (or the corresponding ``--math-output``
546 command line option) select between alternative output formats with
547 different subsets of supported elements. If a writer does not
548 support math typesetting, the content is inserted verbatim.
549
550 For inline formulas, use the `"math" role`_.
551
552 .. _LaTeX math syntax: ../../ref/rst/mathematics.html
553 .. _"math" role: roles.html#math
554 .. _math_output: ../../user/config.html#math-output
555
556
557 Rubric
558 ======
559
560 :Directive Type: "rubric"
561 :Doctree Element: rubric_
562 :Directive Arguments: One, required (rubric text).
563 :Directive Options: class_, name_
564 :Directive Content: None.
565
566 ..
567
568 rubric n. 1. a title, heading, or the like, in a manuscript,
569 book, statute, etc., written or printed in red or otherwise
570 distinguished from the rest of the text. ...
571
572 -- Random House Webster's College Dictionary, 1991
573
574 The "rubric" directive inserts a "rubric" element into the document
575 tree. A rubric is like an informal heading that doesn't correspond to
576 the document's structure.
577
578
579 Epigraph
580 ========
581
582 :Directive Type: "epigraph"
583 :Doctree Element: block_quote_
584 :Directive Arguments: None.
585 :Directive Options: None.
586 :Directive Content: Interpreted as the body of the block quote.
587
588 An epigraph is an apposite (suitable, apt, or pertinent) short
589 inscription, often a quotation or poem, at the beginning of a document
590 or section.
591
592 The "epigraph" directive produces an "epigraph"-class block quote.
593 For example, this input::
594
595 .. epigraph::
596
597 No matter where you go, there you are.
598
599 -- Buckaroo Banzai
600
601 becomes this document tree fragment::
602
603 <block_quote classes="epigraph">
604 <paragraph>
605 No matter where you go, there you are.
606 <attribution>
607 Buckaroo Banzai
608
609
610 Highlights
611 ==========
612
613 :Directive Type: "highlights"
614 :Doctree Element: block_quote_
615 :Directive Arguments: None.
616 :Directive Options: None.
617 :Directive Content: Interpreted as the body of the block quote.
618
619 Highlights summarize the main points of a document or section, often
620 consisting of a list.
621
622 The "highlights" directive produces a "highlights"-class block quote.
623 See Epigraph_ above for an analogous example.
624
625
626 Pull-Quote
627 ==========
628
629 :Directive Type: "pull-quote"
630 :Doctree Element: block_quote_
631 :Directive Arguments: None.
632 :Directive Options: None.
633 :Directive Content: Interpreted as the body of the block quote.
634
635 A pull-quote is a small selection of text "pulled out and quoted",
636 typically in a larger typeface. Pull-quotes are used to attract
637 attention, especially in long articles.
638
639 The "pull-quote" directive produces a "pull-quote"-class block quote.
640 See Epigraph_ above for an analogous example.
641
642
643 Compound Paragraph
644 ==================
645
646 :Directive Type: "compound"
647 :Doctree Element: compound_
648 :Directive Arguments: None.
649 :Directive Options: class_, name_
650 :Directive Content: Interpreted as body elements.
651
652 The "compound" directive is used to create a compound paragraph, which
653 is a single logical paragraph containing multiple physical body
654 elements such as simple paragraphs, literal blocks, tables, lists,
655 etc., instead of directly containing text and inline elements. For
656 example::
657
658 .. compound::
659
660 The 'rm' command is very dangerous. If you are logged
661 in as root and enter ::
662
663 cd /
664 rm -rf *
665
666 you will erase the entire contents of your file system.
667
668 In the example above, a literal block is "embedded" within a sentence
669 that begins in one physical paragraph and ends in another.
670
671 .. note::
672
673 The "compound" directive is *not* a generic block-level container
674 like HTML's ``<div>`` element. Do not use it only to group a
675 sequence of elements, or you may get unexpected results.
676
677 If you need a generic block-level container, please use the
678 container_ directive, described below.
679
680 Compound paragraphs are typically rendered as multiple distinct text
681 blocks, with the possibility of variations to emphasize their logical
682 unity:
683
684 * If paragraphs are rendered with a first-line indent, only the first
685 physical paragraph of a compound paragraph should have that indent
686 -- second and further physical paragraphs should omit the indents;
687 * vertical spacing between physical elements may be reduced;
688 * and so on.
689
690
691 Container
692 =========
693
694 :Directive Type: "container"
695 :Doctree Element: `container <container element_>`__
696 :Directive Arguments: One or more, optional (class names).
697 :Directive Options: name_
698 :Directive Content: Interpreted as body elements.
699
700 The "container" directive surrounds its contents (arbitrary body
701 elements) with a generic block-level "container" element. Combined
702 with the optional "classes_" attribute argument(s), this is an
703 extension mechanism for users & applications. For example::
704
705 .. container:: custom
706
707 This paragraph might be rendered in a custom way.
708
709 Parsing the above results in the following pseudo-XML
710
711 .. code-block:: xml
712
713 <container classes="custom">
714 <paragraph>
715 This paragraph might be rendered in a custom way.
716
717 The "container" directive is the equivalent of HTML's ``<div>``
718 element. It may be used to group a sequence of elements for user- or
719 application-specific purposes.
720
721
722
723 --------
724 Tables
725 --------
726
727 Formal tables need more structure than the reStructuredText syntax
728 supplies. Tables may be given titles with the table_ directive.
729 Sometimes reStructuredText tables are inconvenient to write, or table
730 data in a standard format is readily available. The csv-table_
731 directive supports CSV data.
732
733
734 Table
735 =====
736
737 :Directive Type: "table"
738 :Doctree Element: table_
739 :Directive Arguments: One, optional (table title).
740 :Directive Options: Possible (see below).
741 :Directive Content: A normal `reStructuredText table`_.
742
743 The "table" directive is used to associate a
744 title with a table or specify options, e.g.::
745
746 .. table:: Truth table for "not"
747 :widths: auto
748
749 ===== =====
750 A not A
751 ===== =====
752 False True
753 True False
754 ===== =====
755
756 The following options are recognized:
757
758 ``align`` : "left", "center", or "right"
759 The horizontal alignment of the table (new in Docutils 0.13).
760
761 ``width`` : `length`_ or `percentage`_
762 Sets the width of the table to the specified length or percentage
763 of the line width. If omitted, the renderer determines the width
764 of the table based on its contents or the column ``widths``.
765
766 .. _column-widths:
767
768 ``widths`` : "auto", "grid", or a list of integers
769 A list of relative column widths.
770 The default is the width of the input columns (in characters).
771
772 *"auto"* delegates the determination of column widths to the backend
773 (LaTeX, the HTML browser, ...).
774
775 *"grid"* restores the default, overriding a `table_style`_ or class
776 value "colwidths-auto".
777
778 Plus the common options class_ and name_.
779
780 .. _reStructuredText table: restructuredtext.html#tables
781 .. _table_style: ../../user/config.html#table-style
782
783
784 .. _csv-table:
785
786 CSV Table
787 =========
788
789 :Directive Type: "csv-table"
790 :Doctree Element: table_
791 :Directive Arguments: One, optional (table title).
792 :Directive Options: Possible (see below).
793 :Directive Content: A CSV (comma-separated values) table.
794
795 .. WARNING::
796
797 The "csv-table" directive's ":file:" and ":url:" options represent
798 a potential security holes. They can be disabled with the
799 "file_insertion_enabled_" runtime setting.
800
801 The "csv-table" directive is used to create a table from CSV
802 (comma-separated values) data. CSV is a common data format generated
803 by spreadsheet applications and commercial databases. The data may be
804 internal (an integral part of the document) or external (a separate
805 file).
806
807 * Block markup and inline markup within cells is supported. Line ends
808 are recognized within cells.
809
810 * There is no support for checking that the number of columns in each
811 row is the same. The directive automatically adds empty entries at
812 the end of short rows.
813
814 .. Add "strict" option to verify input?
815
816 Example::
817
818 .. csv-table:: Frozen Delights!
819 :header: "Treat", "Quantity", "Description"
820 :widths: 15, 10, 30
821
822 "Albatross", 2.99, "On a stick!"
823 "Crunchy Frog", 1.49, "If we took the bones out, it wouldn't be
824 crunchy, now would it?"
825 "Gannet Ripple", 1.99, "On a stick!"
826
827 The following options are recognized:
828
829 ``align`` : "left", "center", or "right"
830 The horizontal alignment of the table. (New in Docutils 0.13)
831
832 ``delim`` : char | "tab" | "space" [#whitespace-delim]_
833 A one-character string\ [#ASCII-char]_ used to separate fields.
834 Defaults to ``,`` (comma). May be specified as a Unicode code
835 point; see the unicode_ directive for syntax details.
836
837 ``encoding`` : string
838 The text encoding of the external CSV data (file or URL).
839 Defaults to the document's input_encoding_.
840
841 ``escape`` : char
842 A one-character\ [#ASCII-char]_ string used to escape the
843 delimiter or quote characters. May be specified as a Unicode
844 code point; see the unicode_ directive for syntax details. Used
845 when the delimiter is used in an unquoted field, or when quote
846 characters are used within a field. The default is to double-up
847 the character, e.g. "He said, ""Hi!"""
848
849 .. Add another possible value, "double", to explicitly indicate
850 the default case?
851
852 ``file`` : string (newlines removed)
853 The local filesystem path to a CSV data file.
854
855 ``header`` : CSV data
856 Supplemental data for the table header, added independently of and
857 before any ``header-rows`` from the main CSV data. Must use the
858 same CSV format as the main CSV data.
859
860 ``header-rows`` : integer
861 The number of rows of CSV data to use in the table header.
862 Defaults to 0.
863
864 ``keepspace`` : flag (empty)
865 Treat whitespace immediately following the delimiter as
866 significant. The default is to ignore such whitespace.
867
868 ``quote`` : char
869 A one-character string\ [#ASCII-char]_ used to quote elements
870 containing the delimiter or which start with the quote
871 character. Defaults to ``"`` (quote). May be specified as a
872 Unicode code point; see the unicode_ directive for syntax
873 details.
874
875 ``stub-columns`` : integer
876 The number of table columns to use as stubs (row titles, on the
877 left). Defaults to 0.
878
879 ``url`` : string (whitespace removed)
880 An Internet URL reference to a CSV data file.
881
882 ``widths`` : integer [integer...] or "auto"
883 A list of relative column widths.
884 The default is equal-width columns (100%/#columns).
885
886 "auto" delegates the determination of column widths to the backend
887 (LaTeX, the HTML browser, ...).
888
889 ``width`` : `length`_ or `percentage`_
890 Sets the width of the table to the specified length or percentage
891 of the line width. If omitted, the renderer determines the width
892 of the table based on its contents or the column ``widths``.
893
894 and the common options class_ and name_.
895
896 .. [#whitespace-delim] Whitespace delimiters are supported only for external
897 CSV files.
898
899 .. [#ASCII-char] With Python 2, the values for the ``delimiter``,
900 ``quote``, and ``escape`` options must be ASCII characters. (The csv
901 module does not support Unicode and all non-ASCII characters are
902 encoded as multi-byte utf-8 string). This limitation does not exist
903 under Python 3.
904
905
906 List Table
907 ==========
908
909 :Directive Type: "list-table"
910 :Doctree Element: table_
911 :Directive Arguments: One, optional (table title).
912 :Directive Options: Possible (see below).
913 :Directive Content: A uniform two-level bullet list.
914
915 (This is an initial implementation; `further ideas`__ may be implemented
916 in the future.)
917
918 __ ../../dev/rst/alternatives.html#list-driven-tables
919
920 The "list-table" directive is used to create a table from data in a
921 uniform two-level bullet list. "Uniform" means that each sublist
922 (second-level list) must contain the same number of list items.
923
924 Example::
925
926 .. list-table:: Frozen Delights!
927 :widths: 15 10 30
928 :header-rows: 1
929
930 * - Treat
931 - Quantity
932 - Description
933 * - Albatross
934 - 2.99
935 - On a stick!
936 * - Crunchy Frog
937 - 1.49
938 - If we took the bones out, it wouldn't be
939 crunchy, now would it?
940 * - Gannet Ripple
941 - 1.99
942 - On a stick!
943
944 The following options are recognized:
945
946
947 ``align`` : "left", "center", or "right"
948 The horizontal alignment of the table.
949 (New in Docutils 0.13)
950
951 ``header-rows`` : integer
952 The number of rows of list data to use in the table header.
953 Defaults to 0.
954
955 ``stub-columns`` : integer
956 The number of table columns to use as stubs (row titles, on the
957 left). Defaults to 0.
958
959 .. _table width:
960
961 ``width`` : `length`_ or `percentage`_
962 Sets the width of the table to the specified length or percentage
963 of the line width. If omitted, the renderer determines the width
964 of the table based on its contents or the column ``widths``.
965
966 .. _column widths:
967
968 ``widths`` : integer [integer...] or "auto"
969 A list of relative column widths.
970 The default is equal-width columns (100%/#columns).
971
972 "auto" delegates the determination of column widths to the backend
973 (LaTeX, the HTML browser, ...).
974
975 and the common options class_ and name_.
976
977
978 ----------------
979 Document Parts
980 ----------------
981
982 .. _contents:
983
984 Table of Contents
985 =================
986
987 :Directive Type: "contents"
988 :Doctree Elements: pending_, topic_
989 :Directive Arguments: One, optional: title.
990 :Directive Options: Possible (see below).
991 :Directive Content: None.
992
993 The "contents" directive generates a table of contents (TOC) in a
994 topic_. Topics, and therefore tables of contents, may occur anywhere
995 a section or transition may occur. Body elements and topics may not
996 contain tables of contents.
997
998 Here's the directive in its simplest form::
999
1000 .. contents::
1001
1002 Language-dependent boilerplate text will be used for the title. The
1003 English default title text is "Contents".
1004
1005 An explicit title may be specified::
1006
1007 .. contents:: Table of Contents
1008
1009 The title may span lines, although it is not recommended::
1010
1011 .. contents:: Here's a very long Table of
1012 Contents title
1013
1014 Options may be specified for the directive, using a field list::
1015
1016 .. contents:: Table of Contents
1017 :depth: 2
1018
1019 If the default title is to be used, the options field list may begin
1020 on the same line as the directive marker::
1021
1022 .. contents:: :depth: 2
1023
1024 The following options are recognized:
1025
1026 ``depth`` : integer
1027 The number of section levels that are collected in the table of
1028 contents. The default is unlimited depth.
1029
1030 ``local`` : flag (empty)
1031 Generate a local table of contents. Entries will only include
1032 subsections of the section in which the directive is given. If no
1033 explicit title is given, the table of contents will not be titled.
1034
1035 ``backlinks`` : "entry" or "top" or "none"
1036 Generate links from section headers back to the table of contents
1037 entries, the table of contents itself, or generate no back-links.
1038
1039 ``class`` : text
1040 Set a `"classes"`_ attribute value on the topic element. See the
1041 class_ directive below.
1042
1043
1044 .. _sectnum:
1045 .. _section-numbering:
1046
1047 Automatic Section Numbering
1048 ===========================
1049
1050 :Directive Type: "sectnum" or "section-numbering" (synonyms)
1051 :Doctree Elements: pending_, generated_
1052 :Directive Arguments: None.
1053 :Directive Options: Possible (see below).
1054 :Directive Content: None.
1055 :Configuration Setting: sectnum_xform_
1056
1057 The "sectnum" (or "section-numbering") directive automatically numbers
1058 sections and subsections in a document (if not disabled by the
1059 ``--no-section-numbering`` command line option or the `sectnum_xform`_
1060 configuration setting).
1061
1062 Section numbers are of the "multiple enumeration" form, where each
1063 level has a number, separated by periods. For example, the title of section
1064 1, subsection 2, subsubsection 3 would have "1.2.3" prefixed.
1065
1066 The "sectnum" directive does its work in two passes: the initial parse
1067 and a transform. During the initial parse, a "pending" element is
1068 generated which acts as a placeholder, storing any options internally.
1069 At a later stage in the processing, the "pending" element triggers a
1070 transform, which adds section numbers to titles. Section numbers are
1071 enclosed in a "generated" element, and titles have their "auto"
1072 attribute set to "1".
1073
1074 The following options are recognized:
1075
1076 ``depth`` : integer
1077 The number of section levels that are numbered by this directive.
1078 The default is unlimited depth.
1079
1080 ``prefix`` : string
1081 An arbitrary string that is prefixed to the automatically
1082 generated section numbers. It may be something like "3.2.", which
1083 will produce "3.2.1", "3.2.2", "3.2.2.1", and so on. Note that
1084 any separating punctuation (in the example, a period, ".") must be
1085 explicitly provided. The default is no prefix.
1086
1087 ``suffix`` : string
1088 An arbitrary string that is appended to the automatically
1089 generated section numbers. The default is no suffix.
1090
1091 ``start`` : integer
1092 The value that will be used for the first section number.
1093 Combined with ``prefix``, this may be used to force the right
1094 numbering for a document split over several source files. The
1095 default is 1.
1096
1097 .. _sectnum_xform: ../../user/config.html#sectnum-xform
1098
1099
1100 .. _header:
1101 .. _footer:
1102
1103 Document Header & Footer
1104 ========================
1105
1106 :Directive Types: "header" and "footer"
1107 :Doctree Elements: decoration_, header, footer
1108 :Directive Arguments: None.
1109 :Directive Options: None.
1110 :Directive Content: Interpreted as body elements.
1111
1112 The "header" and "footer" directives create document decorations,
1113 useful for page navigation, notes, time/datestamp, etc. For example::
1114
1115 .. header:: This space for rent.
1116
1117 This will add a paragraph to the document header, which will appear at
1118 the top of the generated web page or at the top of every printed page.
1119
1120 These directives may be used multiple times, cumulatively. There is
1121 currently support for only one header and footer.
1122
1123 .. note::
1124
1125 While it is possible to use the "header" and "footer" directives to
1126 create navigational elements for web pages, you should be aware
1127 that Docutils is meant to be used for *document* processing, and
1128 that a navigation bar is not typically part of a document.
1129
1130 Thus, you may soon find Docutils' abilities to be insufficient for
1131 these purposes. At that time, you should consider using a
1132 documentation generator like Sphinx_ rather than the "header" and
1133 "footer" directives.
1134
1135 .. _Sphinx: http://sphinx-doc.org/
1136
1137 In addition to the use of these directives to populate header and
1138 footer content, content may also be added automatically by the
1139 processing system. For example, if certain runtime settings are
1140 enabled, the document footer is populated with processing information
1141 such as a datestamp, a link to `the Docutils website`_, etc.
1142
1143 .. _the Docutils website: https://docutils.sourceforge.io
1144
1145
1146 ------------
1147 References
1148 ------------
1149
1150 .. _target-notes:
1151
1152 Target Footnotes
1153 ================
1154
1155 :Directive Type: "target-notes"
1156 :Doctree Elements: pending_, footnote_, footnote_reference_
1157 :Directive Arguments: None.
1158 :Directive Options: class_, name_
1159 :Directive Options: Possible (see below).
1160 :Directive Content: None.
1161
1162 The "target-notes" directive creates a footnote for each external
1163 target in the text, and corresponding footnote references after each
1164 reference. For every explicit target (of the form, ``.. _target name:
1165 URL``) in the text, a footnote will be generated containing the
1166 visible URL as content.
1167
1168
1169 Footnotes
1170 =========
1171
1172 **NOT IMPLEMENTED YET**
1173
1174 :Directive Type: "footnotes"
1175 :Doctree Elements: pending_, topic_
1176 :Directive Arguments: None?
1177 :Directive Options: Possible?
1178 :Directive Content: None.
1179
1180 @@@
1181
1182
1183 Citations
1184 =========
1185
1186 **NOT IMPLEMENTED YET**
1187
1188 :Directive Type: "citations"
1189 :Doctree Elements: pending_, topic_
1190 :Directive Arguments: None?
1191 :Directive Options: Possible?
1192 :Directive Content: None.
1193
1194 @@@
1195
1196
1197 ---------------
1198 HTML-Specific
1199 ---------------
1200
1201 Imagemap
1202 ========
1203
1204 **NOT IMPLEMENTED YET**
1205
1206 Non-standard element: imagemap.
1207
1208
1209 -----------------------------------------
1210 Directives for Substitution Definitions
1211 -----------------------------------------
1212
1213 The directives in this section may only be used in `substitution
1214 definitions`_. They may not be used directly, in standalone context.
1215 The `image`_ directive may be used both in substitution definitions
1216 and in the standalone context.
1217
1218 .. _substitution definitions:
1219 .. _substitution definition: restructuredtext.html#substitution-definitions
1220
1221 .. _replace:
1222
1223 Replacement Text
1224 ================
1225
1226 :Directive Type: "replace"
1227 :Doctree Element: Text & `inline elements`_
1228 :Directive Arguments: None.
1229 :Directive Options: None.
1230 :Directive Content: A single paragraph; may contain inline markup.
1231
1232 The "replace" directive is used to indicate replacement text for a
1233 substitution reference. It may be used within `substitution
1234 definitions`_ only. For example, this directive can be used to expand
1235 abbreviations::
1236
1237 .. |reST| replace:: reStructuredText
1238
1239 Yes, |reST| is a long word, so I can't blame anyone for wanting to
1240 abbreviate it.
1241
1242 As reStructuredText doesn't support nested inline markup, the only way
1243 to create a reference with styled text is to use substitutions with
1244 the "replace" directive::
1245
1246 I recommend you try |Python|_.
1247
1248 .. |Python| replace:: Python, *the* best language around
1249 .. _Python: https://www.python.org/
1250
1251
1252 .. _unicode:
1253
1254 Unicode Character Codes
1255 =======================
1256
1257 :Directive Type: "unicode"
1258 :Doctree Element: Text
1259 :Directive Arguments: One or more, required (Unicode character codes,
1260 optional text, and comments).
1261 :Directive Options: Possible (see below).
1262 :Directive Content: None.
1263
1264 The "unicode" directive converts Unicode character codes (numerical
1265 values) to characters, and may be used in `substitution definitions`_
1266 only.
1267
1268 The arguments, separated by spaces, can be:
1269
1270 * **character codes** as
1271
1272 - decimal numbers or
1273
1274 - hexadecimal numbers, prefixed by ``0x``, ``x``, ``\x``, ``U+``, ``u``, or ``\u`` or as XML-style hexadecimal character entities, e.g. ``&#x1a2b;``
1275
1276 * **text**, which is used as-is.
1277
1278 Text following " .. " is a comment and is ignored. The spaces between
1279 the arguments are ignored and thus do not appear in the output.
1280 Hexadecimal codes are case-insensitive.
1281
1282 For example, the following text::
1283
1284 Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1285 all rights reserved.
1286
1287 .. |copy| unicode:: 0xA9 .. copyright sign
1288 .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1289 .. with trademark sign
1290 .. |---| unicode:: U+02014 .. em dash
1291 :trim:
1292
1293 results in:
1294
1295 Copyright |copy| 2003, |BogusMegaCorp (TM)| |---|
1296 all rights reserved.
1297
1298 .. |copy| unicode:: 0xA9 .. copyright sign
1299 .. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
1300 .. with trademark sign
1301 .. |---| unicode:: U+02014 .. em dash
1302 :trim:
1303
1304 The following options are recognized:
1305
1306 ``ltrim`` : flag (empty)
1307 Whitespace to the left of the substitution reference is removed.
1308
1309 ``rtrim`` : flag (empty)
1310 Whitespace to the right of the substitution reference is removed.
1311
1312 ``trim`` : flag (empty)
1313 Equivalent to ``ltrim`` plus ``rtrim``; whitespace on both sides
1314 of the substitution reference is removed.
1315
1316
1317 Date
1318 ====
1319
1320 :Directive Type: "date"
1321 :Doctree Element: Text
1322 :Directive Arguments: One, optional (date format).
1323 :Directive Options: None.
1324 :Directive Content: None.
1325
1326 The "date" directive generates the current local date and inserts it
1327 into the document as text. This directive may be used in substitution
1328 definitions only.
1329
1330 The optional directive content is interpreted as the desired date
1331 format, using the same codes as Python's `time.strftime()`__ function. The
1332 default format is "%Y-%m-%d" (ISO 8601 date), but time fields can also
1333 be used. Examples::
1334
1335 .. |date| date::
1336 .. |time| date:: %H:%M
1337
1338 Today's date is |date|.
1339
1340 This document was generated on |date| at |time|.
1341
1342 __ https://docs.python.org/3/library/time.html#time.strftime
1343
1344
1345 ---------------
1346 Miscellaneous
1347 ---------------
1348
1349 .. _include:
1350
1351 Including an External Document Fragment
1352 =======================================
1353
1354 :Directive Type: "include"
1355 :Doctree Elements: Depend on data being included
1356 (literal_block_ with ``code`` or ``literal`` option).
1357 :Directive Arguments: One, required (path to the file to include).
1358 :Directive Options: Possible (see below).
1359 :Directive Content: None.
1360 :Configuration Setting: file_insertion_enabled_
1361
1362 .. WARNING::
1363
1364 The "include" directive represents a potential security hole. It
1365 can be disabled with the "file_insertion_enabled_" runtime setting.
1366
1367 .. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
1368
1369 The "include" directive reads a text file. The directive argument is
1370 the path to the file to be included, relative to the document containing
1371 the directive. Unless the options ``literal``, ``code``, or ``parser``
1372 are given, the file is parsed in the current document's context at the
1373 point of the directive. For example::
1374
1375 This first example will be parsed at the document level, and can
1376 thus contain any construct, including section headers.
1377
1378 .. include:: inclusion.txt
1379
1380 Back in the main document.
1381
1382 This second example will be parsed in a block quote context.
1383 Therefore it may only contain body elements. It may not
1384 contain section headers.
1385
1386 .. include:: inclusion.txt
1387
1388 If an included document fragment contains section structure, the title
1389 adornments must match those of the master document.
1390
1391 Standard data files intended for inclusion in reStructuredText
1392 documents are distributed with the Docutils source code, located in
1393 the "docutils" package in the ``docutils/parsers/rst/include``
1394 directory. To access these files, use the special syntax for standard
1395 "include" data files, angle brackets around the file name::
1396
1397 .. include:: <isonum.txt>
1398
1399 The current set of standard "include" data files consists of sets of
1400 substitution definitions. See `reStructuredText Standard Definition
1401 Files`__ for details.
1402
1403 __ definitions.html
1404
1405 The following options are recognized:
1406
1407 ``start-line`` : integer
1408 Only the content starting from this line will be included.
1409 (As usual in Python, the first line has index 0 and negative values
1410 count from the end.)
1411
1412 ``end-line`` : integer
1413 Only the content up to (but excluding) this line will be included.
1414
1415 ``start-after`` : text to find in the external data file
1416 Only the content after the first occurrence of the specified text
1417 will be included.
1418
1419 ``end-before`` : text to find in the external data file
1420 Only the content before the first occurrence of the specified text
1421 (but after any ``after`` text) will be included.
1422
1423 ``parser`` : parser name
1424 Parse the included content with the specified parser.
1425 (New in Docutils 0.17)
1426
1427 ``literal`` : flag (empty)
1428 The entire included text is inserted into the document as a single
1429 literal block.
1430
1431 ``code`` : [string] (formal language)
1432 The argument and the included content are passed to
1433 the code_ directive (useful for program listings).
1434
1435 ``number-lines`` : [integer] (start line number)
1436 Precede every code line with a line number.
1437 The optional argument is the number of the first line (default 1).
1438 Works only with ``code`` or ``literal``.
1439
1440 ``encoding`` : string
1441 The text encoding of the external data file. Defaults to the
1442 document's input_encoding_.
1443
1444 .. _input_encoding: ../../user/config.html#input-encoding
1445
1446 ``tab-width`` : integer
1447 Number of spaces for hard tab expansion.
1448 A negative value prevents expansion of hard tabs. Defaults to the
1449 tab_width_ configuration setting.
1450
1451 .. _tab_width: ../../user/config.html#tab-width
1452
1453 With ``code`` or ``literal`` the common options class_ and
1454 name_ are recognized as well.
1455
1456 Combining ``start/end-line`` and ``start-after/end-before`` is possible. The
1457 text markers will be searched in the specified lines (further limiting the
1458 included content).
1459
1460 .. _raw-directive:
1461
1462 Raw Data Pass-Through
1463 =====================
1464
1465 :Directive Type: "raw"
1466 :Doctree Element: raw_
1467 :Directive Arguments: One or more, required (output format types).
1468 :Directive Options: Possible (see below).
1469 :Directive Content: Stored verbatim, uninterpreted. None (empty) if a
1470 "file" or "url" option given.
1471 :Configuration Setting: raw_enabled_
1472
1473 .. WARNING::
1474
1475 The "raw" directive represents a potential security hole. It can
1476 be disabled with the "raw_enabled_" or "file_insertion_enabled_"
1477 runtime settings.
1478
1479 .. _raw_enabled: ../../user/config.html#raw-enabled
1480
1481 .. Caution::
1482
1483 The "raw" directive is a stop-gap measure allowing the author to
1484 bypass reStructuredText's markup. It is a "power-user" feature
1485 that should not be overused or abused. The use of "raw" ties
1486 documents to specific output formats and makes them less portable.
1487
1488 If you often need to use the "raw" directive or a "raw"-derived
1489 interpreted text role, that is a sign either of overuse/abuse or
1490 that functionality may be missing from reStructuredText. Please
1491 describe your situation in a message to the Docutils-users_ mailing
1492 list.
1493
1494 .. _Docutils-users: ../../user/mailing-lists.html#docutils-users
1495
1496 The "raw" directive indicates non-reStructuredText data that is to be
1497 passed untouched to the Writer. The names of the output formats are
1498 given in the directive arguments. The interpretation of the raw data
1499 is up to the Writer. A Writer may ignore any raw output not matching
1500 its format.
1501
1502 For example, the following input would be passed untouched by an HTML
1503 Writer::
1504
1505 .. raw:: html
1506
1507 <hr width=50 size=10>
1508
1509 A LaTeX Writer could insert the following raw content into its
1510 output stream::
1511
1512 .. raw:: latex
1513
1514 \setlength{\parindent}{0pt}
1515
1516 Raw data can also be read from an external file, specified in a
1517 directive option. In this case, the content block must be empty. For
1518 example::
1519
1520 .. raw:: html
1521 :file: inclusion.html
1522
1523 Inline equivalents of the "raw" directive can be defined via
1524 `custom interpreted text roles`_ derived from the `"raw" role`_.
1525
1526 The following options are recognized:
1527
1528 ``file`` : string (newlines removed)
1529 The local filesystem path of a raw data file to be included.
1530
1531 ``url`` : string (whitespace removed)
1532 An Internet URL reference to a raw data file to be included.
1533
1534 ``encoding`` : string
1535 The text encoding of the external raw data (file or URL).
1536 Defaults to the document's encoding (if specified).
1537
1538 and the common option class_.
1539
1540
1541 .. _"raw" role: roles.html#raw
1542
1543
1544 .. _classes:
1545
1546 Class
1547 =====
1548
1549 :Directive Type: "class"
1550 :Doctree Element: pending_
1551 :Directive Arguments: One or more, required (class names / attribute
1552 values).
1553 :Directive Options: None.
1554 :Directive Content: Optional. If present, it is interpreted as body
1555 elements.
1556
1557 The "class" directive sets the `"classes"`_ attribute value on its content
1558 or on the first immediately following [#]_ non-comment element [#]_.
1559 The directive argument consists of one or more space-separated class
1560 names. The names are transformed to conform to the regular expression
1561 ``[a-z](-?[a-z0-9]+)*`` (see `Identifier Normalization`_ below).
1562
1563 Examples::
1564
1565 .. class:: special
1566
1567 This is a "special" paragraph.
1568
1569 .. class:: exceptional remarkable
1570
1571 An Exceptional Section
1572 ======================
1573
1574 This is an ordinary paragraph.
1575
1576 .. class:: multiple
1577
1578 First paragraph.
1579
1580 Second paragraph.
1581
1582 The text above is parsed and transformed into this doctree fragment::
1583
1584 .. code-block:: xml
1585
1586 <paragraph classes="special">
1587 This is a "special" paragraph.
1588 <section classes="exceptional remarkable">
1589 <title>
1590 An Exceptional Section
1591 <paragraph>
1592 This is an ordinary paragraph.
1593 <paragraph classes="multiple">
1594 First paragraph.
1595 <paragraph classes="multiple">
1596 Second paragraph.
1597
1598
1599 .. [#] This is also true, if the class directive is "nested" at the end of
1600 an indented text block, for example::
1601
1602 .. note:: the class values set in this directive-block do not apply to
1603 the note but the next paragraph.
1604
1605 .. class:: special
1606
1607 This is a paragraph with class value "special".
1608
1609 This allows the "classification" of individual list items (except the
1610 first, as a preceding class directive applies to the list as a whole)::
1611
1612 * bullet list
1613
1614 .. class:: classy item
1615
1616 * second item, with class argument
1617
1618 .. [#] To set a "classes" attribute value on a block quote, the
1619 "class" directive must be followed by an empty comment::
1620
1621 .. class:: highlights
1622 ..
1623
1624 Block quote text.
1625
1626 Without the empty comment, the indented text would be interpreted as the
1627 "class" directive's content, and the classes would be applied to each
1628 element (paragraph, in this case) individually, instead of to the block
1629 quote as a whole.
1630
1631
1632 Identifier Normalization
1633 ~~~~~~~~~~~~~~~~~~~~~~~~
1634
1635 Docutils `class names`_ and `identifier keys`_ are normalized to conform
1636 to the regular expression "``[a-z](-?[a-z0-9]+)*``" by converting
1637
1638 * alphabetic characters to lowercase,
1639 * accented characters to the base character,
1640 * non-alphanumeric characters to hyphens,
1641 * consecutive hyphens into one hyphen
1642
1643 and stripping
1644
1645 * leading hyphens and number characters, and
1646 * trailing hyphens.
1647
1648 For example ``"Rot.Gelb&Grün:+2008"`` becomes ``"rot-gelb-grun-2008"`` and
1649 ``"1000_Steps!"`` becomes ``"steps"``.
1650
1651 .. topic:: Rationale:
1652
1653 Identifier keys must be valid in all supported output formats.
1654
1655 For HTMLÂ 4.1 + CSS1 compatibility, identifiers should have no
1656 underscores, colons, or periods. Hyphens may be used.
1657
1658 - The `HTML 4.01 spec`_ defines identifiers based on SGML tokens:
1659
1660 ID and NAME tokens must begin with a letter ([A-Za-z]) and
1661 may be followed by any number of letters, digits ([0-9]),
1662 hyphens ("-"), underscores ("_"), colons (":"), and periods
1663 (".").
1664
1665 -- https://www.w3.org/TR/html401/types.html#type-name
1666
1667 - The `CSS1 spec`_ defines identifiers based on the "name" token
1668 ("flex" tokenizer notation below; "latin1" and "escape" 8-bit
1669 characters have been replaced with XML entities)::
1670
1671 unicode \\[0-9a-f]{1,4}
1672 latin1 [&iexcl;-&yuml;]
1673 escape {unicode}|\\[ -~&iexcl;-&yuml;]
1674 nmchar [-A-Za-z0-9]|{latin1}|{escape}
1675 name {nmchar}+
1676
1677 The CSS1 rule requires underscores ("_"), colons (":"), and
1678 periods (".") to be escaped [#]_,
1679 therefore `"classes"`_ and `"ids"`_ attributes should not
1680 contain these characters. Combined with HTML4.1 requirements (the
1681 first character must be a letter; no "unicode", "latin1", or
1682 "escape" characters), this results in the regular expression
1683 ``[A-Za-z][-A-Za-z0-9]*``. Docutils adds a normalization by
1684 downcasing and merge of consecutive hyphens.
1685
1686 .. [#] CSS identifiers may use underscores ("_") directly in
1687 `CSS Level 1`__, `CSS2.1`__, CSS2.2__, and CSS3__.
1688
1689 __ https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
1690 __ https://www.w3.org/TR/CSS/#css-level-1
1691 __ https://www.w3.org/TR/CSS22/syndata.html
1692 __ https://www.w3.org/TR/css-syntax-3/#typedef-ident-token
1693
1694 .. _HTML 4.01 spec: https://www.w3.org/TR/html401/
1695 .. _CSS1 spec: https://www.w3.org/TR/REC-CSS1
1696
1697 .. _role:
1698
1699 Custom Interpreted Text Roles
1700 =============================
1701
1702 :Directive Type: "role"
1703 :Doctree Element: None; affects subsequent parsing.
1704 :Directive Arguments: Two; one required (new `role name`_), one optional
1705 (base role name, in parentheses).
1706 :Directive Options: Possible (depends on base role).
1707 :Directive Content: depends on base role.
1708
1709 The "role" directive dynamically creates a custom `interpreted text
1710 role`_ and registers it with the parser. This means that after
1711 declaring a role like this::
1712
1713 .. role:: custom
1714
1715 the document may use the new "custom" role::
1716
1717 An example of using :custom:`interpreted text`
1718
1719 This will be parsed into the following document tree fragment::
1720
1721 .. code-block:: xml
1722
1723 <paragraph>
1724 An example of using
1725 <inline classes="custom">
1726 interpreted text
1727
1728 The role must be declared in a document before it can be used.
1729
1730 .. _role name:
1731
1732 Role names are case insensitive and must conform to the rules of
1733 simple `reference names`_ (but do not share a namespace with
1734 hyperlinks, footnotes, and citations).
1735
1736 The new role may be based on an existing role, specified as a second
1737 argument in parentheses (whitespace optional)::
1738
1739 .. role:: custom(emphasis)
1740
1741 :custom:`text`
1742
1743 The parsed result is as follows::
1744
1745 .. code-block:: xml
1746
1747 <paragraph>
1748 <emphasis classes="custom">
1749 text
1750
1751 A special case is the `"raw" role`_: derived roles enable
1752 inline `raw data pass-through`_, e.g.::
1753
1754 .. role:: raw-role(raw)
1755 :format: html latex
1756
1757 :raw-role:`raw text`
1758
1759 If no base role is explicitly specified, a generic custom role is
1760 automatically used. Subsequent interpreted text will produce an
1761 "inline" element with a `"classes"`_ attribute, as in the first example
1762 above.
1763
1764 With most roles, the ":class:" option can be used to set a "classes"
1765 attribute that is different from the role name. For example::
1766
1767 .. role:: custom
1768 :class: special
1769
1770 :custom:`interpreted text`
1771
1772 This is the parsed result::
1773
1774 .. code-block:: xml
1775
1776 <paragraph>
1777 <inline classes="special">
1778 interpreted text
1779
1780 .. _role class:
1781
1782 The following option is recognized by the "role" directive for most
1783 base roles:
1784
1785 ``class`` : text
1786 Set the `"classes"`_ attribute value on the element produced
1787 (``inline``, or element associated with a base class) when the
1788 custom interpreted text role is used. If no directive options are
1789 specified, a "class" option with the directive argument (role
1790 name) as the value is implied. See the class_ directive above.
1791
1792 Specific base roles may support other options and/or directive
1793 content. See the `reStructuredText Interpreted Text Roles`_ document
1794 for details.
1795
1796 .. _reStructuredText Interpreted Text Roles: roles.html
1797
1798
1799 .. _default-role:
1800
1801 Setting the Default Interpreted Text Role
1802 =========================================
1803
1804 :Directive Type: "default-role"
1805 :Doctree Element: None; affects subsequent parsing.
1806 :Directive Arguments: One, optional (new default role name).
1807 :Directive Options: None.
1808 :Directive Content: None.
1809
1810 The "default-role" directive sets the default interpreted text role,
1811 the role that is used for interpreted text without an explicit role.
1812 For example, after setting the default role like this::
1813
1814 .. default-role:: subscript
1815
1816 any subsequent use of implicit-role interpreted text in the document
1817 will use the "subscript" role::
1818
1819 An example of a `default` role.
1820
1821 This will be parsed into the following document tree fragment
1822
1823 .. code-block:: xml
1824
1825 <paragraph>
1826 An example of a
1827 <subscript>
1828 default
1829 role.
1830
1831 Custom roles may be used (see the "role_" directive above), but it
1832 must have been declared in a document before it can be set as the
1833 default role. See the `reStructuredText Interpreted Text Roles`_
1834 document for details of built-in roles.
1835
1836 The directive may be used without an argument to restore the initial
1837 default interpreted text role, which is application-dependent. The
1838 initial default interpreted text role of the standard reStructuredText
1839 parser is "title-reference".
1840
1841
1842 Metadata
1843 ========
1844
1845 :Directive Type: "meta"
1846 :Doctree Element: meta_
1847 :Directive Arguments: None.
1848 :Directive Options: None.
1849 :Directive Content: Must contain a flat field list.
1850
1851 The "meta" directive is used to specify metadata\ [#]_ to be stored
1852 in, e.g., `HTML meta elements`_ or as `ODT file properties`_. The
1853 LaTeX writer passes it to the ``pdfinfo`` option of the hyperref_
1854 package. If an output format does not support "invisible" metadata,
1855 content is silently dropped by the writer.
1856
1857 .. note:: Data from some `bibliographic fields`_ is automatically
1858 extracted and stored as metadata, too. However, Bibliographic
1859 Fields are also displayed in the document's screen rendering or
1860 printout.
1861
1862 For an "invisible" *document title*, see the `metadata document
1863 title`_ directive below.
1864
1865 Within the directive block, a flat field list provides the syntax for
1866 metadata. The field name becomes the contents of the "name" attribute
1867 of the META tag, and the field body (interpreted as a single string
1868 without inline markup) becomes the contents of the "content"
1869 attribute. For example::
1870
1871 .. meta::
1872 :description: The reStructuredText plaintext markup language
1873 :keywords: plaintext, markup language
1874
1875 This would be converted to the following HTML
1876
1877 .. code-block:: html
1878
1879 <meta name="description"
1880 content="The reStructuredText plaintext markup language">
1881 <meta name="keywords" content="plaintext, markup language">
1882
1883 Support for other META attributes ("http-equiv", "scheme", "lang",
1884 "dir") are provided through field arguments, which must be of the form
1885 "attr=value"::
1886
1887 .. meta::
1888 :description lang=en: An amusing story
1889 :description lang=fr: Une histoire amusante
1890
1891 And their HTML equivalents
1892
1893 .. code-block:: html
1894
1895 <meta name="description" lang="en" content="An amusing story">
1896 <meta name="description" lang="fr" content="Une histoire amusante">
1897
1898 Some META tags use an "http-equiv" attribute instead of the "name"
1899 attribute. To specify "http-equiv" META tags, simply omit the name::
1900
1901 .. meta::
1902 :http-equiv=Content-Type: text/html; charset=ISO-8859-1
1903
1904 HTML equivalent
1905
1906 .. code-block:: html
1907
1908 <meta http-equiv="Content-Type"
1909 content="text/html; charset=ISO-8859-1">
1910
1911 .. [#] "Metadata" is data about data, in this case data about the
1912 document. Metadata is, e.g., used to describe and classify web
1913 pages in the World Wide Web, in a form that is easy for search
1914 engines to extract and collate.
1915
1916 .. _HTML meta elements:
1917 https://html.spec.whatwg.org/multipage/semantics.html#the-meta-element
1918 .. _ODT file properties:
1919 https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Metadata
1920 .. _hyperref: https://ctan.org/pkg/hyperref
1921 .. _bibliographic fields: restructuredtext.html#bibliographic-fields
1922
1923
1924 Metadata Document Title
1925 =======================
1926
1927 :Directive Type: "title"
1928 :Doctree Element: Sets the document's `title attribute`_.
1929 :Directive Arguments: One, required (the title text).
1930 :Directive Options: None.
1931 :Directive Content: None.
1932
1933 The "title" directive specifies the document title as metadata, which
1934 does not become part of the document body. It overrides the
1935 document-supplied `document title`_ and the `"title" configuration
1936 setting`_. For example, in HTML output the metadata document title
1937 appears in the title bar of the browser window.
1938
1939 .. _document title: restructuredtext.html#document-title
1940 .. _"title" configuration setting: ../../user/config.html#title
1941
1942 Restructuredtext-Test-Directive
1943 ===============================
1944
1945 :Directive Type: "restructuredtext-test-directive"
1946 :Doctree Element: system_warning
1947 :Directive Arguments: None.
1948 :Directive Options: None.
1949 :Directive Content: Interpreted as a literal block.
1950
1951 This directive is provided for test purposes only. (Nobody is
1952 expected to type in a name *that* long!) It is converted into a
1953 level-1 (info) system message showing the directive data, possibly
1954 followed by a literal block containing the rest of the directive
1955 block.
1956
1957 --------------
1958 Common Options
1959 --------------
1960
1961 Most of the directives that generate doctree elements support the following
1962 options:
1963
1964 .. _class-option:
1965 .. _class:
1966
1967 ``class`` : text (space separated list of `class names`_)
1968 Set a `"classes"`_ attribute value on the doctree element generated by
1969 the directive. See also the class_ directive.
1970
1971 .. _name:
1972
1973 ``name`` : text
1974 Add `text` to the `"names"`_ attribute of the doctree element generated
1975 by the directive. This allows `hyperlink references`_ to the element
1976 using `text` as `reference name`_.
1977
1978 Specifying the `name` option of a directive, e.g., ::
1979
1980 .. image:: bild.png
1981 :name: my picture
1982
1983 is a concise syntax alternative to preceding it with a `hyperlink
1984 target`_ ::
1985
1986 .. _my picture:
1987
1988 .. image:: bild.png
1989
1990
1991 .. _reference name:
1992 .. _reference names: restructuredtext.html#reference-names
1993 .. _hyperlink target: restructuredtext.html#hyperlink-targets
1994 .. _hyperlink references: restructuredtext.html#hyperlink-references
1995 .. _class names: ../doctree.html#classnames-type
1996 .. _"classes": ../doctree.html#classes
1997 .. _identifier keys: ../doctree.html#ids-type
1998 .. _"ids": ../doctree.html#ids
1999 .. _"names": ../doctree.html#names
2000 .. _admonition: ../doctree.html#admonition
2001 .. _block_quote: ../doctree.html#block-quote
2002 .. _caption: ../doctree.html#caption
2003 .. _compound: ../doctree.html#compound
2004 .. _container element: ../doctree.html#container
2005 .. _decoration: ../doctree.html#decoration
2006 .. _figure: ../doctree.html#figure
2007 .. _footnote: ../doctree.html#footnote
2008 .. _footnote_reference: ../doctree.html#footnote-reference
2009 .. _generated: ../doctree.html#generated
2010 .. _image: ../doctree.html#image
2011 .. _inline elements: ../doctree.html#inline-elements
2012 .. _interpreted text role: roles.html
2013 .. _literal_block: ../doctree.html#literal-block
2014 .. _legend: ../doctree.html#legend
2015 .. _length: restructuredtext.html#length-units
2016 .. _line_block: ../doctree.html#line-block
2017 .. _math_block: ../doctree.html#math-block
2018 .. _meta: ../doctree.html#meta
2019 .. _pending: ../doctree.html#pending
2020 .. _percentage: restructuredtext.html#percentage-units
2021 .. _raw: ../doctree.html#raw
2022 .. _rubric: ../doctree.html#rubric
2023 .. _sidebar: ../doctree.html#sidebar
2024 .. _table: ../doctree.html#table
2025 .. _title: ../doctree.html#title
2026 .. _title attribute: ../doctree.html#title-attribute
2027 .. _topic: ../doctree.html#topic
2028
2029
2030
2031 ..
2032 Local Variables:
2033 mode: indented-text
2034 indent-tabs-mode: nil
2035 sentence-end-double-space: t
2036 fill-column: 70
2037 End: