diff options
author | Nick Drozd <nicholasdrozd@gmail.com> | 2019-07-06 14:02:37 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-07-07 13:57:25 +0200 |
commit | bda8a57141e6cb5455e1246c6ab394791fd6c582 (patch) | |
tree | e2e5ba6829d3ed10358ed733add98c3aaf9c84e0 | |
parent | 72e21777d0c3940465351fb86d9b7dbce20ace63 (diff) | |
download | emacs-bda8a57141e6cb5455e1246c6ab394791fd6c582.tar.gz |
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 behavior (bug#36475).
-rw-r--r-- | etc/NEWS | 2 | ||||
-rw-r--r-- | lisp/net/shr.el | 21 |
2 files changed, 22 insertions, 1 deletions
@@ -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 3d437bc6937..b6dbcaa6cfb 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -161,6 +161,12 @@ temporarily blinks with this face." :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.") @@ -1472,6 +1478,21 @@ ones, in case fg and bg are nil." (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)) |