From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el Date: Thu, 04 Jul 2019 20:40:12 +0100 Message-ID: <87y31dtwpv.fsf@tcd.ie> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="71014"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Lars Ingebrigtsen , 36475@debbugs.gnu.org To: Nicholas Drozd Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 04 21:41:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hj7bT-000IKp-1y for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 21:41:11 +0200 Original-Received: from localhost ([::1]:48456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj7bR-0003Az-W9 for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 15:41:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40176) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj7bL-00036W-HJ for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 15:41:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hj7bK-0002h2-9Q for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 15:41:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hj7bK-0002gs-06 for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 15:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hj7bJ-00055E-RV for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 15:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2019 19:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36475 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36475-submit@debbugs.gnu.org id=B36475.156226922919477 (code B ref 36475); Thu, 04 Jul 2019 19:41:01 +0000 Original-Received: (at 36475) by debbugs.gnu.org; 4 Jul 2019 19:40:29 +0000 Original-Received: from localhost ([127.0.0.1]:51940 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj7am-000543-La for submit@debbugs.gnu.org; Thu, 04 Jul 2019 15:40:29 -0400 Original-Received: from mail-ed1-f66.google.com ([209.85.208.66]:44633) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj7aj-00053g-SG for 36475@debbugs.gnu.org; Thu, 04 Jul 2019 15:40:26 -0400 Original-Received: by mail-ed1-f66.google.com with SMTP id k8so6239245edr.11 for <36475@debbugs.gnu.org>; Thu, 04 Jul 2019 12:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=MaqG+ZWll8fpHMPJW2faW/QQ/78mtGiGf7uGSggBIXk=; b=comQUQvmP+kaC5KRs//L+y0M+IrSq55H0hF0iHHOCqzK+420n7V4+zoUUNiEfI0HQ8 RlzZc2te0njvYGXRp5mCcPAk8KLZT1ycgc0c83vLOZcXbs3wPu0rST6+61bOOo5Ckqsz vplr1bNYPuLksqvZ6Lrg/lAiLBk/VzmcboxpvK7zWFwIT+TLU9wkaPPInNiuSBIq/QZt qwi6NgkZEjT5fr1IHBMwQTFkoiF5uuuYyNMDWoXpnrOMMSapBWTyZOIHpiEUb5Xm1dhv EBEErLM4slRHoKTe9r6GMHgSoYrq5P53FjQtEe4Ca1ooH2UjJP4adYhqQHttLG6O0G5V YG2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=MaqG+ZWll8fpHMPJW2faW/QQ/78mtGiGf7uGSggBIXk=; b=fK2rmjbke2Fl3LkFkbtslAW3a060E92w2fPA9uSj9hjZBANhj6Euhez08fZLwyI1Ej gzE0dVmkzYU6mQWlt38s0+kIlRjt1UycsstH2R9oPfyruepn5/Kk0ZLi8htuDJPESnFy Xz6uHJqK6FOkRAtz7/QSY/MqtsT63X6/vXkmUR61nEgK8vplk5l1Lsb2E0iZ9vOVz+/c e3YhpoQVElIY1DGN4Bu5N5jcH8NCrm4Hzw6CZlsZ7YtO5lowANFP6fv4K6/VnNWN5Z7R PrhhjBgIZ2TlPbxyKGmvrsegKw/4faepG93zr60uUArTjMXgk6lJMlnkfZz6K9DZN/l9 8gzw== X-Gm-Message-State: APjAAAXjQvWyJg93I7MU4OPm8U54e6EokIPzqD6d3D/HptVsNtw9QBIj b/X7jTqyPYsvpcIj19G748o96Q== X-Google-Smtp-Source: APXvYqzhai0DF95f846t2I4DB3FUTV/bcMmlgWKnn3a1+6xwfGEJ0m2xFhAeIvPrSdfX87AEamcHmA== X-Received: by 2002:a17:906:2191:: with SMTP id 17mr40929741eju.157.1562269219815; Thu, 04 Jul 2019 12:40:19 -0700 (PDT) Original-Received: from localhost ([86.43.118.33]) by smtp.gmail.com with ESMTPSA id k8sm167670edr.31.2019.07.04.12.40.18 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 12:40:18 -0700 (PDT) In-Reply-To: (Nicholas Drozd's message of "Tue, 2 Jul 2019 09:06:43 -0500") 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: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:162077 Archived-At: severity 36475 wishlist quit Nicholas Drozd writes: > I came across some `abbr` tags in the wild: check out the first > paragraph of http://mindprod.com/jgloss/unmainobfuscation.html. EWW > doesn't handle those, so here is a patch for that. > > My understanding is that there is also an `acronym` tag which has been > deprecated in favor of `abbr`. I figured we might as well cover that > one too just in case. +1. > I picked the `diary` face for abbreviations, but that choice didn't > have a lot of thought put into it. Whoever commits can choose > something else. Indeed I don't think the 'diary' face is a very good fit. Not only is it undefined unless calendar.el is loaded, but it also has a quite jarring red/yellow foreground by default, and bears no relation to abbreviations. The major browsers use a dotted underline, and text in Emacs that has a 'help-echo' property is usually fontified with a face inheriting from 'link' (outside of the mode line, images, and buttons, of course). So my suggestion is to provide a new face inheriting from either 'shr-link', 'link', or 'underline'. Personally, I would also add ':underline (:style wave)', as it reminds me of the dotted underline in external browsers: (defface shr-abbreviation '((t :inherit underline :underline (:style wave))) "Face for elements.") Thoughts? Lars? > Let's try to get this merged ASAP. > > From a720473ad1001d3a72f9b3f3155f5488726cabde Mon Sep 17 00:00:00 2001 > From: Nick Drozd > Date: Mon, 1 Jul 2019 23:46:10 -0500 > Subject: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el > > * lisp/net/shr.el: Add 'abbr' and 'acronym' tag handling. Nit: I think this should list the new functions, as per usual: * lisp/net/shr.el (shr-tag-abbr, shr-tag-acronym): New functions handling 'abbr' and 'acronym' tags, respectively. > * etc/NEWS: Announce change in shr behavrior. > --- > etc/NEWS | 3 +++ > lisp/net/shr.el | 15 +++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/etc/NEWS b/etc/NEWS > index abbece374a..464dae2454 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -989,6 +989,9 @@ This attribute is meant to tell screen readers to ignore a tag. > --- > *** The tag is now handled. > > +--- > +*** The and tags are now handled. > + I suggest announcing all new tags (i.e. including ) in a single NEWS entry. > ** Htmlfontify > > *** The functions 'hfy-color', 'hfy-color-vals' and > diff --git a/lisp/net/shr.el b/lisp/net/shr.el > index 7fdb3212d4..3af3db637a 100644 > --- a/lisp/net/shr.el > +++ b/lisp/net/shr.el > @@ -1470,6 +1470,21 @@ shr-tag-a > (when url > (shr-urlify (or shr-start start) (shr-expand-url url) title)))) > > +(defun shr-tag-abbr (dom) > + (let ((title (dom-attr dom 'title)) > + (start (point))) > + (shr-generic dom) > + (shr-add-font start (point) 'diary) > + (add-text-properties > + start (point) > + (list > + 'help-echo title > + 'mouse-face 'highlight)))) According to Mozilla[1], the 'title' attribute is optional, so perhaps we should avoid this fontification if the attribute is missing, which is what Firefox and Chromium seem do. [1]: https://developer.mozilla.org/en/docs/Web/HTML/Element/abbr Apart from these minor comments, LGTM. Thanks, -- Basil