aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2015-12-25 06:01:19 +0100
committerLars Ingebrigtsen2015-12-25 17:03:06 +0100
commit96ac31425d898d853a15763288d5e360a0f0430a (patch)
tree46094c8f8feb76b3f20adef1f07cd3cc65d1e33e
parenta7143faf482d9b30c120ff969b1a75f1de7f8017 (diff)
downloademacs-96ac31425d898d853a15763288d5e360a0f0430a.tar.gz
emacs-96ac31425d898d853a15763288d5e360a0f0430a.zip
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). Backport: (cherry picked from commit cdaf33029d6620073833876d76056045ecfbc7c4)
-rw-r--r--lisp/net/shr.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index d51b8c73d10..18eadcb0f91 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1572,12 +1572,23 @@ The preference is a float determined from `shr-prefer-media-type'."
1572 ;; Then render the table again with these new "hard" widths. 1572 ;; Then render the table again with these new "hard" widths.
1573 (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths))) 1573 (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths)))
1574 1574
1575(defun shr-table-body (dom)
1576 (let ((tbodies (dom-by-tag dom 'tbody)))
1577 (cond
1578 ((null tbodies)
1579 dom)
1580 ((= (length tbodies) 1)
1581 (car tbodies))
1582 (t
1583 ;; Table with multiple tbodies. Convert into a single tbody.
1584 `(tbody nil
1585 ,@(reduce 'append (mapcar 'dom-non-text-children tbodies)))))))
1586
1575(defun shr-tag-table (dom) 1587(defun shr-tag-table (dom)
1576 (shr-ensure-paragraph) 1588 (shr-ensure-paragraph)
1577 (let* ((caption (dom-children (dom-child-by-tag dom 'caption))) 1589 (let* ((caption (dom-children (dom-child-by-tag dom 'caption)))
1578 (header (dom-non-text-children (dom-child-by-tag dom 'thead))) 1590 (header (dom-non-text-children (dom-child-by-tag dom 'thead)))
1579 (body (dom-non-text-children (or (dom-child-by-tag dom 'tbody) 1591 (body (dom-non-text-children (shr-table-body dom)))
1580 dom)))
1581 (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot))) 1592 (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot)))
1582 (bgcolor (dom-attr dom 'bgcolor)) 1593 (bgcolor (dom-attr dom 'bgcolor))
1583 (start (point)) 1594 (start (point))