From 2122cb6dd2e1323963ebb2340078fc9f22e245e7 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Wed, 7 Aug 2013 00:05:33 +0200 Subject: [PATCH] Further shr width computation fixes (shr-make-table-1): Redo last change to fix the real problem in colspan handling. --- lisp/ChangeLog | 2 ++ lisp/net/shr.el | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 381ded5e697..666fab55bf4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -4,6 +4,8 @@ (shr-render-td): Make width computation consistent by defaulting all zero-width columns to 10 characters. This may not be optimal, but it's at least consistent. + (shr-make-table-1): Redo last change to fix the real problem in + colspan handling. 2013-08-06 Dmitry Antipov diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 281ad3630a4..7eda2554e06 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1488,7 +1488,11 @@ ones, in case fg and bg are nil." 10)) (when (and fill (setq colspan (cdr (assq :colspan (cdr column))))) - (setq colspan (string-to-number colspan)) + (setq colspan (min (string-to-number colspan) + ;; The colspan may be wrong, so + ;; truncate it to the length of the + ;; remaining columns. + (- (length widths) i))) (dotimes (j (1- colspan)) (if (> (+ i 1 j) (1- (length widths))) (setq width (aref widths (1- (length widths)))) @@ -1496,9 +1500,6 @@ ones, in case fg and bg are nil." shr-table-separator-length (aref widths (+ i 1 j)))))) (setq width-column (+ width-column (1- colspan)))) - ;; Sanity check for degenerate tables. - (when (zerop width) - (setq width 10)) (when (or column (not fill)) (push (shr-render-td (cdr column) width fill) @@ -1576,7 +1577,7 @@ ones, in case fg and bg are nil." (split-string (buffer-string) "\n") nil (car actual-colors)) - (max max 10)))))) + max))))) (defun shr-buffer-width () (goto-char (point-min)) -- 2.39.2