emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master cdaf330 1/2: Allow several <tbody> tags in shr


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master cdaf330 1/2: Allow several <tbody> tags in shr
Date: Fri, 25 Dec 2015 05:04:09 +0000

branch: master
commit cdaf33029d6620073833876d76056045ecfbc7c4
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Allow several <tbody> tags in shr
    
    * shr.el (shr-table-body): New function to find the real body
    of a table.
    (shr-tag-table): Use it to render several <tbody> tags in a
    table (bug#22170).
---
 lisp/net/shr.el |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 2389952..0b1a4da 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1579,12 +1579,23 @@ The preference is a float determined from 
`shr-prefer-media-type'."
     ;; Then render the table again with these new "hard" widths.
     (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths)))
 
+(defun shr-table-body (dom)
+  (let ((tbodies (dom-by-tag dom 'tbody)))
+    (cond
+     ((null tbodies)
+      dom)
+     ((= (length tbodies) 1)
+      (car tbodies))
+     (t
+      ;; Table with multiple tbodies.  Convert into a single tbody.
+      `(tbody nil
+              ,@(reduce 'append (mapcar 'dom-non-text-children tbodies)))))))
+
 (defun shr-tag-table (dom)
   (shr-ensure-paragraph)
   (let* ((caption (dom-children (dom-child-by-tag dom 'caption)))
         (header (dom-non-text-children (dom-child-by-tag dom 'thead)))
-        (body (dom-non-text-children (or (dom-child-by-tag dom 'tbody)
-                                         dom)))
+        (body (dom-non-text-children (shr-table-body dom)))
         (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot)))
          (bgcolor (dom-attr dom 'bgcolor))
         (start (point))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]