[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 6ebbeaf: Fix <li><p> indentation in shr
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master 6ebbeaf: Fix <li><p> indentation in shr |
Date: |
Wed, 11 Feb 2015 06:25:16 +0000 |
branch: master
commit 6ebbeafc94a35e49fc3a842b5f5fbd7b069ce936
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>
Fix <li><p> indentation in shr
(shr-ensure-paragraph): Don't insert a new paragraph as the first
item in a <li>.
---
lisp/ChangeLog | 2 ++
lisp/net/shr.el | 44 +++++++++++++++++++++++++++-----------------
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7ec017c..03b465e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -3,6 +3,8 @@
* net/shr.el (shr-insert): Make sure the space inserted has the
right font (for width).
(shr-fill-line): Preserve background colours when indenting/folding.
+ (shr-ensure-paragraph): Don't insert a new paragraph as the first
+ item in a <li>.
2015-02-10 Lars Ingebrigtsen <address@hidden>
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 7a93c3a..cf35a12 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -719,23 +719,32 @@ size, and full-buffer size."
(defun shr-ensure-paragraph ()
(unless (bobp)
- (if (<= (current-column) shr-indentation)
- (unless (save-excursion
- (forward-line -1)
- (looking-at " *$"))
- (insert "\n"))
- (if (save-excursion
- (beginning-of-line)
- ;; If the current line is totally blank, and doesn't even
- ;; have any face properties set, then delete the blank
- ;; space.
- (and (looking-at " *$")
- (not (get-text-property (point) 'face))
- (not (= (next-single-property-change (point) 'face nil
- (line-end-position))
- (line-end-position)))))
- (delete-region (match-beginning 0) (match-end 0))
- (insert "\n\n")))))
+ (let ((prefix (get-text-property (line-beginning-position)
+ 'shr-prefix-length)))
+ (cond
+ ((and (bolp)
+ (save-excursion
+ (forward-line -1)
+ (looking-at " *$")))
+ ;; We're already at a new paragraph; do nothing.
+ )
+ ((and prefix
+ (= prefix (- (point) (line-beginning-position))))
+ ;; Do nothing; we're at the start of a <li>.
+ )
+ ((save-excursion
+ (beginning-of-line)
+ ;; If the current line is totally blank, and doesn't even
+ ;; have any face properties set, then delete the blank
+ ;; space.
+ (and (looking-at " *$")
+ (not (get-text-property (point) 'face))
+ (not (= (next-single-property-change (point) 'face nil
+ (line-end-position))
+ (line-end-position)))))
+ (delete-region (match-beginning 0) (match-end 0)))
+ (t
+ (insert "\n\n"))))))
(defun shr-indent ()
(when (> shr-indentation 0)
@@ -1406,6 +1415,7 @@ The preference is a float determined from
`shr-prefer-media-type'."
(shr-string-pixel-width bullet))))
(put-text-property start (1+ start)
'shr-continuation-indentation shr-indentation)
+ (put-text-property start (1+ start) 'shr-prefix-length (length bullet))
(shr-generic dom)))))
(defun shr-mark-fill (start)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 6ebbeaf: Fix <li><p> indentation in shr,
Lars Ingebrigtsen <=