Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reStructuredText newline character breaks code blocks

I am using reStructuredText and Sphinx in order to generate a set of docs. Every page must be PEP8 compliant and therefore has a max of 80 characters per line. This is a new requirement and is breaking several pages.

When we used to have:

.. code-block:: bash
    really really long line of code that I would want a new user to copy and paste into a terminal

We now have:

.. code-block:: bash
    really really long line of code that
    I would want a new user to copy and
    paste into a terminal

Which is a problem as every line is treated like a separate command when pasting into the terminal. Reading the docs I see I could do something like:

| really really long line of code that I 
  would want a new user to copy and paste
  into a terminal

to make my text fit on 1 line, but this does not keep the block styling or syntax highlighting I want. Does anyone know of a way to achieve what I am looking for? Thanks in advance for any and all feedback!

like image 440
gh4x Avatar asked Feb 02 '15 23:02

gh4x


1 Answers

You should be able to use a backslash to indicate that the line continues. It escapes the newline character.

.. code-block:: bash

   really really long line of code that \
   I would want a new user to copy and \
   paste into a terminal

The command is interpreted as one long line when pasted into a terminal.

See http://www.gnu.org/software/bash/manual/bashref.html#Escape-Character.

like image 72
mzjn Avatar answered Oct 07 '22 01:10

mzjn