From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Nicholas Drozd <nicholasdrozd@gmail.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 36475@debbugs.gnu.org
Subject: bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
Date: Thu, 04 Jul 2019 20:40:12 +0100 [thread overview]
Message-ID: <87y31dtwpv.fsf@tcd.ie> (raw)
In-Reply-To: <CABAiW0pFK_isXewHDWeB3XKRcaT9H0AiZq2oGqi9uGsTu1_iew@mail.gmail.com> (Nicholas Drozd's message of "Tue, 2 Jul 2019 09:06:43 -0500")
severity 36475 wishlist
quit
Nicholas Drozd <nicholasdrozd@gmail.com> 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 <abbr> elements.")
Thoughts? Lars?
> Let's try to get this merged <abbr title="as soon as possible">ASAP</abbr>.
>
> From a720473ad1001d3a72f9b3f3155f5488726cabde Mon Sep 17 00:00:00 2001
> From: Nick Drozd <nicholasdrozd@gmail.com>
> 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 <code ...> tag is now handled.
>
> +---
> +*** The <abbr ...> and <acronym ...> tags are now handled.
> +
I suggest announcing all new tags (i.e. including <code>) 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
next prev parent reply other threads:[~2019-07-04 19:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-02 14:06 bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el Nicholas Drozd
2019-07-02 18:26 ` Michael Albinus
2019-07-02 23:11 ` Nicholas Drozd
2019-07-03 6:42 ` Michael Albinus
2019-07-03 20:17 ` Nicholas Drozd
2019-07-04 19:40 ` Basil L. Contovounesios [this message]
2019-07-05 13:03 ` Lars Ingebrigtsen
2019-07-05 16:36 ` Nicholas Drozd
2019-07-06 12:02 ` Lars 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y31dtwpv.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=36475@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=nicholasdrozd@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.