Search code examples
restructuredtext

How to wrap a long literal block in reStructuredText?


I have a literal block consisting of a single long line. It is currently displayed as a single-line block with horizontal scrollbar (like the literal block below). How do you implement auto-formatting to wrap the line so it wraps dynamically when the browser is resized?

::
  Long line that does not wrap...........................................................................................

Solution

  • This could be done by overriding the default CSS with a new style:

    pre {
        white-space: pre-wrap;
    }
    

    Edit your theme's CSS file to include this directive and it should just work.