aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-09-30 07:27:46 +0200
committerLars Ingebrigtsen2019-09-30 07:27:46 +0200
commit542b78eddeba3f020349c2d02ba2d21e8613d99d (patch)
treed76db4d2ef4395e66ba437b30ff98c4bec218233
parent9f9dca57c60033e6f3248f1492178fed57f3b552 (diff)
downloademacs-542b78eddeba3f020349c2d02ba2d21e8613d99d.tar.gz
emacs-542b78eddeba3f020349c2d02ba2d21e8613d99d.zip
Fix rendering of degenerate tables some more in shr.el
* lisp/net/shr.el (shr--fix-tbody): New function (bug#31665). (shr--fix-table): Use it to fix the <table><tbody>foo</tbody></table> case.
-rw-r--r--lisp/net/shr.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 64263903bdf..dc3cc38c798 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1993,8 +1993,16 @@ BASE is the URL of the HTML being rendered."
1993 `(tbody nil ,@(cl-reduce 'append 1993 `(tbody nil ,@(cl-reduce 'append
1994 (mapcar 'dom-non-text-children tbodies))))))) 1994 (mapcar 'dom-non-text-children tbodies)))))))
1995 1995
1996(defun shr--fix-tbody (tbody)
1997 (nconc (list 'tbody (dom-attributes tbody))
1998 (cl-loop for child in (dom-children tbody)
1999 collect (if (or (stringp child)
2000 (not (eq (dom-tag child) 'tr)))
2001 (list 'tr nil (list 'td nil child))
2002 child))))
2003
1996(defun shr--fix-table (dom caption header footer) 2004(defun shr--fix-table (dom caption header footer)
1997 (let* ((body (dom-non-text-children (shr-table-body dom))) 2005 (let* ((body (dom-non-text-children (shr--fix-tbody (shr-table-body dom))))
1998 (nheader (if header (shr-max-columns header))) 2006 (nheader (if header (shr-max-columns header)))
1999 (nbody (if body (shr-max-columns body) 0)) 2007 (nbody (if body (shr-max-columns body) 0))
2000 (nfooter (if footer (shr-max-columns footer)))) 2008 (nfooter (if footer (shr-max-columns footer))))