all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
@ 2019-07-02 14:06 Nicholas Drozd
  2019-07-02 18:26 ` Michael Albinus
  2019-07-04 19:40 ` Basil L. Contovounesios
  0 siblings, 2 replies; 9+ messages in thread
From: Nicholas Drozd @ 2019-07-02 14:06 UTC (permalink / raw)
  To: 36475

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

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.

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.

Let's try to get this merged <abbr title="as soon as possible">ASAP</abbr>.

[-- Attachment #2: 0001-Handle-abbr-and-acronym-tags-in-shr.el.patch --]
[-- Type: text/x-patch, Size: 1506 bytes --]

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.
* 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.
+
 ** 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))))
+
+(defun shr-tag-acronym (dom)
+  ;; `acronym' is deprecated in favor of `abbr'.
+  (shr-tag-abbr dom))
+
 (defun shr-tag-object (dom)
   (unless shr-inhibit-images
     (let ((start (point))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  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-04 19:40 ` Basil L. Contovounesios
  1 sibling, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2019-07-02 18:26 UTC (permalink / raw)
  To: Nicholas Drozd; +Cc: 36475

Nicholas Drozd <nicholasdrozd@gmail.com> writes:

> +(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))))
> +
> +(defun shr-tag-acronym (dom)
> +  ;; `acronym' is deprecated in favor of `abbr'.
> +  (shr-tag-abbr dom))

Couldn't this be a defalias?

Best regards, Michael.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-02 18:26 ` Michael Albinus
@ 2019-07-02 23:11   ` Nicholas Drozd
  2019-07-03  6:42     ` Michael Albinus
  0 siblings, 1 reply; 9+ messages in thread
From: Nicholas Drozd @ 2019-07-02 23:11 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 36475

It could be, but I don't know that much would be gained. While a
defalias would be slightly terser, it would also stick out from the
surrounding defuns. I don't have a strong opinion either way. Are
there any non-style considerations?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-02 23:11   ` Nicholas Drozd
@ 2019-07-03  6:42     ` Michael Albinus
  2019-07-03 20:17       ` Nicholas Drozd
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Albinus @ 2019-07-03  6:42 UTC (permalink / raw)
  To: Nicholas Drozd; +Cc: 36475

Nicholas Drozd <nicholasdrozd@gmail.com> writes:

Hi Nicholas,

> It could be, but I don't know that much would be gained. While a
> defalias would be slightly terser, it would also stick out from the
> surrounding defuns. I don't have a strong opinion either way. Are
> there any non-style considerations?

I have no strong opinion either, but using a defalias seems to me the
better choice. Maybe I'm biased due to the work on Tramp, where a large
part of the job is keeping backward compatibility with older
Emacsen. That's why I have a preference to defalias, whenever
possible. It needs less maintainership attention.

But it is your decision, of course.

Best regards, Michael.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-03  6:42     ` Michael Albinus
@ 2019-07-03 20:17       ` Nicholas Drozd
  0 siblings, 0 replies; 9+ messages in thread
From: Nicholas Drozd @ 2019-07-03 20:17 UTC (permalink / raw)
  To: Michael Albinus; +Cc: 36475

Let's leave it as a defun for now then, and anyone who objects can
change it later (probably without any consequence). shr-tag-tt does
the same thing, deferring to shr-tag-code, so shr-tag-tt and
shr-tag-acronym can be changed together.

On Wed, Jul 3, 2019 at 1:42 AM Michael Albinus <michael.albinus@gmx.de> wrote:
>
> Nicholas Drozd <nicholasdrozd@gmail.com> writes:
>
> Hi Nicholas,
>
> > It could be, but I don't know that much would be gained. While a
> > defalias would be slightly terser, it would also stick out from the
> > surrounding defuns. I don't have a strong opinion either way. Are
> > there any non-style considerations?
>
> I have no strong opinion either, but using a defalias seems to me the
> better choice. Maybe I'm biased due to the work on Tramp, where a large
> part of the job is keeping backward compatibility with older
> Emacsen. That's why I have a preference to defalias, whenever
> possible. It needs less maintainership attention.
>
> But it is your decision, of course.
>
> Best regards, Michael.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  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-04 19:40 ` Basil L. Contovounesios
  2019-07-05 13:03   ` Lars Ingebrigtsen
  2019-07-05 16:36   ` Nicholas Drozd
  1 sibling, 2 replies; 9+ messages in thread
From: Basil L. Contovounesios @ 2019-07-04 19:40 UTC (permalink / raw)
  To: Nicholas Drozd; +Cc: Lars Ingebrigtsen, 36475

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-04 19:40 ` Basil L. Contovounesios
@ 2019-07-05 13:03   ` Lars Ingebrigtsen
  2019-07-05 16:36   ` Nicholas Drozd
  1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-05 13:03 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Nicholas Drozd, 36475

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> (defface shr-abbreviation
>   '((t :inherit underline :underline (:style wave)))
>   "Face for <abbr> elements.")
>
> Thoughts?  Lars?

Sounds good.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-04 19:40 ` Basil L. Contovounesios
  2019-07-05 13:03   ` Lars Ingebrigtsen
@ 2019-07-05 16:36   ` Nicholas Drozd
  2019-07-06 12:02     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 9+ messages in thread
From: Nicholas Drozd @ 2019-07-05 16:36 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Lars Ingebrigtsen, 36475

[-- Attachment #1: Type: text/plain, Size: 133 bytes --]

Thanks for the comments, Basil. Attached is a revised patch that
covers everything <abbr title="as far as I can tell">AFAICT</abbr>.

[-- Attachment #2: 0001-Handle-abbr-and-acronym-tags-in-shr.el.patch --]
[-- Type: text/x-patch, Size: 1928 bytes --]

From 05cc14641fa7f193ebcdb6548c03e293b4511d47 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 (shr-tag-abbr, shr-tag-acronym): New functions
handling 'abbr' and 'acronym' tags, respectively.
* etc/NEWS: Announce change in shr behavrior.
---
 etc/NEWS        |  2 +-
 lisp/net/shr.el | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index abbece374a..852b6e4948 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -987,7 +987,7 @@ This attribute is meant to tell screen readers to ignore a tag.
 *** 'shr-tag-ol' now respects the ordered list 'start' attribute.
 
 ---
-*** The <code ...> tag is now handled.
+*** The following tags are now handled: <code>, <abbr>, and <acronym>.
 
 ** Htmlfontify
 
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 7fdb3212d4..9897e59e1e 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -159,6 +159,12 @@ shr-selected-link
   :version "27.1"
   :group 'shr)
 
+(defface shr-abbreviation
+  '((t :inherit underline :underline (:style wave)))
+  "Face for <abbr> elements."
+  :version "27.1"
+  :group 'shr)
+
 (defvar shr-inhibit-images nil
   "If non-nil, inhibit loading images.")
 
@@ -1470,6 +1476,21 @@ shr-tag-a
     (when url
       (shr-urlify (or shr-start start) (shr-expand-url url) title))))
 
+(defun shr-tag-abbr (dom)
+  (when-let* ((title (dom-attr dom 'title))
+	      (start (point)))
+    (shr-generic dom)
+    (shr-add-font start (point) 'shr-abbreviation)
+    (add-text-properties
+     start (point)
+     (list
+      'help-echo title
+      'mouse-face 'highlight))))
+
+(defun shr-tag-acronym (dom)
+  ;; `acronym' is deprecated in favor of `abbr'.
+  (shr-tag-abbr dom))
+
 (defun shr-tag-object (dom)
   (unless shr-inhibit-images
     (let ((start (point))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
  2019-07-05 16:36   ` Nicholas Drozd
@ 2019-07-06 12:02     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-06 12:02 UTC (permalink / raw)
  To: Nicholas Drozd; +Cc: Basil L. Contovounesios, 36475

Nicholas Drozd <nicholasdrozd@gmail.com> writes:

> Thanks for the comments, Basil. Attached is a revised patch that
> covers everything <abbr title="as far as I can tell">AFAICT</abbr>.

Looks good; I've now applied this to trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-06 12:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-07-05 13:03   ` Lars Ingebrigtsen
2019-07-05 16:36   ` Nicholas Drozd
2019-07-06 12:02     ` Lars Ingebrigtsen

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.