Skip to content

Commit

Permalink
[search] constraint retrieval for anchored search result summary (#12105
Browse files Browse the repository at this point in the history
)

This is a post-merge adjustments for #11944.
  • Loading branch information
jayaddison committed Mar 16, 2024
1 parent 16748ae commit 6aaeee2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sphinx/themes/basic/static/searchtools.js
Expand Up @@ -164,11 +164,11 @@ const Search = {
const htmlElement = new DOMParser().parseFromString(htmlString, 'text/html');
htmlElement.querySelectorAll(".headerlink").forEach((el) => { el.remove() });
if (anchor) {
const anchorContent = htmlElement.querySelector(anchor);
const anchorContent = htmlElement.querySelector(`[role="main"] ${anchor}`);
if (anchorContent) return anchorContent.textContent;

console.warn(
`Anchor block not found. Sphinx search tries to obtain it via '${anchor}'. Check your theme or template.`
`Anchored content block not found. Sphinx search tries to obtain it via DOM query '[role=main] ${anchor}'. Check your theme or template.`
);
}

Expand All @@ -177,7 +177,7 @@ const Search = {
if (docContent) return docContent.textContent;

console.warn(
"Content block not found. Sphinx search tries to obtain it via '[role=main]'. Could you check your theme or template."
"Content block not found. Sphinx search tries to obtain it via DOM query '[role=main]'. Check your theme or template."
);
return "";
},
Expand Down

0 comments on commit 6aaeee2

Please sign in to comment.