Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word wrap does not work well in grid tables #1246

Open
mhdirkse opened this issue Oct 11, 2021 · 2 comments
Open

Word wrap does not work well in grid tables #1246

mhdirkse opened this issue Oct 11, 2021 · 2 comments
Labels
Bug A bug Needed: replication Bug replication is required

Comments

@mhdirkse
Copy link

Problem

I had a grid table with two columns. The table became too wide because word wrap did not work properly. See question on StackOverflow. I got an answer that suggested a custom style sheet:

.wy-table-responsive table td, .wy-table-responsive table th {
    white-space: inherit;
}

This fixed my issue. I would like this behavior without having to add a custom style sheet.

Reproducible Project

See https://frank-manual.readthedocs.io/en/credentials/deploying/credentials.html and https://github.com/ibissource/frank-manual/tree/credentials. This code does what I want, but only because I have a custom style sheet custom.css. I would like to be able to remove that file.

Error Logs/Results

Place any images or error logs that might be able to help solve the issue here.

Expected Results

Please describe how this should work properly.

Environment Info

  • Python Version: Python 3.8.2
  • Sphinx Version: 4.0.0
  • RTD Theme Version: 0.5.2
@mhdirkse mhdirkse added Bug A bug Needed: replication Bug replication is required labels Oct 11, 2021
@nienn
Copy link
Contributor

nienn commented Oct 11, 2021

Hi @mhdirkse, unfortunately, this is not a feature that we can implement by default.

Modern tables are used to display all kinds of data and this makes it exceedingly difficult to find a rule that will fit all purposes. The table primarily purpose, however, is to display tabular data, often technical data, that generally benefits from not being wrapped randomly. We must keep this in mind when defining the default tables' behaviour in a way that best fits the majority of uses.

On a future major version of the theme we will try to offer more options for tables display with minimal setup. For now, the custom.css is still the best option.

@mhdirkse
Copy link
Author

Thanks, Mrs. Costa.

LeSpocky pushed a commit to LeSpocky/ptxdist that referenced this issue May 8, 2023
By default, spinx_rtd_theme sets the CSS attribute "white-space: nowrap"
on table cells, which has the effect, that table contents never
word-wrap and the table gets scrollable. This is unfortunate if table
cells contain a large amount of text.

Issue #1246 of sphinx_rtd_theme addresses this situation, but the
general fix is not that easy. Until this issue is fixed upstream,
introduce a custom CSS class named "word-wrap" that reverts the
behaviour of table cells back to do word wrapping when the content of
the cell is wider than the available width.

With this change, the following example should produce a table as wide
as the content area with word-wrapped text in the second row:

  .. table::
     :class: word-wrap

     +--------------------------------+-----------------------------+
     | Column 1                       | Column 2                    |
     +================================+=============================+
     | Lorem ipsum dolor sit amet,    | Duis aute irure dolor in    |
     | adipisicing elit, sed do eius  | voluptate velit esse cillum |
     | incididunt ut labore et dolor  | fugiat nulla pariatur.      |
     | aliqua. Ut enim ad minim veni  | Excepteur sint occaecat     |
     | nostrud exercitation ullamco   | proident, sunt in culpa     |
     | nisi ut aliquip ex ea commodi. | deserunt mollit anim id.    |
     +--------------------------------+-----------------------------+
     | Third Row                      | Third Row continued         |
     +--------------------------------+-----------------------------+

Link: readthedocs/sphinx_rtd_theme#1246
Signed-off-by: Roland Hieber <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Michael Olbrich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: replication Bug replication is required
Projects
None yet
Development

No branches or pull requests

2 participants