From 80f5224e3cabb33c5244a34a1caaf0a66e3db10d Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 17 Jun 2013 12:20:30 +0200 Subject: [PATCH] * shr.el (shr-render-td): Support horizontal alignment. --- lisp/ChangeLog | 2 ++ lisp/shr.el | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cb643dbee..951b0623f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,7 @@ 2013-06-17 Lars Magne Ingebrigtsen + * shr.el (shr-render-td): Support horizontal alignment. + * eww.el (eww-put-color): Removed. (eww-colorize-region): Use `add-face-text-property'. diff --git a/lisp/shr.el b/lisp/shr.el index e7169c5a7..d3b9a362a 100644 --- a/lisp/shr.el +++ b/lisp/shr.el @@ -1449,11 +1449,23 @@ ones, in case fg and bg are nil." (if (zerop (buffer-size)) (insert (make-string width ? )) ;; Otherwise, fill the buffer. - (while (not (eobp)) - (end-of-line) - (when (> (- width (current-column)) 0) - (insert (make-string (- width (current-column)) ? ))) - (forward-line 1))) + (let ((align (cdr (assq :align cont))) + length) + (while (not (eobp)) + (end-of-line) + (setq length (- width (current-column))) + (when (> length 0) + (cond + ((equal align "right") + (beginning-of-line) + (insert (make-string length ? ))) + ((equal align "center") + (insert (make-string (/ length 2) ? )) + (beginning-of-line) + (insert (make-string (- length (/ length 2)) ? ))) + (t + (insert (make-string length ? ))))) + (forward-line 1)))) (when style (setq actual-colors (shr-colorize-region -- 2.25.1