From b56b24a1a40fdce7746ff0f81570b29c83309c12 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Tue, 7 Aug 2018 20:40:56 -0400 Subject: [PATCH] Optionally skip rendering of 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. * etc/NEWS: Announce shr-discard-aria-hidden. --- etc/NEWS | 2 ++ lisp/net/shr.el | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 2825bb9f59..068c48cabc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -363,6 +363,8 @@ 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'. + ** Htmlfontify *** The functions 'hfy-color', 'hfy-color-vals' and diff --git a/lisp/net/shr.el b/lisp/net/shr.el index edea7cb297..2599c3c727 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -68,6 +68,12 @@ shr-use-fonts :group 'shr :type 'boolean) +(defcustom shr-discard-aria-hidden nil + "If non-nil, don't render tags with `aria-hidden=true' attribute." + :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 +515,9 @@ shr-descend 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 -- 2.11.0