changeset 110756:9070b77b4a28

shr.el (shr-insert): Tweak line breaking. shr.el (shr-insert): Handle <pre> better.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 04 Oct 2010 10:43:14 +0000
parents 5c603f558199
children d3001fd75795
files lisp/gnus/ChangeLog lisp/gnus/shr.el
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/gnus/ChangeLog	Mon Oct 04 10:16:57 2010 +0000
+++ b/lisp/gnus/ChangeLog	Mon Oct 04 10:43:14 2010 +0000
@@ -1,6 +1,8 @@
 2010-10-04  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 	* shr.el (shr-ensure-paragraph): Fix the non-empty line case.
+	(shr-insert): Tweak line breaking.
+	(shr-insert): Handle <pre> better.
 
 2010-10-04  Julien Danjou  <julien@danjou.info>
 
--- a/lisp/gnus/shr.el	Mon Oct 04 10:16:57 2010 +0000
+++ b/lisp/gnus/shr.el	Mon Oct 04 10:43:14 2010 +0000
@@ -214,14 +214,14 @@
       image)))
 
 (defun shr-tag-pre (cont)
-  (let ((shr-folding-mode nil))
+  (let ((shr-folding-mode 'none))
     (shr-ensure-newline)
     (shr-generic cont)
     (shr-ensure-newline)))
 
 (defun shr-tag-blockquote (cont)
   (let ((shr-indentation (+ shr-indentation 4)))
-    (shr-tag-pre cont)))
+    (shr-generic cont)))
 
 (defun shr-ensure-newline ()
   (unless (zerop (current-column))
@@ -233,7 +233,7 @@
     (setq shr-state nil))
   (cond
    ((eq shr-folding-mode 'none)
-    (insert t))
+    (insert text))
    (t
     (let ((first t)
 	  column)
@@ -244,7 +244,9 @@
 	(setq column (current-column))
 	(when (> column 0)
 	  (cond
-	   ((> (+ column (length elem) 1) shr-width)
+	   ((and (or (not first)
+		     (eq shr-state 'space))
+		 (> (+ column (length elem) 1) shr-width))
 	    (insert "\n"))
 	   ((not first)
 	    (insert " "))))
@@ -258,9 +260,11 @@
 	(unless shr-start
 	  (setq shr-start (point)))
 	(insert elem))
+      (setq shr-state nil)
       (when (and (string-match "[ \t\n]\\'" text)
 		 (not (bolp)))
-	(insert " "))))))
+	(insert " ")
+	(setq shr-state 'space))))))
 
 (defun shr-get-image-data (url)
   "Get image data for URL.
@@ -293,7 +297,8 @@
   (shr-generic cont))
 
 (defun shr-tag-br (cont)
-  (shr-ensure-newline)
+  (unless (bobp)
+    (insert "\n"))
   (shr-generic cont))
 
 (defun shr-tag-h1 (cont)