diff options
| author | Lars Ingebrigtsen | 2015-12-25 06:01:19 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2015-12-25 06:01:19 +0100 |
| commit | cdaf33029d6620073833876d76056045ecfbc7c4 (patch) | |
| tree | 7a0dfe3c86ce9f1af65d373e371fe8b89a599784 | |
| parent | edfdd0a6cbdfa9e5e4bd0553e2b489401ca39266 (diff) | |
| download | emacs-cdaf33029d6620073833876d76056045ecfbc7c4.tar.gz emacs-cdaf33029d6620073833876d76056045ecfbc7c4.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).
| -rw-r--r-- | 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 23899521140..0b1a4dac6a4 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'." | |||
| 1579 | ;; Then render the table again with these new "hard" widths. | 1579 | ;; Then render the table again with these new "hard" widths. |
| 1580 | (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths))) | 1580 | (shr-insert-table (shr-make-table dom sketch-widths t) sketch-widths))) |
| 1581 | 1581 | ||
| 1582 | (defun shr-table-body (dom) | ||
| 1583 | (let ((tbodies (dom-by-tag dom 'tbody))) | ||
| 1584 | (cond | ||
| 1585 | ((null tbodies) | ||
| 1586 | dom) | ||
| 1587 | ((= (length tbodies) 1) | ||
| 1588 | (car tbodies)) | ||
| 1589 | (t | ||
| 1590 | ;; Table with multiple tbodies. Convert into a single tbody. | ||
| 1591 | `(tbody nil | ||
| 1592 | ,@(reduce 'append (mapcar 'dom-non-text-children tbodies))))))) | ||
| 1593 | |||
| 1582 | (defun shr-tag-table (dom) | 1594 | (defun shr-tag-table (dom) |
| 1583 | (shr-ensure-paragraph) | 1595 | (shr-ensure-paragraph) |
| 1584 | (let* ((caption (dom-children (dom-child-by-tag dom 'caption))) | 1596 | (let* ((caption (dom-children (dom-child-by-tag dom 'caption))) |
| 1585 | (header (dom-non-text-children (dom-child-by-tag dom 'thead))) | 1597 | (header (dom-non-text-children (dom-child-by-tag dom 'thead))) |
| 1586 | (body (dom-non-text-children (or (dom-child-by-tag dom 'tbody) | 1598 | (body (dom-non-text-children (shr-table-body dom))) |
| 1587 | dom))) | ||
| 1588 | (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot))) | 1599 | (footer (dom-non-text-children (dom-child-by-tag dom 'tfoot))) |
| 1589 | (bgcolor (dom-attr dom 'bgcolor)) | 1600 | (bgcolor (dom-attr dom 'bgcolor)) |
| 1590 | (start (point)) | 1601 | (start (point)) |