Fix formatting of tables with thead/tfoot but no tbody
Correctly handle formatting of tables containing thead and/or tfoot, but without any tbody, to prevent including thead/tfoot content twice within the table's derived body. * lisp/net/shr.el (shr--fix-tbody): Omit 'thead' and 'tfoot' from implicit body. (Bug#71685) * test/lisp/net/shr-resources/table.html: * test/lisp/net/shr-resources/table.txt: New tests for table rendering.
This commit is contained in:
parent
83234cc1db
commit
9625e4af99
3 changed files with 15 additions and 2 deletions
|
@ -2261,8 +2261,9 @@ See `outline-search-function' for BOUND, MOVE, BACKWARD and LOOKING-AT."
|
|||
(defun shr--fix-tbody (tbody)
|
||||
(nconc (list 'tbody (dom-attributes tbody))
|
||||
(cl-loop for child in (dom-children tbody)
|
||||
collect (if (or (stringp child)
|
||||
(not (eq (dom-tag child) 'tr)))
|
||||
for tag = (and (not (stringp child)) (dom-tag child))
|
||||
unless (or (eq tag 'thead) (eq tag 'tfoot))
|
||||
collect (if (not (eq tag 'tr))
|
||||
(list 'tr nil (list 'td nil child))
|
||||
child))))
|
||||
|
||||
|
|
7
test/lisp/net/shr-resources/table.html
Normal file
7
test/lisp/net/shr-resources/table.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
<table>
|
||||
<thead><tr><th>A</th><th>B</th></tr></thead>
|
||||
<tr><td>1</td><td>2</td></tr>
|
||||
<tr><td>3</td><td>4</td></tr>
|
||||
5678
|
||||
<tfoot><tr><th>A</th><th>B</th></tr></tfoot>
|
||||
</table>
|
5
test/lisp/net/shr-resources/table.txt
Normal file
5
test/lisp/net/shr-resources/table.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
A B
|
||||
1 2
|
||||
3 4
|
||||
5678
|
||||
A B
|
Loading…
Add table
Reference in a new issue