From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#23057: 25.0.92; shr wrongly adds two newlines to div element Date: Sat, 19 Mar 2016 13:59:47 +0100 Message-ID: <874mc2fwsc.fsf@web.de> References: <87lh5fijaq.fsf@gmx.net> <87a8lvig5m.fsf@gmx.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1458392431 2956 80.91.229.3 (19 Mar 2016 13:00:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Mar 2016 13:00:31 +0000 (UTC) Cc: 23057@debbugs.gnu.org, Lars Ingebrigtsen To: Stephen Berman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 19 14:00:18 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ahGUJ-0008O1-Dj for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Mar 2016 14:00:15 +0100 Original-Received: from localhost ([::1]:48730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahGUF-0006B1-7T for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Mar 2016 09:00:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahGU9-00068S-TZ for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 09:00:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ahGU6-0003cV-Oh for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 09:00:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ahGU6-0003cQ-M8 for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 09:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ahGU6-0002WO-Ax for bug-gnu-emacs@gnu.org; Sat, 19 Mar 2016 09:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Mar 2016 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23057 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23057-submit@debbugs.gnu.org id=B23057.14583923989654 (code B ref 23057); Sat, 19 Mar 2016 13:00:02 +0000 Original-Received: (at 23057) by debbugs.gnu.org; 19 Mar 2016 12:59:58 +0000 Original-Received: from localhost ([127.0.0.1]:53252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahGU2-0002Ve-0M for submit@debbugs.gnu.org; Sat, 19 Mar 2016 08:59:58 -0400 Original-Received: from mout.web.de ([212.227.15.3]:57548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ahGU0-0002VS-Ew for 23057@debbugs.gnu.org; Sat, 19 Mar 2016 08:59:56 -0400 Original-Received: from drachen.dragon ([94.218.210.27]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0LrKIO-1ZeSYj1IFA-013ABj; Sat, 19 Mar 2016 13:59:49 +0100 In-Reply-To: <87a8lvig5m.fsf@gmx.net> (Stephen Berman's message of "Fri, 18 Mar 2016 23:18:29 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) X-Provags-ID: V03:K0:uyaVBDa2Z5a68YxYfSESSsB0FJcixzkPGjSA3w7Lxb1ZrBu2QKU mwhyNRgpfuGDnuO8czdsoc4yf1W93RM22/HBlwbNSG3HqnVesXxzYbxc88MR/f3bCQOTtJw XCuQDDlmRnWzB6jM2e+23/JxcXCqH2Aa+DVuI2Bk8uA7FCP1Yq7naGezaUcfINpKndVB3ep uk9MWOA3xuH9wkNNw5yaQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:bpIOuJ4FwIE=:aMeH+YJrNNdG+7GrBuGrgY YqiHh8lmhEsUbKvGJyeP1ldnAdYydT/fd6AZYQD5x/OtPB0ceKfPjI27GK0jBJzgHBKpBlHuS GfwthaJJgW00MGuJNa+GUR0ZQ29e8+dSGppgH7QyEdinRkFzOSvTbpBSrVMiKvYL0wxl2dy3r +sjBqIBbWZlxIpb4hTwZFqJljjg0sdPKHNLb3QzH2F3OFlhLvHPgZZPWV0t5yYYElEQSiuuFL iQVw2hE+U7YYozms/DUlXqmU+DwibGWxhglkLdQvymBDgWgPKm2rL+oOCcbomf3HrTd12k9L8 JFXzPvvPTyulfQnuK95amrDVkKvBk71aeXQ59ZIgmH+O3wsl7/YMZb8vXacqPCYaWQW10MO9g CF8H8OX6ZYZxjJA0ZgR0s7B1tbWVAlps0DHRojB3qI+vhr6gL1ts7PmtJ5pvM+Cn8Yi2GZG64 1EAOoUFFOA2/F9TP/YZoQpov1FK3NzDHkfhXG1q3fc5OI9d3S+t27DAzqqMB+Ns5WwjUmLW17 6EKd2OUw4+VOWX9tRye1d8HOOxpmDEuZ20IuRzqmqiROGiMvOFrAAJAwoqGxxUu8QOKdY++my agfv1KFAXySQlvtWnFN0xAcm7lk5QZ54rQ8+ucXEcMW0fusZSOPvqxzH3PFUcn21uPqrGPQGE 0yXUTn4YVN3jTSmHf/57sl98Dl50XWYhWSeCqXr4DDZVbIrpbZyBhMSn4axmn3jiS0HVf1n/d mMQSC879HCnkeYER5naUeAZUjgFIaKmrwR5eOK51US1d377lsckq37TLnhEWW+iaw1tRLaIp X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115080 Archived-At: 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) > > + ;;
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)) > + ;;
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)) >