From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Sebasti=C3=A1n_?= =?UTF-8?Q?Mon=C3=ADa?= Newsgroups: gmane.emacs.bugs Subject: bug#59549: EWW ordered list display irregularity Date: Mon, 23 Sep 2024 15:07:32 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26684"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59549@debbugs.gnu.org To: Nicholas Drozd Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 23 23:18:00 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ssqRS-0006hk-CE for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Sep 2024 23:17:59 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ssqRC-0005cE-Uw; Mon, 23 Sep 2024 17:17:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ssqR9-0005c0-CE for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 17:17:39 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ssqR8-0004ic-VS for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 17:17:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=LUXAeMa+f5U4M1xb27+alNBQztj55mq+7L3Ff3C2fLs=; b=f3PobzvKNn5ZIIIiggsXKWEIzk828k43qwEYWnR6tDux0US2Tika9eLRfEOMQuFdvxatve8tynM43DMzFIK0kB4OcaRlr4CYaa4EFvxIJ9HGD48vIKqRcWBxv8xJMtIlHLpAfwgZADzs6U7b2VelivD14C90G0yhaWYZJAIsA1CvJQEguPa9DG3OORday5ssC8DWsQyE77koA1BAv8pJCM5q5A2thYVh+iHgXqPEbbMv4xphwv/9QAL/ynCuYhzZkPqktzdERbegoX38RYtBQ2yiQI37iAYiYdk88m9Q4DVlDjUZfilPkYOap3Wz4v6qeiKm2ydd4TOSC5zCyqftuA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ssqRV-0006rd-VV for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 17:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Sebasti=C3=A1n_?= =?UTF-8?Q?Mon=C3=ADa?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 Sep 2024 21:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59549 X-GNU-PR-Package: emacs Original-Received: via spool by 59549-submit@debbugs.gnu.org id=B59549.172712625126334 (code B ref 59549); Mon, 23 Sep 2024 21:18:01 +0000 Original-Received: (at 59549) by debbugs.gnu.org; 23 Sep 2024 21:17:31 +0000 Original-Received: from localhost ([127.0.0.1]:44764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssqQy-0006qd-Fr for submit@debbugs.gnu.org; Mon, 23 Sep 2024 17:17:30 -0400 Original-Received: from fout-a1-smtp.messagingengine.com ([103.168.172.144]:35409) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ssoPi-0008Co-PV for 59549@debbugs.gnu.org; Mon, 23 Sep 2024 15:08:04 -0400 Original-Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id A6F0F13802BA; Mon, 23 Sep 2024 15:07:33 -0400 (EDT) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 23 Sep 2024 15:07:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sebasmonia.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1727118453; x= 1727204853; bh=LUXAeMa+f5U4M1xb27+alNBQztj55mq+7L3Ff3C2fLs=; b=a dF/CKLcxKveuab6lWSwbsRfMRhUC+QIHwJvYWiHmKBW7oWFcn9XMDUQYnnsvs00e phnRuWRc0IdKUdmFdBee9IeMXKZBof08IKiHiwQ1BxGJNn9rwYLjGx7oiGiWNPYn p865Kpbb6PkLAQgigAUuvj7HA9sKUwiPYyz3IK/VFoHsfwEvV2F+rA4mfNEYG7fk KqRpvaGPR1LYf/6TT7Fpwlm/84fgVLeacAgKgddSM7OJX8BmB+A3NjxnfVsNmNtl f2r1LtvKKa4b2Xjrd+U0dtxnaOEaepV4rHJdslZEsmd7juG1uVA1uAwI/CkztRkn VcfcdtKuhrp6zpB/z2Kuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1727118453; x=1727204853; bh=LUXAeMa+f5U4M1xb27+alNBQztj5 5mq+7L3Ff3C2fLs=; b=fTy0oSek3VDBxAxQd/1UGx0OF7/MeguO/jiK2At8sYhh vhbVWpoL2CHz2AvWwxXGu+vqixsDdlVbLBvxd602O2cbDsAu8MCSqHkqDCXRts+X CJKlR/P/+LpcZMT7YKQkYFxTkMICNH9ATXO/CyVVPHf6jVS9r5A2BGX13Iqzvrs0 pobHFnnqgKHFxjQgoCkD4xq5dC6RHIPq7cqZrajn+jbbb+55pJkpYbi1RSUd2ljD mmHnYAjSPKyovgC0FRqxgZLlfWwbhbFnchXGJQbyvWxRCrAAjQ3kzIegO2keb/j8 Y7OON094sVKgEjucgdB4z81FWalDFXPFikdd3MUcLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelledgudefhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufgjfhffkfgfgggtsehmtderredtredu necuhfhrohhmpefuvggsrghsthhijohnucfoohhnvogruceoshgvsggrshhtihgrnhessh gvsggrshhmohhnihgrrdgtohhmqeenucggtffrrghtthgvrhhnpeevieetvdehudehheeu udehtdeutdejhffhfffgheelueeugeelvedvgfejfedvueenucffohhmrghinhepfihikh htihhonhgrrhihrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepshgvsggrshhtihgrnhesshgvsggrshhmohhnihgrrdgtohhmpdhnsg gprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeehleehgeel seguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepnhhitghhohhlrghsughroh iiugesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Sep 2024 15:07:33 -0400 (EDT) In-Reply-To: (Nicholas Drozd's message of "Thu, 24 Nov 2022 12:29:13 -0600") X-Mailman-Approved-At: Mon, 23 Sep 2024 17:17:27 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292292 Archived-At: --=-=-= Content-Type: text/plain Hi everyone, > Here is the Wiktionary definition of the word "locus": > https://en.wiktionary.org/wiki/locus#Noun When I open that page in > EWW, I see five definition entries. But the second entry is blank. I was able to reproduce. > So EWW is not failing to display anything; instead, it is inserting > something extra. That extra something comes from this piece of HTML: > >
  • I wouldn't say for sure EWW is in the wrong here. Apparently inserting empty li elements for styling purposed is a somewhat common practice. Couldn't confirm how "correct" it is, but it is accepted. (sidenote, stuff like this makes be glad I haven't worked in web stuff in many many years) > I don't know why that's in there or how Firefox knows not to display > it. It would be cool if EWW also knew not to display it. The attached patch does exactly that: skip any li elements that don't have content. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-shr-don-t-render-empty-li-tags-bug-59549.patch Content-Description: shr.el: don't render empty li tags >From afa3cccda43ea17933d0e782243cf2adc9ee51c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Mon=C3=ADa?= Date: Mon, 23 Sep 2024 15:00:44 -0400 Subject: [PATCH] shr: don't render empty li tags (bug#59549) --- lisp/net/shr.el | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index cd0e482aee7..2a72621fec4 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1656,6 +1656,11 @@ Based on https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-infore (shr-generic dom) (shr-ensure-paragraph)) +(defun shr-tag-empty-content-p (dom) + "Return t if DOM has no content. +By \"content\" we mean \"text between the tags\"." + (string-empty-p (string-trim (dom-text dom)))) + (defun shr-tag-div (dom) (let ((display (cdr (assq 'display shr-stylesheet)))) (if (or (equal display "inline") @@ -2163,26 +2168,30 @@ BASE is the URL of the HTML being rendered." (shr-ensure-paragraph)) (defun shr-tag-li (dom) - (shr-ensure-newline) - (let ((start (point))) - (let* ((bullet - (if (numberp shr-list-mode) - (prog1 - (format "%d " shr-list-mode) - (setq shr-list-mode (1+ shr-list-mode))) - (car shr-internal-bullet))) - (width (if (numberp shr-list-mode) - (shr-string-pixel-width bullet) - (cdr shr-internal-bullet)))) - (insert bullet) - (shr-mark-fill start) - (let ((shr-indentation (+ shr-indentation width))) - (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)))) - (unless (bolp) - (insert "\n"))) + ;; bug#59549: EWW ordered list display irregularity + ;; empty li tags are used sometimes for styling purposes: do not + ;; render such tags + (unless (shr-tag-empty-content-p dom) + (shr-ensure-newline) + (let ((start (point))) + (let* ((bullet + (if (numberp shr-list-mode) + (prog1 + (format "%d " shr-list-mode) + (setq shr-list-mode (1+ shr-list-mode))) + (car shr-internal-bullet))) + (width (if (numberp shr-list-mode) + (shr-string-pixel-width bullet) + (cdr shr-internal-bullet)))) + (insert bullet) + (shr-mark-fill start) + (let ((shr-indentation (+ shr-indentation width))) + (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)))) + (unless (bolp) + (insert "\n")))) (defun shr-mark-fill (start) ;; We may not have inserted any text to fill. -- 2.45.2.windows.1 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable I tested with the Wiktionary page and a few other offline tests and it worked as intended. Regards, Seb --=20 Sebasti=E1n Mon=EDa https://site.sebasmonia.com/ --=-=-=--