8

I'm using Sphinx to document a Python project.

There seems to be a bit of inconsistency with the .. csv-table:: directive.

The main issue is a new line in a cell. And my questionable mental health.

The following code:

.. csv-table::
    :header: Header1, Header2, Header3

    A, B, "These lines appear as one line, 
    even though they are written in two lines."
    C, D, "| These lines appear as two lines, 
    | but they are indented, and my OCD will simply not allow it."
    E, F, "| If I continue this line in another line,
    it will appear in a new line."
    G, H, "If there is a blank line between the two lines,

    there will be a blank line between the lines."

Will render as:

enter image description here

I have searched through the entire reStructuredText manual, but could not find a way to solve it.

Is there any way to write two lines in one cell that will appear as the 2nd row, but without the indentation?

The theme is sphinx_rtd_theme.

I found the theme.css file (C:\Python34\Lib\site-packages\sphinx_rtd_theme\static\css\theme.css), but I can't find the section of the table definition for newline styling

Derorrist
  • 2,753
  • 1
  • 17
  • 26

1 Answers1

5

Line blocks have a left margin value in the sphinx_rtd_theme. One way to get rid of them is to create a custom CSS file which imports the theme's style rules and add a rule for line blocks within tables without that margin. Assuming the standard file and path names of a Sphinx project:

Create a _static/css/mystyle.css file in your Sphinx project with the following content:

@import "theme.css";

table.docutils div.line-block {
    margin-left: 0;
}

Add the following option to the conf.py:

html_style = 'css/mystyle.css'

Rebuild the Sphinx project.

BlackJack
  • 4,476
  • 1
  • 20
  • 25