]> git.eshelyaron.com Git - emacs.git/commitdiff
shr: Allow skipping tags with aria-hidden (Bug#32348)
authorNoam Postavsky <npostavs@gmail.com>
Wed, 8 Aug 2018 00:40:56 +0000 (20:40 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Mon, 27 Aug 2018 23:16:47 +0000 (19:16 -0400)
* 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.

doc/misc/eww.texi
etc/NEWS
lisp/net/shr.el

index 43adc2eda0f141f5f40dd902db5578bbd6f8a3ed..aa17eee9d9405bcc8180fd4054dd458f41eaa587 100644 (file)
@@ -262,6 +262,16 @@ contrast.  If that is still too low for you, you can customize the
 variables @code{shr-color-visible-distance-min} and
 @code{shr-color-visible-luminance-min} to get a better contrast.
 
+@vindex shr-discard-aria-hidden
+@cindex @code{aria-hidden}, HTML attribute
+  The HTML attribute @code{aria-hidden} is meant to tell screen
+readers to ignore a tag's contents.  You can customize the variable
+@code{shr-discard-aria-hidden} to tell @code{shr} to ignore such tags.
+This can be useful when using a screen reader on the output of
+@code{shr} (e.g., on EWW buffer text).  It can be useful even when not
+using a screen reader, since web authors often put this attribute on
+non-essential decorative elements.
+
 @cindex Desktop Support
 @cindex Saving Sessions
   In addition to maintaining the history at run-time, EWW will also
index d757f52466a1006f0851011b72e6bda3e07fca4a..4fc02e8f2a4e07ae8b2b4067f5fcf58dab447df1 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -405,6 +405,11 @@ and its value has been changed to Duck Duck Go.
 'shr-selected-link' face to give the user feedback that the command
 has been executed.
 
++++
+*** New option 'shr-discard-aria-hidden'.
+If set, shr will not render tags with attribute 'aria-hidden="true"'.
+This attribute is meant to tell screen readers to ignore a tag.
+
 ** Htmlfontify
 
 *** The functions 'hfy-color', 'hfy-color-vals' and
index edea7cb297c328ef599af6d5c5abb5a7fe00da6a..bc86fe5a383a11c8dffcbd801b24bfdb20ba78dd 100644 (file)
@@ -68,6 +68,13 @@ fit these criteria."
   :group 'shr
   :type 'boolean)
 
+(defcustom shr-discard-aria-hidden nil
+  "If non-nil, don't render tags with `aria-hidden=\"true\"'.
+This attribute is meant to tell screen readers to ignore a tag."
+  :version "27.1"
+  :group 'shr
+  :type 'boolean)
+
 (defcustom shr-use-colors t
   "If non-nil, respect color specifications in the HTML."
   :version "26.1"
@@ -509,7 +516,9 @@ size, and full-buffer size."
                                        shr-stylesheet))
          (setq style nil)))
       ;; If we have a display:none, then just ignore this part of the DOM.
-      (unless (equal (cdr (assq 'display shr-stylesheet)) "none")
+      (unless (or (equal (cdr (assq 'display shr-stylesheet)) "none")
+                  (and shr-discard-aria-hidden
+                       (equal (dom-attr dom 'aria-hidden) "true")))
         ;; We don't use shr-indirect-call here, since shr-descend is
         ;; the central bit of shr.el, and should be as fast as
         ;; possible.  Having one more level of indirection with its