mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
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.
This commit is contained in:
parent
21c89971c3
commit
292921faca
1 changed files with 12 additions and 3 deletions
|
|
@ -805,8 +805,13 @@ size, and full-buffer size."
|
|||
(url-expand-file-name url (concat (car base) (cadr base))))))
|
||||
|
||||
(defun shr-ensure-newline ()
|
||||
(unless (zerop (current-column))
|
||||
(insert "\n")))
|
||||
(unless (bobp)
|
||||
(let ((prefix (get-text-property (line-beginning-position)
|
||||
'shr-prefix-length)))
|
||||
(unless (or (zerop (current-column))
|
||||
(and prefix
|
||||
(= prefix (- (point) (line-beginning-position)))))
|
||||
(insert "\n")))))
|
||||
|
||||
(defun shr-ensure-paragraph ()
|
||||
(unless (bobp)
|
||||
|
|
@ -834,6 +839,10 @@ size, and full-buffer size."
|
|||
(line-end-position))
|
||||
(line-end-position)))))
|
||||
(delete-region (match-beginning 0) (match-end 0)))
|
||||
;; We have a single blank line.
|
||||
((and (eolp) (bolp))
|
||||
(insert "\n"))
|
||||
;; Insert new paragraph.
|
||||
(t
|
||||
(insert "\n\n"))))))
|
||||
|
||||
|
|
@ -1247,7 +1256,7 @@ ones, in case fg and bg are nil."
|
|||
(shr-ensure-paragraph))
|
||||
|
||||
(defun shr-tag-div (dom)
|
||||
(shr-ensure-paragraph)
|
||||
(shr-ensure-newline)
|
||||
(shr-generic dom)
|
||||
(shr-ensure-newline))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue