Skip to content

Commit

Permalink
Allow ?highlight=...
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 24, 2022
1 parent 70f9a6b commit 1a56dfa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sphinx/themes/basic/static/sphinx_highlight.js
Expand Up @@ -76,9 +76,16 @@ const SphinxHighlight = {
if (!SPHINX_HIGHLIGHT_ENABLED) return; // bail if no highlight

// get and clear terms from localstorage
const highlight = localStorage.getItem("sphinx_highlight_terms") || "";
const url = new URL(window.location);
const highlight =
localStorage.getItem("sphinx_highlight_terms")
|| url.searchParams.get("highlight")
|| "";
localStorage.removeItem("sphinx_highlight_terms")
url.searchParams.delete("highlight");
window.history.replaceState({}, "", url);

// get individual terms from highlight string
const terms = highlight.toLowerCase().split(/\s+/).filter(x => x);
if (terms.length === 0) return; // nothing to do

Expand Down

0 comments on commit 1a56dfa

Please sign in to comment.