From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 23057@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#23057: 25.0.92; shr wrongly adds two newlines to div element
Date: Sat, 19 Mar 2016 13:59:47 +0100 [thread overview]
Message-ID: <874mc2fwsc.fsf@web.de> (raw)
In-Reply-To: <87a8lvig5m.fsf@gmx.net> (Stephen Berman's message of "Fri, 18 Mar 2016 23:18:29 +0100")
Hi,
Lars, could you please have a look if it is ok to install this? This
fix should go to emacs25 (soon).
Thanks,
Michael.
> > The following patch fixes this display problem for me, but I'm not
> > familiar enough either with shr or with all the details of HTML block
> > elements to be sure this is a sufficient or even correct fix.
> >
> > diff --git a/lisp/net/shr.el b/lisp/net/shr.el
> > index e943132..d9dcda3 100644
> > --- a/lisp/net/shr.el
> > +++ b/lisp/net/shr.el
> > @@ -812,6 +812,9 @@ shr-ensure-paragraph
> > (line-end-position))
> > (line-end-position)))))
> > (delete-region (match-beginning 0) (match-end 0)))
> > + ((eq (dom-tag dom) 'div)
> > + ;; <div> contains no block element; do nothing.
> > + )
> > (t
> > (insert "\n\n"))))))
>
> Oops, I overlooked that `dom' is unbound here; it's dynamically bound
> when called from shr-tag-div, but that may be a problem elsewhere.
> Here's a cleaner alternative, but it's probably too ad hoc for a real
> fix:
>
> diff --git a/lisp/net/shr.el b/lisp/net/shr.el
> index e943132..6350dfb 100644
> --- a/lisp/net/shr.el
> +++ b/lisp/net/shr.el
> @@ -786,7 +786,7 @@ shr-ensure-newline
> (unless (zerop (current-column))
> (insert "\n")))
>
> -(defun shr-ensure-paragraph ()
> +(defun shr-ensure-paragraph (&optional dom)
> (unless (bobp)
> (let ((prefix (get-text-property (line-beginning-position)
> 'shr-prefix-length)))
> @@ -812,6 +812,10 @@ shr-ensure-paragraph
> (line-end-position))
> (line-end-position)))))
> (delete-region (match-beginning 0) (match-end 0)))
> + ((and dom
> + (eq (dom-tag dom) 'div))
> + ;; <div> contains no block element; do nothing.
> + )
> (t
> (insert "\n\n"))))))
>
> @@ -1206,7 +1210,7 @@ shr-tag-p
> (shr-ensure-paragraph))
>
> (defun shr-tag-div (dom)
> - (shr-ensure-paragraph)
> + (shr-ensure-paragraph dom)
> (shr-generic dom)
> (shr-ensure-newline))
>
next prev parent reply other threads:[~2016-03-19 12:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 21:10 bug#23057: 25.0.92; shr wrongly adds two newlines to div element Stephen Berman
2016-03-18 22:18 ` Stephen Berman
2016-03-19 12:59 ` Michael Heerdegen [this message]
2016-03-20 11:57 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874mc2fwsc.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=23057@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=stephen.berman@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).