unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicholas Drozd <nicholasdrozd@gmail.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 36475@debbugs.gnu.org
Subject: bug#36475: [PATCH] Handle 'abbr' and 'acronym' tags in shr.el
Date: Fri, 5 Jul 2019 12:36:04 -0400	[thread overview]
Message-ID: <CABAiW0qeso5i3=Ci8Va1fRB6HkxF08Ln_K25WQcBEo3BZ3fiPg@mail.gmail.com> (raw)
In-Reply-To: <87y31dtwpv.fsf@tcd.ie>

[-- 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


  parent reply	other threads:[~2019-07-05 16:36 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
2019-07-05 13:03   ` Lars Ingebrigtsen
2019-07-05 16:36   ` Nicholas Drozd [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABAiW0qeso5i3=Ci8Va1fRB6HkxF08Ln_K25WQcBEo3BZ3fiPg@mail.gmail.com' \
    --to=nicholasdrozd@gmail.com \
    --cc=36475@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=larsi@gnus.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).