diff options
author | 2023-10-26 13:31:58 +0000 | |
---|---|---|
committer | 2023-10-26 13:31:58 +0000 | |
commit | 63d0cff1159d6d40ed867263abee409568f73d29 (patch) | |
tree | 4f8b1c1ae806944f8bcb778710098f7f6778336a /v8.1.0/_static/sphinx_highlight.js | |
parent | Deploying to docs from @ python-discord/bot-core@03575223498fa16ecec18ef39658... (diff) |
Deploying to docs from @ python-discord/bot-core@ee2501e36aa4cb6e809de9873e3d607bdf3309db 🚀
Diffstat (limited to 'v8.1.0/_static/sphinx_highlight.js')
-rw-r--r-- | v8.1.0/_static/sphinx_highlight.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/v8.1.0/_static/sphinx_highlight.js b/v8.1.0/_static/sphinx_highlight.js index aae669d7..8a96c69a 100644 --- a/v8.1.0/_static/sphinx_highlight.js +++ b/v8.1.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(); +}); |