Use bg/gfcolor specs on tables.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 7 Dec 2010 16:25:17 +0000 (17:25 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Tue, 7 Dec 2010 16:25:17 +0000 (17:25 +0100)
lisp/ChangeLog
lisp/shr.el

index aabbca9..3b9dfc8 100644 (file)
@@ -1,3 +1,7 @@
+2010-12-07  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
+
 2010-12-07  Andrew Cohen  <cohen@andy.bu.edu>
 
        * nnir.el (nnir-run-gmane): Restore sub-optimal test for gmane server.
index 4f3af11..7d06ffb 100644 (file)
@@ -589,7 +589,8 @@ ones, in case fg and bg are nil."
   (when (or fg bg)
     (let ((new-colors (shr-color-check fg bg)))
       (when new-colors
-       (shr-put-color start end :foreground (cadr new-colors))
+       (when fg
+         (shr-put-color start end :foreground (cadr new-colors)))
        (when bg
          (shr-put-color start end :background (car new-colors)))))))
 
@@ -896,6 +897,9 @@ ones, in case fg and bg are nil."
         (body (or (cdr (assq 'tbody cont)) cont))
         (footer (cdr (assq 'tfoot cont)))
          (bgcolor (cdr (assq :bgcolor cont)))
+        (start (point))
+        (shr-stylesheet (nconc (list (cons 'color bgcolor)
+                                     shr-stylesheet)))
         (nheader (if header (shr-max-columns header)))
         (nbody (if body (shr-max-columns body)))
         (nfooter (if footer (shr-max-columns footer))))
@@ -936,7 +940,11 @@ ones, in case fg and bg are nil."
                       `((tr (td (table (tbody ,@footer))))))))
          (if caption
              `((tr (td (table (tbody ,@body)))))
-           body)))))))
+           body)))))
+    (when bgcolor
+      (shr-colorize-region start (point)
+                          nil
+                          bgcolor))))
 
 (defun shr-find-elements (cont type)
   (let (result)
@@ -1042,43 +1050,54 @@ ones, in case fg and bg are nil."
 
 (defun shr-render-td (cont width fill)
   (with-temp-buffer
-    (let ((cache (cdr (assoc (cons width cont) shr-content-cache))))
-      (if cache
-         (insert cache)
-       (let ((shr-width width)
-             (shr-indentation 0))
-         (shr-descend (cons 'td cont)))
-       (delete-region
-        (point)
-        (+ (point)
-           (skip-chars-backward " \t\n")))
-       (push (cons (cons width cont) (buffer-string))
-             shr-content-cache)))
-    (goto-char (point-min))
-    (let ((max 0))
-      (while (not (eobp))
-       (end-of-line)
-       (setq max (max max (current-column)))
-       (forward-line 1))
-      (when fill
-       (goto-char (point-min))
-       ;; If the buffer is totally empty, then put a single blank
-       ;; line here.
-       (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))))
-      (if fill
+    (let ((bgcolor (cdr (assq :bgcolor cont)))
+         (fgcolor (cdr (assq :fgcolor cont)))
+         (shr-stylesheet shr-stylesheet))
+      (when bgcolor
+       (setq shr-stylesheet (nconc (list 'background-color bgcolor)
+                                   shr-stylesheet)))
+      (when fgcolor
+       (setq shr-stylesheet (nconc (list 'background-color fgcolor)
+                                   shr-stylesheet)))
+      (let ((cache (cdr (assoc (cons width cont) shr-content-cache))))
+       (if cache
+           (insert cache)
+         (let ((shr-width width)
+               (shr-indentation 0))
+           (shr-descend (cons 'td cont)))
+         (delete-region
+          (point)
+          (+ (point)
+             (skip-chars-backward " \t\n")))
+         (push (cons (cons width cont) (buffer-string))
+               shr-content-cache)))
+      (goto-char (point-min))
+      (let ((max 0))
+       (while (not (eobp))
+         (end-of-line)
+         (setq max (max max (current-column)))
+         (forward-line 1))
+       (when fill
+         (goto-char (point-min))
+         ;; If the buffer is totally empty, then put a single blank
+         ;; line here.
+         (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))))
+       (when (or bgcolor fgcolor)
+         (shr-colorize-region (point-min) (point-max) fgcolor bgcolor))
+       (if fill
+           (list max
+                 (count-lines (point-min) (point-max))
+                 (split-string (buffer-string) "\n")
+                 (shr-collect-overlays))
          (list max
-               (count-lines (point-min) (point-max))
-               (split-string (buffer-string) "\n")
-               (shr-collect-overlays))
-       (list max
-             (shr-natural-width))))))
+               (shr-natural-width)))))))
 
 (defun shr-natural-width ()
   (goto-char (point-min))