I use rst heavily for my documents and slides for teaching which in turn include many independent code blocks. It is cumbersome to copy and paste indented code blocks.
There are some workarounds:
include
directive using start-line
end-line
when sourcing from a single documentIf short independent code snippets are used in rst, these workarounds are not convenient or feasible.
It is not easy to integrate CommonMark style blocks, because it could clash with headers [2] (There is an extension for Sphinx for this purpose [1])
[1] https://sphinx-codefence.readthedocs.io/
Also see the short discussion:
[2] https://sourceforge.net/p/docutils/mailman/message/37170674/
Thank you for the suggestion.
Should fenced blocks become "literal blocks" or "code blocks"?
https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#literal-blocks
https://docutils.sourceforge.io/docs/ref/rst/directives.html#code
A problem with the implementation in the Sphinx extension [1] is a possible clash with section underlining like ::
This could be circumvented with fenced literal blocks requiring a leading
::
(just like quoted literal blocks). https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#quoted-literal-blocksDisambiguation is also possible via the blank line required before a fenced literal block.
Disambiguation from a transition is simple, as "syntax for a transition marker is a horizontal line of 4 or more repeated punctuation characters". https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#transitions