aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-08-07 20:40:56 -0400
committerNoam Postavsky2018-08-27 19:16:47 -0400
commit0250d22eeb8427cb87c58f528f337dc83d0419a5 (patch)
tree13185fd4551b6034a1fe3f6f2c10af54b99d6c7f
parentc8b86362d45a07e0aec0041cade551c3c663ea8c (diff)
downloademacs-0250d22eeb8427cb87c58f528f337dc83d0419a5.tar.gz
emacs-0250d22eeb8427cb87c58f528f337dc83d0419a5.zip
shr: Allow skipping tags with aria-hidden (Bug#32348)
* lisp/net/shr.el (shr-discard-aria-hidden): New option. (shr-descend): Suppress aria-hidden=true tags if it's set. * doc/misc/eww.texi (Advanced): Document shr-discard-aria-hidden. * etc/NEWS: Announce it.
-rw-r--r--doc/misc/eww.texi10
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/shr.el11
3 files changed, 25 insertions, 1 deletions
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index 43adc2eda0f..aa17eee9d94 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -262,6 +262,16 @@ contrast. If that is still too low for you, you can customize the
262variables @code{shr-color-visible-distance-min} and 262variables @code{shr-color-visible-distance-min} and
263@code{shr-color-visible-luminance-min} to get a better contrast. 263@code{shr-color-visible-luminance-min} to get a better contrast.
264 264
265@vindex shr-discard-aria-hidden
266@cindex @code{aria-hidden}, HTML attribute
267 The HTML attribute @code{aria-hidden} is meant to tell screen
268readers to ignore a tag's contents. You can customize the variable
269@code{shr-discard-aria-hidden} to tell @code{shr} to ignore such tags.
270This can be useful when using a screen reader on the output of
271@code{shr} (e.g., on EWW buffer text). It can be useful even when not
272using a screen reader, since web authors often put this attribute on
273non-essential decorative elements.
274
265@cindex Desktop Support 275@cindex Desktop Support
266@cindex Saving Sessions 276@cindex Saving Sessions
267 In addition to maintaining the history at run-time, EWW will also 277 In addition to maintaining the history at run-time, EWW will also
diff --git a/etc/NEWS b/etc/NEWS
index d757f52466a..4fc02e8f2a4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -405,6 +405,11 @@ and its value has been changed to Duck Duck Go.
405'shr-selected-link' face to give the user feedback that the command 405'shr-selected-link' face to give the user feedback that the command
406has been executed. 406has been executed.
407 407
408+++
409*** New option 'shr-discard-aria-hidden'.
410If set, shr will not render tags with attribute 'aria-hidden="true"'.
411This attribute is meant to tell screen readers to ignore a tag.
412
408** Htmlfontify 413** Htmlfontify
409 414
410*** The functions 'hfy-color', 'hfy-color-vals' and 415*** The functions 'hfy-color', 'hfy-color-vals' and
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index edea7cb297c..bc86fe5a383 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -68,6 +68,13 @@ fit these criteria."
68 :group 'shr 68 :group 'shr
69 :type 'boolean) 69 :type 'boolean)
70 70
71(defcustom shr-discard-aria-hidden nil
72 "If non-nil, don't render tags with `aria-hidden=\"true\"'.
73This attribute is meant to tell screen readers to ignore a tag."
74 :version "27.1"
75 :group 'shr
76 :type 'boolean)
77
71(defcustom shr-use-colors t 78(defcustom shr-use-colors t
72 "If non-nil, respect color specifications in the HTML." 79 "If non-nil, respect color specifications in the HTML."
73 :version "26.1" 80 :version "26.1"
@@ -509,7 +516,9 @@ size, and full-buffer size."
509 shr-stylesheet)) 516 shr-stylesheet))
510 (setq style nil))) 517 (setq style nil)))
511 ;; If we have a display:none, then just ignore this part of the DOM. 518 ;; If we have a display:none, then just ignore this part of the DOM.
512 (unless (equal (cdr (assq 'display shr-stylesheet)) "none") 519 (unless (or (equal (cdr (assq 'display shr-stylesheet)) "none")
520 (and shr-discard-aria-hidden
521 (equal (dom-attr dom 'aria-hidden) "true")))
513 ;; We don't use shr-indirect-call here, since shr-descend is 522 ;; We don't use shr-indirect-call here, since shr-descend is
514 ;; the central bit of shr.el, and should be as fast as 523 ;; the central bit of shr.el, and should be as fast as
515 ;; possible. Having one more level of indirection with its 524 ;; possible. Having one more level of indirection with its