Further shr vertical white space fixups
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 19 Mar 2012 21:34:35 +0000 (22:34 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 19 Mar 2012 21:34:35 +0000 (22:34 +0100)
(shr-tag-br): Allow <br> to end lines or to make a single blank line.
(shr-ensure-paragraph): Consider lines with white space to be blank.

lisp/ChangeLog
lisp/shr.el

index b35f080..cd294d6 100644 (file)
@@ -3,6 +3,8 @@
        * shr.el (shr-insert): Treat non-breaking space just like normal
        space.  This seems to produce more pleasing results.
        (shr-insert): Only insert a blank line if we're starting from an image.
+       (shr-tag-br): Allow <br> to end lines or to make a single blank line.
+       (shr-ensure-paragraph): Consider lines with white space to be blank.
 
 2012-03-15  Elias Pipping  <pipping@lavabit.com>
 
index 281a7b1..b0cbc1b 100644 (file)
@@ -501,7 +501,7 @@ size, and full-buffer size."
       (if (save-excursion
            (beginning-of-line)
            (looking-at " *$"))
-         (insert "\n")
+         (delete-region (match-beginning 0) (match-end 0))
        (insert "\n\n")))))
 
 (defun shr-indent ()
@@ -1044,7 +1044,12 @@ ones, in case fg and bg are nil."
     (shr-generic cont)))
 
 (defun shr-tag-br (cont)
-  (unless (bobp)
+  (when (and (not (bobp))
+            ;; Only add a newline if we break the current line, or
+            ;; the previous line isn't a blank line.
+            (or (not (bolp))
+                (and (> (- (point) 2) (point-min))
+                     (not (= (char-after (- (point) 2)) ?\n)))))
     (insert "\n")
     (shr-indent))
   (shr-generic cont))