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

Support for grid tables with multiple table bodies #8266

Open
tarleb opened this issue Sep 1, 2022 · 3 comments
Open

Support for grid tables with multiple table bodies #8266

tarleb opened this issue Sep 1, 2022 · 3 comments

Comments

@tarleb
Copy link
Collaborator

tarleb commented Sep 1, 2022

This is a proposal to add support for multiple table bodies by treating two consecutive row separators as table body delimiter.

E.g., this table

+------+-------+
| Item | Price |
+======+=======+
| Eggs | 5£    |
+------+-------+
| Spam | 3£    |
+------+-------+
+------+-------+
| Sweets       |
+------+-------+
| Item | Price |
+======+=======+
| Ice  | 2£    |
+======+=======+
| Sum  | 9£    |
+======+=======+

would be parsed to

<table>
  <thead>
    <tr><th>Item</th><th>Price</th></tr>
  </thead>
  <tbody>
    <tr><td>Eggs</td><td></td></tr>
    <tr><td>Spam</td><td></td></tr>
  </tbody>
  <tbody>
    <tr><th colspan="2">Sweets</th></tr>
    <tr><th>Item</th><th>Price</th></tr>
    <tr><td>Ice</td><td></td></tr>
  </tbody>
  <tfoot>
    <tr><td>Sum</td><td>10£</td></tr>
  </tfoot>
</table>

Note that the bodies can have header rows, but the first head separator (+===+) always marks the head of the full table.

@jgm
Copy link
Owner

jgm commented Sep 1, 2022

I'm not sure. This does introduce an ambiguity, since currently

+------+-------+
| Spam | 3£    |
+------+-------+
+------+-------+
| Sweets       |
+------+-------+

is two distinct tables.

Also: I'm not clear about the significance of multiple table bodies. Can you give an example of a rendered table with multiple bodies, so I can see what it would be used for? (I know that HTML and our AST allow this.)

@tarleb
Copy link
Collaborator Author

tarleb commented Sep 1, 2022

Our test suite uses an example from MDN to test handling of multiple bodies. I don't particularly like these tables: most of the times those table should have an additional column instead, or be presented as separate tables. So I'm ok with not supporting them for now.

The updated parser follows rst interpretation of two consecutive row separators: it treats the above as a single table with three rows, where the second row is empty. I hadn't realize that we changed parsing behavior in this case.

@tarleb
Copy link
Collaborator Author

tarleb commented Sep 1, 2022

An image search for "rowgroup tables" yields a number of tables that, I have to admit, look like legitimate use cases for this feature. Example taken from this question.

Example

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

No branches or pull requests

2 participants