GNU bug report logs - #71685
[PATCH] fix shr rendering in tables without tbody

Previous Next

Package: emacs;

Reported by: JD Smith <jdtsmith <at> gmail.com>

Date: Thu, 20 Jun 2024 19:16:01 UTC

Severity: normal

Tags: patch

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#71685: closed ([PATCH] fix shr rendering in tables without tbody)
Date: Sat, 06 Jul 2024 19:13:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 6 Jul 2024 19:11:00 +0000
with message-id <CADwFkmmqCETothWPE9aZ2gsjgjUTPCi-U7gXnQ=APGO9x6Rb_Q <at> mail.gmail.com>
and subject line Re: bug#71685: [PATCH] fix shr rendering in tables without tbody
has caused the debbugs.gnu.org bug report #71685,
regarding [PATCH] fix shr rendering in tables without tbody
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
71685: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71685
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: JD Smith <jdtsmith <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] fix shr rendering in tables without tbody
Date: Thu, 20 Jun 2024 15:15:32 -0400
[Message part 3 (text/plain, inline)]
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 | |
| ---  --   |
 ---------  


[shr_fix_tbody.patch (application/octet-stream, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Stefan Kangas <stefankangas <at> gmail.com>
To: JD Smith <jdtsmith <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 71685-done <at> debbugs.gnu.org
Subject: Re: bug#71685: [PATCH] fix shr rendering in tables without tbody
Date: Sat, 6 Jul 2024 19:11:00 +0000
Version: 30.1

JD Smith <jdtsmith <at> gmail.com> 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.


This bug report was last modified 1 year and 33 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.