useblocks / sphinx-simplepdf

A simple PDF builder for Sphinx documentations
https://sphinx-simplepdf.readthedocs.io
MIT License
36 stars 15 forks source link

Overflow wrapping of content in, e.g. in tables #34

Open kreuzberger opened 1 year ago

kreuzberger commented 1 year ago

If i have non-breakable content in my tables (e.g. in Tables from sphinx-needs specifications) or in RestructuredText Tables directly, the tables are rendered in html fine by adding scroolbars (e.g. to datatables styles in needs-table) or in html directly.

In the pdf output the table is extend over the right margins and page, also ignoring any colwidths hints.

What is the default strategy for this?

Attached is a patch to get to the issue by adding "Non-breakable" content to the demo files sphinx-simplepdf_long_text_breaks.txt

This may be affected also to weasyprint issues regarding table layouts itself, see #weasyprint-541

kreuzberger commented 1 year ago

Fixing the issue with #weasyprint-541 has issues with default layouting of tables. Instead could #weasyprint-1520 be used with overflow-wrap: anywhere to fix the issue.

The demo pdf is then changed in layout, currently not clear what else could be influenced.

in _table.scss add overflow-wrap: anywhere; to table.docutils { td, th {section

kreuzberger commented 1 year ago

The affected sections in the demo pdf are the table output in "Giant Tables". Withoud modification these are also printed not completly in the pdf, but after the patch completly with very small columns.

Maybe its best to add a "class" to hande this behaviour and then use this in table directies to enable/disable default overlap handling.

danwos commented 1 year ago

Thanks for the analysis. I think there is not one solution to solve all possible table problems.

And a good solution would be to provide 1-2 classes, which deal differently with it. By default, I would not change any font or column space sizes. It's up to the user to provide PDF-compatible content or to select the needed representation by setting the suitable class.

kreuzberger commented 1 year ago

we came to the same solution :-) Provided a PR with an extra class for table wrapping. "Motivation" from my issue came from imported needs requirements, shown in an overview (database tables) and in a complete list of requirements. Due to the imported nature there is no chance to get "breakable" words in the specifications, e.g for "file naming conventions" or url handlings

sachin-suresh-rapyuta commented 1 year ago

What is the final fix for this @danwos. I also see the table column overflow to the right if it has more than 3 columns.