diff options
| author | Nick Drozd | 2019-07-06 14:02:37 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-07-07 13:57:25 +0200 |
| commit | bda8a57141e6cb5455e1246c6ab394791fd6c582 (patch) | |
| tree | e2e5ba6829d3ed10358ed733add98c3aaf9c84e0 | |
| parent | 72e21777d0c3940465351fb86d9b7dbce20ace63 (diff) | |
| download | emacs-bda8a57141e6cb5455e1246c6ab394791fd6c582.tar.gz emacs-bda8a57141e6cb5455e1246c6ab394791fd6c582.zip | |
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. | |||
| 987 | *** 'shr-tag-ol' now respects the ordered list 'start' attribute. | 987 | *** 'shr-tag-ol' now respects the ordered list 'start' attribute. |
| 988 | 988 | ||
| 989 | --- | 989 | --- |
| 990 | *** The <code ...> tag is now handled. | 990 | *** The following tags are now handled: <code>, <abbr>, and <acronym>. |
| 991 | 991 | ||
| 992 | ** Htmlfontify | 992 | ** Htmlfontify |
| 993 | 993 | ||
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." | |||
| 161 | :version "27.1" | 161 | :version "27.1" |
| 162 | :group 'shr) | 162 | :group 'shr) |
| 163 | 163 | ||
| 164 | (defface shr-abbreviation | ||
| 165 | '((t :inherit underline :underline (:style wave))) | ||
| 166 | "Face for <abbr> elements." | ||
| 167 | :version "27.1" | ||
| 168 | :group 'shr) | ||
| 169 | |||
| 164 | (defvar shr-inhibit-images nil | 170 | (defvar shr-inhibit-images nil |
| 165 | "If non-nil, inhibit loading images.") | 171 | "If non-nil, inhibit loading images.") |
| 166 | 172 | ||
| @@ -1472,6 +1478,21 @@ ones, in case fg and bg are nil." | |||
| 1472 | (when url | 1478 | (when url |
| 1473 | (shr-urlify (or shr-start start) (shr-expand-url url) title)))) | 1479 | (shr-urlify (or shr-start start) (shr-expand-url url) title)))) |
| 1474 | 1480 | ||
| 1481 | (defun shr-tag-abbr (dom) | ||
| 1482 | (when-let* ((title (dom-attr dom 'title)) | ||
| 1483 | (start (point))) | ||
| 1484 | (shr-generic dom) | ||
| 1485 | (shr-add-font start (point) 'shr-abbreviation) | ||
| 1486 | (add-text-properties | ||
| 1487 | start (point) | ||
| 1488 | (list | ||
| 1489 | 'help-echo title | ||
| 1490 | 'mouse-face 'highlight)))) | ||
| 1491 | |||
| 1492 | (defun shr-tag-acronym (dom) | ||
| 1493 | ;; `acronym' is deprecated in favor of `abbr'. | ||
| 1494 | (shr-tag-abbr dom)) | ||
| 1495 | |||
| 1475 | (defun shr-tag-object (dom) | 1496 | (defun shr-tag-object (dom) |
| 1476 | (unless shr-inhibit-images | 1497 | (unless shr-inhibit-images |
| 1477 | (let ((start (point)) | 1498 | (let ((start (point)) |