diff options
| author | Lars Magne Ingebrigtsen | 2015-02-11 17:24:42 +1100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2015-02-11 17:25:10 +1100 |
| commit | 6ebbeafc94a35e49fc3a842b5f5fbd7b069ce936 (patch) | |
| tree | 34e50df7fbc3c5cfb433c1361026eefcd0845848 | |
| parent | 097e16e26663c1010db6f6dc2db7b5f1b7a4dbc0 (diff) | |
| download | emacs-6ebbeafc94a35e49fc3a842b5f5fbd7b069ce936.tar.gz emacs-6ebbeafc94a35e49fc3a842b5f5fbd7b069ce936.zip | |
Fix <li><p> indentation in shr
(shr-ensure-paragraph): Don't insert a new paragraph as the first
item in a <li>.
| -rw-r--r-- | lisp/ChangeLog | 2 | ||||
| -rw-r--r-- | lisp/net/shr.el | 44 |
2 files changed, 29 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7ec017c94ec..03b465e8030 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | * net/shr.el (shr-insert): Make sure the space inserted has the | 3 | * net/shr.el (shr-insert): Make sure the space inserted has the |
| 4 | right font (for width). | 4 | right font (for width). |
| 5 | (shr-fill-line): Preserve background colours when indenting/folding. | 5 | (shr-fill-line): Preserve background colours when indenting/folding. |
| 6 | (shr-ensure-paragraph): Don't insert a new paragraph as the first | ||
| 7 | item in a <li>. | ||
| 6 | 8 | ||
| 7 | 2015-02-10 Lars Ingebrigtsen <larsi@gnus.org> | 9 | 2015-02-10 Lars Ingebrigtsen <larsi@gnus.org> |
| 8 | 10 | ||
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 7a93c3a043c..cf35a1287d6 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -719,23 +719,32 @@ size, and full-buffer size." | |||
| 719 | 719 | ||
| 720 | (defun shr-ensure-paragraph () | 720 | (defun shr-ensure-paragraph () |
| 721 | (unless (bobp) | 721 | (unless (bobp) |
| 722 | (if (<= (current-column) shr-indentation) | 722 | (let ((prefix (get-text-property (line-beginning-position) |
| 723 | (unless (save-excursion | 723 | 'shr-prefix-length))) |
| 724 | (forward-line -1) | 724 | (cond |
| 725 | (looking-at " *$")) | 725 | ((and (bolp) |
| 726 | (insert "\n")) | 726 | (save-excursion |
| 727 | (if (save-excursion | 727 | (forward-line -1) |
| 728 | (beginning-of-line) | 728 | (looking-at " *$"))) |
| 729 | ;; If the current line is totally blank, and doesn't even | 729 | ;; We're already at a new paragraph; do nothing. |
| 730 | ;; have any face properties set, then delete the blank | 730 | ) |
| 731 | ;; space. | 731 | ((and prefix |
| 732 | (and (looking-at " *$") | 732 | (= prefix (- (point) (line-beginning-position)))) |
| 733 | (not (get-text-property (point) 'face)) | 733 | ;; Do nothing; we're at the start of a <li>. |
| 734 | (not (= (next-single-property-change (point) 'face nil | 734 | ) |
| 735 | (line-end-position)) | 735 | ((save-excursion |
| 736 | (line-end-position))))) | 736 | (beginning-of-line) |
| 737 | (delete-region (match-beginning 0) (match-end 0)) | 737 | ;; If the current line is totally blank, and doesn't even |
| 738 | (insert "\n\n"))))) | 738 | ;; have any face properties set, then delete the blank |
| 739 | ;; space. | ||
| 740 | (and (looking-at " *$") | ||
| 741 | (not (get-text-property (point) 'face)) | ||
| 742 | (not (= (next-single-property-change (point) 'face nil | ||
| 743 | (line-end-position)) | ||
| 744 | (line-end-position))))) | ||
| 745 | (delete-region (match-beginning 0) (match-end 0))) | ||
| 746 | (t | ||
| 747 | (insert "\n\n")))))) | ||
| 739 | 748 | ||
| 740 | (defun shr-indent () | 749 | (defun shr-indent () |
| 741 | (when (> shr-indentation 0) | 750 | (when (> shr-indentation 0) |
| @@ -1406,6 +1415,7 @@ The preference is a float determined from `shr-prefer-media-type'." | |||
| 1406 | (shr-string-pixel-width bullet)))) | 1415 | (shr-string-pixel-width bullet)))) |
| 1407 | (put-text-property start (1+ start) | 1416 | (put-text-property start (1+ start) |
| 1408 | 'shr-continuation-indentation shr-indentation) | 1417 | 'shr-continuation-indentation shr-indentation) |
| 1418 | (put-text-property start (1+ start) 'shr-prefix-length (length bullet)) | ||
| 1409 | (shr-generic dom))))) | 1419 | (shr-generic dom))))) |
| 1410 | 1420 | ||
| 1411 | (defun shr-mark-fill (start) | 1421 | (defun shr-mark-fill (start) |