From 05cc14641fa7f193ebcdb6548c03e293b4511d47 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 (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 tag is now handled. +*** The following tags are now handled: , , and . ** 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 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