Fix nnir/gnus-sum mutually recursive requirements
[gnus] / lisp / shr.el
index ddf47f4..969d893 100644 (file)
@@ -1,6 +1,6 @@
 ;;; shr.el --- Simple HTML Renderer
 
-;; Copyright (C) 2010-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2012 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: html
@@ -53,17 +53,17 @@ fit these criteria."
   :group 'shr
   :type 'regexp)
 
-(defcustom shr-table-horizontal-line ? 
+(defcustom shr-table-horizontal-line ?\s
   "Character used to draw horizontal table lines."
   :group 'shr
   :type 'character)
 
-(defcustom shr-table-vertical-line ? 
+(defcustom shr-table-vertical-line ?\s
   "Character used to draw vertical table lines."
   :group 'shr
   :type 'character)
 
-(defcustom shr-table-corner ? 
+(defcustom shr-table-corner ?\s
   "Character used to draw table corners."
   :group 'shr
   :type 'character)
@@ -134,7 +134,8 @@ cid: URL as the argument.")
   (shr-insert-document
    (with-temp-buffer
      (insert-file-contents file)
-     (libxml-parse-html-region (point-min) (point-max)))))
+     (libxml-parse-html-region (point-min) (point-max))))
+  (goto-char (point-min)))
 
 ;;;###autoload
 (defun shr-insert-document (dom)
@@ -534,33 +535,33 @@ the URL of the image to the kill buffer instead."
     (insert alt)))
 
 (defun shr-rescale-image (data)
-  (if (or (not (fboundp 'imagemagick-types))
-         (not (get-buffer-window (current-buffer))))
-      (create-image data nil t
-                   :ascent 100)
-    (let* ((image (create-image data nil t :ascent 100))
-          (size (image-size image t))
-          (width (car size))
-          (height (cdr size))
-          (edges (window-inside-pixel-edges
-                  (get-buffer-window (current-buffer))))
-          (window-width (truncate (* shr-max-image-proportion
-                                     (- (nth 2 edges) (nth 0 edges)))))
-          (window-height (truncate (* shr-max-image-proportion
-                                      (- (nth 3 edges) (nth 1 edges)))))
-          scaled-image)
-      (when (> height window-height)
-       (setq image (or (create-image data 'imagemagick t
-                                     :height window-height)
-                       image))
-       (setq size (image-size image t)))
-      (when (> (car size) window-width)
-       (setq image (or
-                    (create-image data 'imagemagick t
-                                  :width window-width
-                                  :ascent 100)
-                    image)))
-      image)))
+  (let ((image (create-image data nil t :ascent 100)))
+    (if (or (not (fboundp 'imagemagick-types))
+           (not (get-buffer-window (current-buffer))))
+       image
+      (let* ((size (image-size image t))
+            (width (car size))
+            (height (cdr size))
+            (edges (window-inside-pixel-edges
+                    (get-buffer-window (current-buffer))))
+            (window-width (truncate (* shr-max-image-proportion
+                                       (- (nth 2 edges) (nth 0 edges)))))
+            (window-height (truncate (* shr-max-image-proportion
+                                        (- (nth 3 edges) (nth 1 edges)))))
+            scaled-image)
+       (when (> height window-height)
+         (setq image (or (create-image data 'imagemagick t
+                                       :height window-height
+                                       :ascent 100)
+                         image))
+         (setq size (image-size image t)))
+       (when (> (car size) window-width)
+         (setq image (or
+                      (create-image data 'imagemagick t
+                                    :width window-width
+                                    :ascent 100)
+                      image)))
+       image))))
 
 ;; url-cache-extract autoloads url-cache.
 (declare-function url-cache-create-filename "url-cache" (url))
@@ -583,7 +584,7 @@ Return a string with image data."
   "Return a function to display an image.
 CONTENT-FUNCTION is a function to retrieve an image for a cid url that
 is an argument.  The function to be returned takes three arguments URL,
-START, and END.  Note that START and END should be merkers."
+START, and END.  Note that START and END should be markers."
   `(lambda (url start end)
      (when url
        (if (string-match "\\`cid:" url)
@@ -914,12 +915,13 @@ ones, in case fg and bg are nil."
           (shr-encode-url url) 'shr-image-fetched
           (list (current-buffer) start (set-marker (make-marker) (1- (point))))
           t)))
-       (put-text-property start (point) 'keymap shr-map)
-       (put-text-property start (point) 'shr-alt alt)
-       (put-text-property start (point) 'image-url url)
-       (put-text-property start (point) 'image-displayer
-                          (shr-image-displayer shr-content-function))
-       (put-text-property start (point) 'help-echo alt)
+       (when (zerop shr-table-depth) ;; We are not in a table.
+         (put-text-property start (point) 'keymap shr-map)
+         (put-text-property start (point) 'shr-alt alt)
+         (put-text-property start (point) 'image-url url)
+         (put-text-property start (point) 'image-displayer
+                            (shr-image-displayer shr-content-function))
+         (put-text-property start (point) 'help-echo alt))
        (setq shr-state 'image)))))
 
 (defun shr-tag-pre (cont)