summaryrefslogtreecommitdiff
path: root/lisp/net/shr.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2020-09-19 19:11:09 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-09-19 19:11:09 +0200
commit7222e975be8d3d128086ed49506aa5bd8fccfae5 (patch)
treeefb6748f257c026107f5d3559a5e9274fbb9324c /lisp/net/shr.el
parent28ba8793626f60d9af2be4a21b3c57a314ac9e79 (diff)
downloademacs-7222e975be8d3d128086ed49506aa5bd8fccfae5.tar.gz
emacs-7222e975be8d3d128086ed49506aa5bd8fccfae5.tar.bz2
emacs-7222e975be8d3d128086ed49506aa5bd8fccfae5.zip
Fix problem with spurious extra paragraphs in shr
* lisp/net/shr.el (shr-ensure-paragraph): Don't regard <div id=foo></div> (empty placeholders) as occupying any space (bug#43510).
Diffstat (limited to 'lisp/net/shr.el')
-rw-r--r--lisp/net/shr.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 6517596130c..1f53bc4016d 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -555,7 +555,7 @@ size, and full-buffer size."
;; If the element was empty, we don't have anything to put the
;; anchor on. So just insert a dummy character.
(when (= start (point))
- (insert ?*)
+ (insert ? )
(put-text-property (1- (point)) (point) 'display ""))
(put-text-property start (1+ start) 'shr-target-id id))
;; If style is set, then this node has set the color.
@@ -932,6 +932,22 @@ size, and full-buffer size."
(looking-at " *$")))
;; We're already at a new paragraph; do nothing.
)
+ ((and (not (bolp))
+ (save-excursion
+ (beginning-of-line)
+ (looking-at " *$"))
+ (save-excursion
+ (forward-line -1)
+ (looking-at " *$"))
+ ;; Check all chars on the current line and see whether
+ ;; they're all placeholders.
+ (cl-loop for pos from (line-beginning-position) upto (1- (point))
+ unless (get-text-property pos 'shr-target-id)
+ return nil
+ finally return t))
+ ;; We have some invisible markers from <div id="foo"></div>;
+ ;; do nothing.
+ )
((and prefix
(= prefix (- (point) (line-beginning-position))))
;; Do nothing; we're at the start of a <li>.