emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 52ba24b: Fix <p> and <div> newlines with or witho


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] emacs-25 52ba24b: Fix <p> and <div> newlines with or without <li> in shr
Date: Sun, 20 Mar 2016 12:50:37 +0000

branch: emacs-25
commit 52ba24bdd913f6be8318c34b281c7ad727dee6ad
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>

    Fix <p> and <div> newlines with or without <li> in shr
    
    * lisp/net/shr.el (shr-ensure-newline): Respect that we're in
    a <li>, if we are, and don't insert newlines there.
    (shr-ensure-paragraph): When mixing newlines and paragraph
    ensurements, don't insert too many blank lines.
    (shr-tag-div): A <div> shouldn't introduce a paragraph, but a
    new line.
    (cherry picked from commit 292921facaff2f02ac4e8602c1f7ecbdcfe7ef45)
    
    Backport:
---
 lisp/net/shr.el |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index e943132..900b8ec 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -783,8 +783,13 @@ size, and full-buffer size."
         (url-expand-file-name url (concat (car base) (cadr base))))))
 
 (defun shr-ensure-newline ()
-  (unless (zerop (current-column))
-    (insert "\n")))
+  (unless (bobp)
+    (let ((prefix (get-text-property (line-beginning-position)
+                                    'shr-prefix-length)))
+      (unless (or (zerop (current-column))
+                  (and prefix
+                       (= prefix (- (point) (line-beginning-position)))))
+        (insert "\n")))))
 
 (defun shr-ensure-paragraph ()
   (unless (bobp)
@@ -812,6 +817,10 @@ size, and full-buffer size."
                                                    (line-end-position))
                       (line-end-position)))))
        (delete-region (match-beginning 0) (match-end 0)))
+       ;; We have a single blank line.
+       ((and (eolp) (bolp))
+        (insert "\n"))
+       ;; Insert new paragraph.
        (t
        (insert "\n\n"))))))
 
@@ -1206,7 +1215,7 @@ ones, in case fg and bg are nil."
   (shr-ensure-paragraph))
 
 (defun shr-tag-div (dom)
-  (shr-ensure-paragraph)
+  (shr-ensure-newline)
   (shr-generic dom)
   (shr-ensure-newline))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]