From: Lars Ingebrigtsen Date: Fri, 17 Jul 2020 01:13:05 +0000 (+0200) Subject: Fix problems with not rendering shr tables with rowspan X-Git-Tag: emacs-28.0.90~6995 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=510da73b4a0ff77d27a208a4177ef21fcdbf766d;p=emacs.git Fix problems with not rendering shr tables with rowspan * lisp/net/shr.el (shr-max-columns): When rowspans were in effect, columns would go missing from subsequent lines (bug#42194). --- diff --git a/lisp/net/shr.el b/lisp/net/shr.el index a3f04968a27..1ba615f92a8 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -2576,12 +2576,29 @@ flags that control whether to collect or render objects." i)) (defun shr-max-columns (dom) - (let ((max 0)) + (let ((max 0) + (this 0) + (rowspans nil)) (dolist (row (dom-children dom)) (when (and (not (stringp row)) (eq (dom-tag row) 'tr)) - (setq max (max max (+ (shr-count row 'td) - (shr-count row 'th)))))) + (setq this 0) + (dolist (column (dom-children row)) + (when (and (not (stringp column)) + (or (eq (dom-tag column) 'td) + (eq (dom-tag column) 'th))) + (setq this (+ (1+ this) (length rowspans))) + ;; We have a rowspan, which we emulate later in rendering + ;; by adding an extra column to the following rows. + (when-let* ((span (dom-attr column 'rowspan))) + (push (string-to-number span) rowspans)))) + (setq max (max max this))) + ;; Count down the rowspans in effect. + (let ((new nil)) + (dolist (span rowspans) + (when (> span 1) + (push (1- span) new))) + (setq rowspans new))) max)) (provide 'shr)