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

Table formatting breaks #20

Open
kaddkaka opened this issue Mar 16, 2022 · 2 comments
Open

Table formatting breaks #20

kaddkaka opened this issue Mar 16, 2022 · 2 comments

Comments

@kaddkaka
Copy link

Trying to format

==== =====
Head Foot
==== =====
1    1234
12   12 34
123  123 4
1234 123
==== =====

results in

+----+-----+
| Head | Foot |
+====+=====+
| 1  | 1234 |
+----+-----+
| 12 | 12  |
|    | 34  |
+----+-----+
| 123 | 123 |
|    | 4   |
+----+-----+
| 1234 | 123 |
+----+-----+

which is a broken table.

The problem seems to happen when the cell content is a single word and fills the full width of the cell or full_width-1.

@StaticRocket
Copy link

StaticRocket commented Jan 13, 2024

Adding to this issue, formatting will also break if:

  • If a span is present in the table

And formatting right now has a chance to break if:

  • If the table contents contain vertical bars that use the offset

https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#grid-tables

I'm looking at trying to get around this right now. It basically revolves around us parsing the whole table block as opposed to the header and rows separately, reconstructing the table geometry from the morecols and morerows attributes of occasional <entry...> objects in the rows. No idea why docutils chooses to be lossy with this info depending on the table construction...

Should be easy enough to tack on an extra whitespace row for rows containing a vertical bar in the paragraph contents in all of that other mess.

@StaticRocket
Copy link

Table from hell example:

+-----------+-----------+----------+
| 1         | 2         | 3        |
+===========+===========+==========+
| 4         | 5         | 6        |
+           +-----------+          +
|           | 7         |          |
+           +-----------+          +
|           | 8         |          |
+           +-----+-----+          +
|           | 9   | 10  |          |
+-----------+-----+-----+----------+
| 11        | 12        | 13       |
+-----------+-----------+----------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants