[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))))
- [Emacs-diffs] shr-fontified updated (70199c1 -> 35d95a2), Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 1376a51 2/9: shr/Gnus face fixup and <li> rendering fix, Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified fe9660e 1/9: Rework the indentation to work more generally, Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified b0e3d92 3/9: (shr-fold-line): Handle lines that end with a space at the fill point., Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 217e202 5/9: Further colspan fixes,
Lars Ingebrigtsen <=
- [Emacs-diffs] shr-fontified 659202a 6/9: Fix up last change to really get colspans right, Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 8180e53 7/9: (shr-fold-line): Keep breaking unbreakable text., Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 1d5d72e 4/9: shr filling fix-ups, Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 25f55f7 8/9: Don't infloop on unbreakable, indented lines, Lars Ingebrigtsen, 2015/02/09
- [Emacs-diffs] shr-fontified 35d95a2 9/9: (shr-insert-table): Expand table alignments in any buffer at the end., Lars Ingebrigtsen, 2015/02/09