From 63d0cff1159d6d40ed867263abee409568f73d29 Mon Sep 17 00:00:00 2001 From: ChrisLovering Date: Thu, 26 Oct 2023 13:31:58 +0000 Subject: Deploying to docs from @ python-discord/bot-core@ee2501e36aa4cb6e809de9873e3d607bdf3309db 🚀 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v8.0.0/_static/sphinx_highlight.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'v8.0.0/_static/sphinx_highlight.js') diff --git a/v8.0.0/_static/sphinx_highlight.js b/v8.0.0/_static/sphinx_highlight.js index aae669d7..8a96c69a 100644 --- a/v8.0.0/_static/sphinx_highlight.js +++ b/v8.0.0/_static/sphinx_highlight.js @@ -29,14 +29,19 @@ const _highlight = (node, addItems, text, className) => { } span.appendChild(document.createTextNode(val.substr(pos, text.length))); + const rest = document.createTextNode(val.substr(pos + text.length)); parent.insertBefore( span, parent.insertBefore( - document.createTextNode(val.substr(pos + text.length)), + rest, node.nextSibling ) ); node.nodeValue = val.substr(0, pos); + /* There may be more occurrences of search term in this node. So call this + * function recursively on the remaining fragment. + */ + _highlight(rest, addItems, text, className); if (isInSVG) { const rect = document.createElementNS( @@ -140,5 +145,10 @@ const SphinxHighlight = { }, }; -_ready(SphinxHighlight.highlightSearchWords); -_ready(SphinxHighlight.initEscapeListener); +_ready(() => { + /* Do not call highlightSearchWords() when we are on the search page. + * It will highlight words from the *previous* search query. + */ + if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords(); + SphinxHighlight.initEscapeListener(); +}); -- cgit v1.2.3