[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 542b78e 2/2: Fix rendering of degenerate tables som
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 542b78e 2/2: Fix rendering of degenerate tables some more in shr.el |
Date: |
Mon, 30 Sep 2019 01:27:53 -0400 (EDT) |
branch: master
commit 542b78eddeba3f020349c2d02ba2d21e8613d99d
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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.
---
lisp/net/shr.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 6426390..dc3cc38 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1993,8 +1993,16 @@ BASE is the URL of the HTML being rendered."
`(tbody nil ,@(cl-reduce 'append
(mapcar 'dom-non-text-children tbodies)))))))
+(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)))
+ (list 'tr nil (list 'td nil child))
+ child))))
+
(defun shr--fix-table (dom caption header footer)
- (let* ((body (dom-non-text-children (shr-table-body dom)))
+ (let* ((body (dom-non-text-children (shr--fix-tbody (shr-table-body dom))))
(nheader (if header (shr-max-columns header)))
(nbody (if body (shr-max-columns body) 0))
(nfooter (if footer (shr-max-columns footer))))