From 13d59bc1742279d7b1c614cd45c0499f5da104f4 Mon Sep 17 00:00:00 2001
From: Joe Nelson
Date: Thu, 17 Jun 2021 15:03:34 -0500
Subject: [PATCH] Provide more semantic structure for screen-readers
https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA12
---
sphinx/writers/html.py | 2 +-
sphinx/writers/html5.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py
index d633f07e8e0..e9a31a848ca 100644
--- a/sphinx/writers/html.py
+++ b/sphinx/writers/html.py
@@ -415,7 +415,7 @@ def depart_term(self, node: Element) -> None:
# overwritten
def visit_title(self, node: Element) -> None:
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
- self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
+ self.body.append(self.starttag(node, 'p', '', CLASS='caption', ROLE='heading'))
self.body.append('')
self.context.append('
\n')
else:
diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py
index 4696425910b..5b38b3be281 100644
--- a/sphinx/writers/html5.py
+++ b/sphinx/writers/html5.py
@@ -366,7 +366,7 @@ def depart_term(self, node: Element) -> None:
# overwritten
def visit_title(self, node: Element) -> None:
if isinstance(node.parent, addnodes.compact_paragraph) and node.parent.get('toctree'):
- self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
+ self.body.append(self.starttag(node, 'p', '', CLASS='caption', ROLE='heading'))
self.body.append('')
self.context.append('\n')
else: