From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.bugs Subject: bug#24831: shr mangling messages Date: Tue, 01 Nov 2016 18:59:39 +0900 Organization: Emacsen advocacy group Message-ID: References: <87shrgvt8y.fsf@jidanni.org> <87shrd6xsp.fsf_-_@jidanni.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1477994441 18064 195.159.176.226 (1 Nov 2016 10:00:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 1 Nov 2016 10:00:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (i686-pc-cygwin) Cc: jidanni@jidanni.org To: 24831@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 01 11:00:33 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1Vrb-00021Y-IU for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Nov 2016 11:00:15 +0100 Original-Received: from localhost ([::1]:46619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Vre-00017V-3n for geb-bug-gnu-emacs@m.gmane.org; Tue, 01 Nov 2016 06:00:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1VrS-00010Q-Tp for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2016 06:00:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1VrP-0000wj-7X for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2016 06:00:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1VrP-0000w6-3r for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2016 06:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1c1VrO-00084M-Ps for bug-gnu-emacs@gnu.org; Tue, 01 Nov 2016 06:00:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87shrd6xsp.fsf_-_@jidanni.org> Resent-From: Katsumi Yamaoka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Nov 2016 10:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24831 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24831-submit@debbugs.gnu.org id=B24831.147799439330969 (code B ref 24831); Tue, 01 Nov 2016 10:00:02 +0000 Original-Received: (at 24831) by debbugs.gnu.org; 1 Nov 2016 09:59:53 +0000 Original-Received: from localhost ([127.0.0.1]:38566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1VrE-00083R-QS for submit@debbugs.gnu.org; Tue, 01 Nov 2016 05:59:52 -0400 Original-Received: from mail-hampton.hostforweb.net ([205.234.186.191]:52121 helo=hampton.hostforweb.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c1VrD-00083C-7A for 24831@debbugs.gnu.org; Tue, 01 Nov 2016 05:59:51 -0400 Original-Received: from s70.gtokyofl21.vectant.ne.jp ([202.215.75.70]:60000 helo=localhost) by hampton.hostforweb.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1c1Vr5-002sdI-AN; Tue, 01 Nov 2016 04:59:44 -0500 X-Face: #kKnN,xUnmKia.'[pp`; Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu; B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( Cancel-Lock: sha1:eVqpKdXB1w736zFoAlVOIf3e97E= X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hampton.hostforweb.net X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Get-Message-Sender-Via: hampton.hostforweb.net: authenticated_id: yamaoka/from_h X-Authenticated-Sender: hampton.hostforweb.net: yamaoka@jpl.org X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:125202 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, 01 Nov 2016 10:39:12 +0900, Katsumi Yamaoka wrote: > I found the cause of the problem that shr does not display the > "Hi, you have a new email..." > statement contained in the example message. That is, the message > has a table in which the td element is omitted or lost. I tried fixing it. A patch is below. But I feel it somewhat awkward, so I hope Lars or someone will review it. My patch simply adds the missing td tag as follows: (table nil (tr nil contents)) =E2=86=93 (table nil (tr nil (td nil contents))) Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: inline --- shr.el~ 2016-11-01 02:35:57.788777000 +0000 +++ shr.el 2016-11-01 09:51:32.251984400 +0000 @@ -1759,6 +1759,7 @@ ;; we then render everything again with the new widths, and finally ;; insert all these boxes into the main buffer. (defun shr-tag-table-1 (dom) + (shr-add-missing-td dom) (setq dom (or (dom-child-by-tag dom 'tbody) dom)) (let* ((shr-inhibit-images t) (shr-table-depth (1+ shr-table-depth)) @@ -1787,6 +1788,19 @@ ;; Then render the table again with these new "hard" widths. (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths))) +(defun shr-add-missing-td (dom) + "Add missing td tag to table." + (let (tr td) + (dolist (elem (dom-children dom)) + (when (eq (car-safe elem) 'tr) + (setq tr elem + td nil + elem (cddr elem)) + (while (and (not td) elem) + (setq td (eq (car-safe (pop elem)) 'td))) + (unless td + (setcdr (cdr tr) (list (cons 'td (cons nil (cddr tr)))))))))) + (defun shr-table-body (dom) (let ((tbodies (seq-filter (lambda (child) (eq (dom-tag child) 'tbody)) --=-=-=--