aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2016-03-20 13:43:42 +0100
committerLars Magne Ingebrigtsen2016-03-20 13:45:09 +0100
commit52ba24bdd913f6be8318c34b281c7ad727dee6ad (patch)
tree147299c1b2315319481b2eb06990dac8f8702352
parentb8ea08b037fb16395b90481162587706e71b487c (diff)
downloademacs-52ba24bdd913f6be8318c34b281c7ad727dee6ad.tar.gz
emacs-52ba24bdd913f6be8318c34b281c7ad727dee6ad.zip
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:
-rw-r--r--lisp/net/shr.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index e9431325333..900b8ec3f5c 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -783,8 +783,13 @@ size, and full-buffer size."
783 (url-expand-file-name url (concat (car base) (cadr base)))))) 783 (url-expand-file-name url (concat (car base) (cadr base))))))
784 784
785(defun shr-ensure-newline () 785(defun shr-ensure-newline ()
786 (unless (zerop (current-column)) 786 (unless (bobp)
787 (insert "\n"))) 787 (let ((prefix (get-text-property (line-beginning-position)
788 'shr-prefix-length)))
789 (unless (or (zerop (current-column))
790 (and prefix
791 (= prefix (- (point) (line-beginning-position)))))
792 (insert "\n")))))
788 793
789(defun shr-ensure-paragraph () 794(defun shr-ensure-paragraph ()
790 (unless (bobp) 795 (unless (bobp)
@@ -812,6 +817,10 @@ size, and full-buffer size."
812 (line-end-position)) 817 (line-end-position))
813 (line-end-position))))) 818 (line-end-position)))))
814 (delete-region (match-beginning 0) (match-end 0))) 819 (delete-region (match-beginning 0) (match-end 0)))
820 ;; We have a single blank line.
821 ((and (eolp) (bolp))
822 (insert "\n"))
823 ;; Insert new paragraph.
815 (t 824 (t
816 (insert "\n\n")))))) 825 (insert "\n\n"))))))
817 826
@@ -1206,7 +1215,7 @@ ones, in case fg and bg are nil."
1206 (shr-ensure-paragraph)) 1215 (shr-ensure-paragraph))
1207 1216
1208(defun shr-tag-div (dom) 1217(defun shr-tag-div (dom)
1209 (shr-ensure-paragraph) 1218 (shr-ensure-newline)
1210 (shr-generic dom) 1219 (shr-generic dom)
1211 (shr-ensure-newline)) 1220 (shr-ensure-newline))
1212 1221