Subject: bug#71685: closed (Re: bug#71685: [PATCH] fix shr rendering in tables without tbody)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 06 Jul 2024 19:13:02 +0000

Your bug report

#71685: [PATCH] fix shr rendering in tables without tbody

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71685: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71685
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71685: [PATCH] fix shr rendering in tables without tbody
From: Stefan Kangas <[email-masked]>
To: JD Smith <[email-masked]>, Eli Zaretskii <[email-masked]>
Cc: [email-masked]
Date: Sat, 6 Jul 2024 19:11:00 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 30.1

JD Smith <[email-masked]> writes:

> I've added a test and formatted the patch, below.  All shr tests
> succeed.

Thanks, installed on emacs-30 as commit 9625e4af994.

I'm therefore closing this bug report.

Subject: [PATCH] fix shr rendering in tables without tbody
From: JD Smith <[email-masked]>
To: [email-masked]
Date: Thu, 20 Jun 2024 15:15:32 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

It is very common for HTML tables to include a header (<thead>) and/or footer (<tfoot>) without using <tbody>.  Modern browsers simply supply an implicit <tbody>..</tbody> around all the unparented rows in a table.  `shr' does not handle this common case correctly.  Below is an example with <thead> but not <tbody>.  It prints the header, but then subsumes it again inside the derived body, printing the header again in a single cell.  

The relevant function which should handle this is `shr--fix-tbody'.   The included patch to this function simply avoids including `thead` and `tfoot` children in the implicit body.

(let ((shr-table-vertical-line ?|)
      (shr-table-horizontal-line ?-))
  (shr-insert-document
   (with-temp-buffer
     (insert "<table>
<thead><tr><th>A</th><th>B</th></tr></thead>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
</table>")
     (libxml-parse-html-region))))

 ---------  
| ---  --   |
||A |B | |
| ---  --   |
||AB | |
| ---  --   |
||1 |2 | |
| ---  --   |
||3 |4 | |
| ---  --   |
 ---------