Skip to content

Commit 6919a8a

Browse files
authored
Restore search snippet highlights in search results page (#1678)
1 parent 115343c commit 6919a8a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
{% include "sections/sidebar-primary.html" %}
9090
</div>
9191
{# Using an ID here so that the skip-link works #}
92-
<main id="main-content" class="bd-main">
92+
<main id="main-content" class="bd-main" role="main">
9393
{# Main content area #}
9494
{% block docs_main %}
9595
<div class="bd-content">

tests/test_build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,3 +1164,12 @@ def test_render_secondary_sidebar_dict_multiple_glob_matches(
11641164
assert not sphinx_build.html_tree("section1/index.html").select("div.sourcelink")
11651165
assert sphinx_build.html_tree("section2/index.html").select("div.sourcelink")
11661166
assert sphinx_build.html_tree("section2/page1.html").select("div.sourcelink")
1167+
1168+
1169+
def test_role_main_for_search_highlights(sphinx_build_factory):
1170+
"""Sphinx searchtools.js looks for [role="main"], so make sure it's there.
1171+
1172+
This is a regression test. See #1676.
1173+
"""
1174+
sphinx_build = sphinx_build_factory("base").build()
1175+
assert sphinx_build.html_tree("index.html").select_one('[role="main"]')

0 commit comments

Comments
 (0)