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

Ensure that group label rows have valid HTML #308

Merged
merged 5 commits into from
Apr 22, 2024

Conversation

rich-iannone
Copy link
Member

@rich-iannone rich-iannone commented Apr 19, 2024

From a simple rendering of:

from great_tables import GT, exibble

GT(exibble, rowname_col="row", groupname_col="group").as_raw_html()

the following invalid HTML is generated for a group label row and the row below:

<tbody class="gt_table_body">
<tr>
<tr class=gt_group_heading_row>  <th class="gt_group_heading" colspan="8">grp_a</th></tr>
  <th class="gt_row gt_left gt_stub">row_1</th>
  <td class="gt_row gt_right">0.1111</td>
  <td class="gt_row gt_left">apricot</td>
  <td class="gt_row gt_left">one</td>
  <td class="gt_row gt_right">2015-01-15</td>
  <td class="gt_row gt_right">13:35</td>
  <td class="gt_row gt_right">2018-01-01 02:22</td>
  <td class="gt_row gt_right">49.95</td>
</tr>

The first <tr> should instead be opening tag for the collection of <th> and <td> tags. Browsers could handle this invalid code and generate a suitable table display but not Quarto/Pandoc (requires that the HTML be valid in order for it to be parsed).

With this PR, the HTML generated should instead be:

<tbody class="gt_table_body">
  <tr class="gt_group_heading_row">
    <th class="gt_group_heading" colspan="8">grp_a</th>
  </tr>
  <tr>
    <th class="gt_row gt_left gt_stub">row_1</th>
    <td class="gt_row gt_right">0.1111</td>
    <td class="gt_row gt_left">apricot</td>
    <td class="gt_row gt_left">one</td>
    <td class="gt_row gt_right">2015-01-15</td>
    <td class="gt_row gt_right">13:35</td>
    <td class="gt_row gt_right">2018-01-01 02:22</td>
    <td class="gt_row gt_right">49.95</td>
  </tr>

Fixes: #306

@github-actions github-actions bot temporarily deployed to pr-308 April 19, 2024 19:20 Destroyed
@github-actions github-actions bot temporarily deployed to pr-308 April 19, 2024 19:22 Destroyed
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.72%. Comparing base (14ce2c5) to head (9a1634b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #308   +/-   ##
=======================================
  Coverage   81.71%   81.72%           
=======================================
  Files          41       41           
  Lines        4321     4323    +2     
=======================================
+ Hits         3531     3533    +2     
  Misses        790      790           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot temporarily deployed to pr-308 April 19, 2024 19:58 Destroyed
@rich-iannone rich-iannone marked this pull request as ready for review April 22, 2024 17:29
@github-actions github-actions bot temporarily deployed to pr-308 April 22, 2024 17:53 Destroyed
Copy link
Collaborator

@machow machow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rich-iannone rich-iannone merged commit b4d102a into main Apr 22, 2024
9 checks passed
@rich-iannone rich-iannone deleted the fix-group-heading-row-invalid-html branch April 22, 2024 18:46
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

Successfully merging this pull request may close these issues.

great tables emitting invalid html for group heading rows
3 participants