File: html5-features.rst

package info (click to toggle)
python-docutils 0.22%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 11,448 kB
  • sloc: python: 53,302; lisp: 14,475; xml: 1,807; javascript: 1,032; makefile: 102; sh: 96
file content (266 lines) | stat: -rw-r--r-- 7,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
Differences to the `html4css1` Writer
=====================================

* Use only meta_ keywords recognized by HTML 5.
  Add HTML5-compatible meta tags for docinfo items
  "authors", "date", and "copyright".

  Add a `viewport meta tag`__ to tell mobile browsers
  to use the device-width as viewport.

  __ https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag

* Set table column widths with <style="width: ...">, not "width" argument.

* Horizontal alignment of table heads with CSS.

* Do not drop paragraph elements, use CSS rules to prevent unwanted vertical
  space.

* Put subtitles in <p> elements.

* Use the new semantic tags <main>, <section>, <header>,
  <footer>, <aside>, <figure>, and <figcaption>.
  See ``minimal.css`` and ``responsive.css`` for styling rule examples.

  Change the `initial_header_level` setting default to "2", as browsers
  use the `same style for <h1> and <h2> when nested in a <section\>`__.

  __ https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article

* Use HTML5 tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
  <i>, <b>, <u>, <mark>, and <bdi> if a matching class value
  is found in `inline` and `literal` elements.
  Use <ins> and <del> if a matching class value
  is found in `inline`, `literal`, or `container` elements.
  (See `text-level semantics`_ and `indicating edits`_.)

* Use <img> tags for SVG images and <video> for video formats.

* .. image:: ../input/data/blue%20square.png
     :loading: embed
     :alt: blue square
     :align: right

  Embed images or defer fetching images with the image-loading_
  configuration setting or the "loading" option of the "image" directive.

  .. image:: ../../../docs/user/rst/images/biohazard.png
     :loading: lazy
     :width: 16
     :height: 16
     :align: right

  Especially with "lazy" loading, it is strongly recommended to
  specify both width and height of the image to prevent content layout
  shifts or use the "scale" option to let the writer insert the size
  determined from the image file.

.. _image-loading:
    https://docutils.sourceforge.io/docs/user/config.html#image-loading


Field List Rendering
--------------------

A `field list` is converted to a HTML `definition list` and given the
``field-list`` class argument value to allow CSS styling.
With ``html_plain.css``, the layout is similar to `html4css1`:

.. class:: open

:A long field name: sticks into the field body.

    The field body is pushed to the next line (you can suppress this
    behaviour with the `run-in`_ class argument).

:Customization: of the field name width is possible with CSS instead
    of the `field-name-limit` configuration setting, for
    example::

      dl.field-list > dd { margin-left: 6em; }

:Empty:

:fields:  must not lead to misalignment of the following content.

Styling with Class Arguments
----------------------------

The ``plain.css`` style sheet comes with some pre-defined style variants
that can be chosen via a class argument.

Description Lists
`````````````````

Definition lists with the "description" class argument:

.. class:: description

description lists
    Definition lists that are styled like in most dictionaries,
    encyclopedias etc. (as well as the LaTeX `description` environment).
label
    The term to be described. Put in boldface or italic.
Content
    starts on the same line and has a hanging indent.
A label without content
    ..
and the next label
    must align.

as well
    as content containing more than one

    paragraph

or
    * nested lists
    * item 2
or
    nested
      definition lists

Details disclosure elements
```````````````````````````

Items of `definition lists`_ with class argument "details" are converted
to `details`_ disclosure elements with the term becoming the "summary".

.. _closed-details:
.. class:: details

A summary
  with details only visible after user interaction.

.. _open-details:
.. class:: details open

Another summary
  with open details because the source list has the additional class
  value "open".

.. _details:
   https://www.w3.org/TR/html52/interactive-elements.html#the-details-element

Field List Variants
```````````````````

For field lists, the "compact/open", "narrow" and "run-in" styles are defined
in the style sheets ``plain.css`` and ``responsive.css``.

*compact*
  .. class:: compact

  :Feature: No additional space between list items.

  :Option: The ``--compact-field-lists`` command line option (and the
           corresponding configuration setting) set the `compact`
           class argument on all "simple" field lists, if not
           overridden with `open`.

  :Use:  For lists with short field body.

*open*
  .. class:: open

  :Feature: Additional space between list items also in "simple" lists.
            (Overrides the ``--compact-field-lists`` command line
            option and the corresponding configuration setting)

  :Use: For "simple" lists that should keep the space between list items.

*narrow*
  .. class:: narrow

  :Feature: Less indented field body.
  :Use:   For lists with short field names.
  :A long field name:
       sticks into the field body and the field body starts on a
       new line (if not combined with `run-in`_).

custom *field-indent*
  .. class:: field-indent-3em

  :Feature: Field body indented by custom amount.
  :Use:     class value starting with ``field-indent-`` followed by
            a valid length, e.g. ``field-indent-3em``.
  :The writer:
            will convert this class value to a ``style`` attribute setting.

.. _`run-in`:

*run-in*
  .. class:: run-in

  :Feature: Field body starts on the same line also after long field
            names.

  :A long field name: sticks into the field body which continues on
                         the same line.

  :The next field name:  and field body should align. Long text in the field
                         body is wrapped and aligns with other fields.

Table Variants
``````````````

The following styles can be applied to individual tables via a class
argument or as document wide setting with the table-style_ configuration
setting (or command line argument).

* Numbered tables can be achieved with the "numbered" class option:

  .. table:: truth values
     :class: numbered

     ======= ======= ==========
     A       B       A or B
     ======= ======= ==========
     False   False   False
     True    False   True
     False   True    True
     True    True    True
     ======= ======= ==========

  Currently, referencing to the table by number is not supported. This is a
  common request and already on the `TODO list`.

* A table with "booktabs" class value, is rendered similar to the style
  from the booktabs_ LaTeX package.

  .. _table-style:
     https://docutils.sourceforge.io/docs/user/config.html#table-style
  .. _booktabs:
     http://tug.ctan.org/tex-archive/macros/latex/contrib/booktabs/booktabs.pdf

"Booktabs" style table, numbered, centre-aligned, with auto-sized columns:

  .. table:: I/O values
     :class: booktabs numbered
     :align: center
     :widths: auto

     ======= ======= ==========
     Input           Output
     --------------- ----------
     A       B       A or B
     ======= ======= ==========
     False   False   False
     True    False   True
     False   True    True
     True    True    True
     ======= ======= ==========

Numbered Figures
````````````````

Numbered figures can be achieved with the "numbered" ``:figclass:`` option:

.. figure:: ../../../docs/user/rst/images/title-scaling.svg
   :alt: reStructuredText, the markup syntax
   :figclass: numbered
   :width: 100%
   :loading: embed

   Embedded SVG image in a numbered figure.