summaryrefslogtreecommitdiffstats
path: root/tests/roots/test-directive-code/dedent.rst
blob: 66ac91c0052672b737650ed8807ea82a1293bbac (plain)
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
dedent option
-------------

.. code-block::

   First line
   Second line
       Third line
   Fourth line

ReST has no fixed indent and only a change in indentation is significant not the amount [1]_.
Thus, the following code inside the code block is not indent even it looks so with respect to the previous block.

.. code-block::

       First line
       Second line
           Third line
       Fourth line

Having an option "fixates" the indent to be 3 spaces, thus the code inside the code block is indented by 4 spaces.

.. code-block::
   :class: dummy

       First line
       Second line
           Third line
       Fourth line

The code has 6 spaces indent, minus 4 spaces dedent should yield a 2 space indented code in the output.

.. code-block::
   :dedent: 4

         First line
         Second line
             Third line
         Fourth line

Dedenting by zero, should not strip any spaces and be a no-op.

.. note::
   This can be used as an alternative to ``:class: dummy`` above, to fixate the ReST indentation of the block.

.. code-block::
   :dedent: 0

       First line
       Second line
           Third line
       Fourth line

Dedent without argument should autostrip common whitespace at the beginning.

.. code-block::
   :dedent:

       First line
       Second line
           Third line
       Fourth line

.. [1] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#indentation