emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] shr-fontified 217e202 5/9: Further colspan fixes


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] shr-fontified 217e202 5/9: Further colspan fixes
Date: Mon, 09 Feb 2015 10:39:09 +0000

branch: shr-fontified
commit 217e2024a21240c9c8ff2d3058eb87ca54f306dc
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>

    Further colspan fixes
    
    (shr-insert-table): Get colspan pro-rating right by distributing
    the zero-length columns in the right place.
---
 lisp/ChangeLog  |    2 +
 lisp/net/shr.el |   97 ++++++++++++++++++++++++++++--------------------------
 2 files changed, 52 insertions(+), 47 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 71d1223..cec4409 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -5,6 +5,8 @@
        (shr-pixel-region): New function.
        (shr-fold-lines): Don't re-fold sections that didn't need to be
        folded.
+       (shr-insert-table): Get colspan pro-rating right by distributing
+       the zero-length columns in the right place.
 
 2015-02-08  Lars Ingebrigtsen  <address@hidden>
 
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index eb3df1f..190fdc6 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1644,44 +1644,45 @@ The preference is a float determined from 
`shr-prefer-media-type'."
          (shr-indent)
          (insert shr-table-vertical-line "\n"))
        (dolist (column row)
-         (goto-char start)
-         ;; Sum up all the widths from the column.  (There may be
-         ;; more than one if this is a "colspan" column.)
-         (dotimes (i (nth 4 column))
-           ;; The colspan directive may be wrong and there may not be
-           ;; that number of columns.
-           (when (<= column-number (1- (length widths)))
-             (setq align (+ align
-                            (aref widths column-number)
-                            (* 2 shr-table-separator-pixel-width))))
-           (setq column-number (1+ column-number)))
-         (let ((lines (nth 3 column))
-               (pixel-align (if (not shr-use-fonts)
-                                (* align (frame-char-width))
-                              align)))
-           (dolist (line lines)
-             (end-of-line)
-             (let ((start (point)))
-               (insert line
-                       (propertize " "
-                                   'display `(space :align-to (,pixel-align))
-                                   'shr-table-indent shr-table-id)
-                       shr-table-vertical-line)
-               (shr-colorize-region
-                start (1- (point)) (nth 5 column) (nth 6 column)))
-             (forward-line 1))
-           ;; Add blank lines at padding at the bottom of the TD,
-           ;; possibly.
-           (dotimes (i (- height (length lines)))
-             (end-of-line)
-             (let ((start (point)))
-               (insert (propertize " "
-                                   'display `(space :align-to (,pixel-align))
-                                   'shr-table-indent shr-table-id)
-                       shr-table-vertical-line)
-               (shr-colorize-region
-                start (1- (point)) (nth 5 column) (nth 6 column)))
-             (forward-line 1)))))
+         (when (> (nth 2 column) -1)
+           (goto-char start)
+           ;; Sum up all the widths from the column.  (There may be
+           ;; more than one if this is a "colspan" column.)
+           (dotimes (i (nth 4 column))
+             ;; The colspan directive may be wrong and there may not be
+             ;; that number of columns.
+             (when (<= column-number (1- (length widths)))
+               (setq align (+ align
+                              (aref widths column-number)
+                              (* 2 shr-table-separator-pixel-width))))
+             (setq column-number (1+ column-number)))
+           (let ((lines (nth 3 column))
+                 (pixel-align (if (not shr-use-fonts)
+                                  (* align (frame-char-width))
+                                align)))
+             (dolist (line lines)
+               (end-of-line)
+               (let ((start (point)))
+                 (insert line
+                         (propertize " "
+                                     'display `(space :align-to (,pixel-align))
+                                     'shr-table-indent shr-table-id)
+                         shr-table-vertical-line)
+                 (shr-colorize-region
+                  start (1- (point)) (nth 5 column) (nth 6 column)))
+               (forward-line 1))
+             ;; Add blank lines at padding at the bottom of the TD,
+             ;; possibly.
+             (dotimes (i (- height (length lines)))
+               (end-of-line)
+               (let ((start (point)))
+                 (insert (propertize " "
+                                     'display `(space :align-to (,pixel-align))
+                                     'shr-table-indent shr-table-id)
+                         shr-table-vertical-line)
+                 (shr-colorize-region
+                  start (1- (point)) (nth 5 column) (nth 6 column)))
+               (forward-line 1))))))
       (unless collapse
        (shr-insert-table-ruler widths)))
     (if (equal (buffer-name) "*eww*")
@@ -1831,24 +1832,26 @@ The preference is a float determined from 
`shr-prefer-media-type'."
                (setq width-column (+ width-column (1- colspan))
                      colspan-count colspan
                      colspan-remaining colspan))
-             (when (or column
-                       (not fill))
-               (let ((data (if (not column)
-                               (if fill
-                                   (list 0 0 nil 1 nil nil)
-                                 '(0 0))
-                             (shr-render-td column width fill))))
+             (when column
+               (let ((data (shr-render-td column width fill)))
                  (if (and (not fill)
                           (> colspan-remaining 0))
                      (progn
-                       (when (= colspan-count colspan-remaining)
-                         (setq colspan-width (car data)))
+                       (setq colspan-width (car data))
                        (let ((this-width (/ colspan-width colspan-count)))
                          (push (cons this-width (cadr data)) tds)
                          (setq colspan-remaining (1- colspan-remaining))))
                    (if (not fill)
                        (push (cons (car data) (cadr data)) tds)
                      (push data tds)))))
+             (when (and colspan
+                        (> colspan 1))
+               (dotimes (c (1- colspan))
+                 (push
+                  (if fill
+                      (list 0 0 -1 nil 1 nil nil)
+                    '(0 . 0))
+                  tds)))
              (setq i (1+ i)
                    width-column (1+ width-column))))
          (push (nreverse tds) trs))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]