unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: 24831@debbugs.gnu.org
Cc: jidanni@jidanni.org
Subject: bug#24831: shr mangling messages
Date: Tue, 01 Nov 2016 18:59:39 +0900	[thread overview]
Message-ID: <b4mins7zfjo.fsf@jpl.org> (raw)
In-Reply-To: <87shrd6xsp.fsf_-_@jidanni.org>

[-- Attachment #1: Type: text/plain, Size: 548 bytes --]

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))
	↓
(table nil (tr nil (td nil contents)))

Thanks.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1098 bytes --]

--- 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))

  reply	other threads:[~2016-11-01  9:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87shrgvt8y.fsf@jidanni.org>
2016-10-31  2:45 ` bug#24831: shr mangling messages 積丹尼 Dan Jacobson
2016-11-01  1:39   ` Katsumi Yamaoka
2016-11-01  9:59     ` Katsumi Yamaoka [this message]
2016-11-01 10:06       ` Lars Ingebrigtsen
2016-11-01 10:12         ` Lars Ingebrigtsen
2016-11-01 18:43         ` Lars Ingebrigtsen
2016-11-02  9:49           ` Katsumi Yamaoka
2016-11-04  7:19             ` Katsumi Yamaoka
2016-11-04  8:51               ` Lars Ingebrigtsen
2016-11-04 10:28                 ` Katsumi Yamaoka
2016-11-04 11:17                   ` Lars Ingebrigtsen
2016-11-06 23:32                     ` Katsumi Yamaoka
2016-11-01 11:22   ` 積丹尼 Dan Jacobson
2016-11-01 17:16     ` Richard Stallman
2016-11-04 18:18       ` Ted Zlatanov
2016-11-01 11:24   ` 積丹尼 Dan Jacobson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4mins7zfjo.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=24831@debbugs.gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).