diff options
| author | Lars Magne Ingebrigtsen | 2016-03-20 13:43:42 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2016-03-20 13:43:42 +0100 |
| commit | 292921facaff2f02ac4e8602c1f7ecbdcfe7ef45 (patch) | |
| tree | df5c8b113992692374c9335f6422340cc6c10acd | |
| parent | 21c89971c31d8f5c14814d2a18749495ed191d8f (diff) | |
| download | emacs-292921facaff2f02ac4e8602c1f7ecbdcfe7ef45.tar.gz emacs-292921facaff2f02ac4e8602c1f7ecbdcfe7ef45.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.
| -rw-r--r-- | 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 0a7ea14b252..eae50a71438 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -805,8 +805,13 @@ size, and full-buffer size." | |||
| 805 | (url-expand-file-name url (concat (car base) (cadr base)))))) | 805 | (url-expand-file-name url (concat (car base) (cadr base)))))) |
| 806 | 806 | ||
| 807 | (defun shr-ensure-newline () | 807 | (defun shr-ensure-newline () |
| 808 | (unless (zerop (current-column)) | 808 | (unless (bobp) |
| 809 | (insert "\n"))) | 809 | (let ((prefix (get-text-property (line-beginning-position) |
| 810 | 'shr-prefix-length))) | ||
| 811 | (unless (or (zerop (current-column)) | ||
| 812 | (and prefix | ||
| 813 | (= prefix (- (point) (line-beginning-position))))) | ||
| 814 | (insert "\n"))))) | ||
| 810 | 815 | ||
| 811 | (defun shr-ensure-paragraph () | 816 | (defun shr-ensure-paragraph () |
| 812 | (unless (bobp) | 817 | (unless (bobp) |
| @@ -834,6 +839,10 @@ size, and full-buffer size." | |||
| 834 | (line-end-position)) | 839 | (line-end-position)) |
| 835 | (line-end-position))))) | 840 | (line-end-position))))) |
| 836 | (delete-region (match-beginning 0) (match-end 0))) | 841 | (delete-region (match-beginning 0) (match-end 0))) |
| 842 | ;; We have a single blank line. | ||
| 843 | ((and (eolp) (bolp)) | ||
| 844 | (insert "\n")) | ||
| 845 | ;; Insert new paragraph. | ||
| 837 | (t | 846 | (t |
| 838 | (insert "\n\n")))))) | 847 | (insert "\n\n")))))) |
| 839 | 848 | ||
| @@ -1247,7 +1256,7 @@ ones, in case fg and bg are nil." | |||
| 1247 | (shr-ensure-paragraph)) | 1256 | (shr-ensure-paragraph)) |
| 1248 | 1257 | ||
| 1249 | (defun shr-tag-div (dom) | 1258 | (defun shr-tag-div (dom) |
| 1250 | (shr-ensure-paragraph) | 1259 | (shr-ensure-newline) |
| 1251 | (shr-generic dom) | 1260 | (shr-generic dom) |
| 1252 | (shr-ensure-newline)) | 1261 | (shr-ensure-newline)) |
| 1253 | 1262 | ||