From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#71685: [PATCH] fix shr rendering in tables without tbody Date: Sat, 6 Jul 2024 14:13:30 -0400 Message-ID: References: <65EAF7A2-697E-46E2-998C-AB99CC54E89C@gmail.com> <86h6d355vk.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_EDB2603C-B276-45FC-9781-E2A4C9E78D9E" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20915"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71685@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 06 20:15:16 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sQ9wK-0005Dd-IJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Jul 2024 20:15:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ9w4-0001kw-HU; Sat, 06 Jul 2024 14:15:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQ9w2-0001kL-LQ for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2024 14:14:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ9w2-0005tr-CO for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2024 14:14:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sQ9w5-0008QD-T7 for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2024 14:15:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jul 2024 18:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71685 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71685-submit@debbugs.gnu.org id=B71685.172028969432340 (code B ref 71685); Sat, 06 Jul 2024 18:15:01 +0000 Original-Received: (at 71685) by debbugs.gnu.org; 6 Jul 2024 18:14:54 +0000 Original-Received: from localhost ([127.0.0.1]:46731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQ9vx-0008PY-Ik for submit@debbugs.gnu.org; Sat, 06 Jul 2024 14:14:53 -0400 Original-Received: from mail-qv1-f45.google.com ([209.85.219.45]:47592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQ9vw-0008PK-1F for 71685@debbugs.gnu.org; Sat, 06 Jul 2024 14:14:52 -0400 Original-Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6b5f46191b5so10277086d6.3 for <71685@debbugs.gnu.org>; Sat, 06 Jul 2024 11:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720289623; x=1720894423; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=NZbVaGzqg6Zg62PTTuRfYVwxQcbA37EnSjwgWFPG46M=; b=UeBgyBW/01/akpKNvZJ3qYcglRdoEmgZJQd1qb0hBDoiUHl0tdAzVepg89WxHxn/zT ZFkmx3ZglPGATugWKw9whwJaPqxOpG7YgHYSbnRIOmlSezqsmGKD84jpnzhlveISSjSZ snObPhs+JdxfxcE8HhT1ry2JrpdV1ugCTqkOkk9Aj/9dxD7DopO04IhMeGnMbD2qzZR8 BB/dcL4TAnlpGqDiw/RyV7d+OuO+F9yIS4dzGl9SGZIULJRsXqta9V3Bp0uOxGFpatN6 Dfws4NAwzwZ6aQpe51Gg6Lb4etiMsiExSsf+fRlnFzP3EsCoKS4ieL4I/IoNGUGF2CK8 pJyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720289623; x=1720894423; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NZbVaGzqg6Zg62PTTuRfYVwxQcbA37EnSjwgWFPG46M=; b=SjlQ11PpXi8pAmvkYCB/w6bppaJ/sTKeyqfl8+dCmR1sMrY5YFu6lKpPzHsH8JDIgK kACtMlLG3XUCntpXglvDXiyAXNma/WCj+JjKS+fffiw/Ev74kykg2H/SE7WfhrRakaMC NzoAy9wBlTEuZl6GFixYLeGjbwkePSw7dq7cw2Ojaqu+dTzKW7OYnZZyQ3T5lU5qrlc5 OJo7cil5/YYDXEW8XF34MzKXipfT+zXogzhc7QNTkYTMjIorYwFQe4GqqNBB/B0b32mf WoFp6XLmoLdefBP6Oyyt3uksIeknnkMp+G6Mjuhua6aABLTqsLi653c5rmyZJ5TupU+A +vWg== X-Gm-Message-State: AOJu0YyGK+Q4yJLTz9eYoTBzgi7rMq4b2kuZRJRMce6vD65OsfKLogid ClYr4xupSEipa4x8zsE9drD/F4+UZLGqzAfmhjYOhODeRhJQBFKO X-Google-Smtp-Source: AGHT+IG0UkeJO7W5Fspq5IsMxoawNAtDuRmsHCxJDAKKL4GvaeRY1KX5QRAdlzDWuRGD9bUkDFCvzA== X-Received: by 2002:a05:6214:19cc:b0:6b5:dea6:f376 with SMTP id 6a1803df08f44-6b5ed0873a5mr116296746d6.61.1720289622553; Sat, 06 Jul 2024 11:13:42 -0700 (PDT) Original-Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b5ee6f0c27sm25967836d6.72.2024.07.06.11.13.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jul 2024 11:13:41 -0700 (PDT) In-Reply-To: <86h6d355vk.fsf@gnu.org> X-Mailer: Apple Mail (2.3774.600.62) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288516 Archived-At: --Apple-Mail=_EDB2603C-B276-45FC-9781-E2A4C9E78D9E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 6, 2024, at 3:36=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> From: JD Smith >> Date: Thu, 20 Jun 2024 15:15:32 -0400 >>=20 >> It is very common for HTML tables to include a header () = and/or footer () without using . Modern browsers simply = supply an implicit .. around all the unparented rows in a = table. `shr' does not handle this common case correctly. Below is an = example with but not . It prints the header, but then = subsumes it again inside the derived body, printing the header again in = a single cell. =20 >>=20 >> 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. >=20 > Thanks. I don't see any experts chiming in, so if you are confident > in the patch, and it doesn't fail the existing tests, please install > on the emacs-30 branch, and thanks. Bonus points for adding a test > for this case. Thanks. I'm afraid I don't have write access on savannah. I've added a = test and formatted the patch, below. All shr tests succeed. --Apple-Mail=_EDB2603C-B276-45FC-9781-E2A4C9E78D9E Content-Disposition: attachment; filename=0001-Fix-formatting-of-tables-with-thead-tfoot-but-no-tbo.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Fix-formatting-of-tables-with-thead-tfoot-but-no-tbo.patch" Content-Transfer-Encoding: quoted-printable =46rom=20623ecf07dc1b215cbc98f5804d58b571a649e9ba=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20JD=20Smith=20= <93749+jdtsmith@users.noreply.github.com>=0ADate:=20Sat,=206=20Jul=20= 2024=2009:22:33=20-0400=0ASubject:=20[PATCH]=20Fix=20formatting=20of=20= tables=20with=20thead/tfoot=20but=20no=20tbody=0A=0ACorrectly=20handle=20= formatting=20of=20tables=20containing=20thead=20and/or=20tfoot,=20but=0A= without=20any=20tbody,=20to=20prevent=20including=20thead/tfoot=20= content=20twice=20within=0Athe=20table's=20derived=20body=20(Bug#71685).=0A= *=20lisp/net.shr.el=20(shr--fix-tbody):=20Omit=20thead/tfoot=20from=20= implicit=20body=0A*=20test/lisp/net/shr-resources/table.html:=0A*=20= test/lisp/net/shr-resources/table.txt:=0AAdded=20table=20rendering=20= test.=0A---=0A=20lisp/net/shr.el=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20|=205=20+++--=0A=20= test/lisp/net/shr-resources/table.html=20|=207=20+++++++=0A=20= test/lisp/net/shr-resources/table.txt=20=20|=205=20+++++=0A=203=20files=20= changed,=2015=20insertions(+),=202=20deletions(-)=0A=20create=20mode=20= 100644=20test/lisp/net/shr-resources/table.html=0A=20create=20mode=20= 100644=20test/lisp/net/shr-resources/table.txt=0A=0Adiff=20--git=20= a/lisp/net/shr.el=20b/lisp/net/shr.el=0Aindex=203dadcb9a09b..fb72ea6aa67=20= 100644=0A---=20a/lisp/net/shr.el=0A+++=20b/lisp/net/shr.el=0A@@=20= -2261,8=20+2261,9=20@@=20shr-table-body=0A=20(defun=20shr--fix-tbody=20= (tbody)=0A=20=20=20(nconc=20(list=20'tbody=20(dom-attributes=20tbody))=0A= =20=20=20=20=20=20=20=20=20=20(cl-loop=20for=20child=20in=20= (dom-children=20tbody)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20collect=20(if=20(or=20(stringp=20child)=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(not=20(eq=20(dom-tag=20child)=20'tr)))=0A+=09=09=20=20for=20tag=20=3D=20= (and=20(not=20(stringp=20child))=20(dom-tag=20child))=0A+=09=09=20=20= unless=20(or=20(eq=20tag=20'thead)=20(eq=20tag=20'tfoot))=0A+=09=09=20=20= collect=20(if=20(not=20(eq=20tag=20'tr))=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(list=20= 'tr=20nil=20(list=20'td=20nil=20child))=0A=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20child))))=0A=20=0A= diff=20--git=20a/test/lisp/net/shr-resources/table.html=20= b/test/lisp/net/shr-resources/table.html=0Anew=20file=20mode=20100644=0A= index=2000000000000..c5e8875ac91=0A---=20/dev/null=0A+++=20= b/test/lisp/net/shr-resources/table.html=0A@@=20-0,0=20+1,7=20@@=0A= +=0A+=0A= +=0A+=0A+5678=0A= +=0A+
AB
12
34
AB
=0Adiff=20--git=20= a/test/lisp/net/shr-resources/table.txt=20= b/test/lisp/net/shr-resources/table.txt=0Anew=20file=20mode=20100644=0A= index=2000000000000..70939effb63=0A---=20/dev/null=0A+++=20= b/test/lisp/net/shr-resources/table.txt=0A@@=20-0,0=20+1,5=20@@=0A+=20=20= A=20=20B=20=20=20=20=0A+=20=201=20=202=20=20=20=20=0A+=20=203=20=204=20=20= =20=20=0A+=20=205678=20=20=20=20=20=0A+=20=20A=20=20B=20=20=20=20=0A--=20= =0A2.43.0=0A=0A= --Apple-Mail=_EDB2603C-B276-45FC-9781-E2A4C9E78D9E--