diff options
| author | Adam Turner <9087854+aa-turner@users.noreply.github.com> | 2022-03-19 22:40:51 +0000 |
|---|---|---|
| committer | Adam Turner <9087854+aa-turner@users.noreply.github.com> | 2022-03-19 23:16:27 +0000 |
| commit | 61d7b0b47ce89d33d97b6f398bf7017ee3789c93 (patch) | |
| tree | 5b07c3aa4d75b1c6a77bd9019b79d479a86002d8 /sphinx/themes/basic | |
| parent | 09299b2237f77ca390bc04b3ce006733d0181c4b (diff) | |
| download | sphinx-git-61d7b0b47ce89d33d97b6f398bf7017ee3789c93.tar.gz | |
Replace `jssplitter` with JavaScript
Diffstat (limited to 'sphinx/themes/basic')
| -rw-r--r-- | sphinx/themes/basic/static/searchtools.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index 403718cd3..50473461d 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -13,7 +13,7 @@ /** * Simple result scoring code. */ -if (!Scorer) { +if (typeof Scorer === "undefined") { var Scorer = { // Implement the following function to further tweak the score for each result // The function takes a result array [docname, title, anchor, descr, score, filename] @@ -133,6 +133,20 @@ const _displayNextItem = ( }; /** + * Default splitQuery function. Can be overridden in ``sphinx.search`` with a + * custom function per language. + * + * The regular expression works by splitting the string on consecutive characters + * that are not Unicode letters, numbers, underscores, or emoji characters. + * This is the same as ``\W+`` in Python, preserving the surrogate pair area. + */ +if (typeof splitQuery === "undefined") { + var splitQuery = (query) => query + .split(/[^\p{Letter}\p{Number}_\p{Emoji_Presentation}]+/gu) + .filter(term => term) // remove remaining empty strings +} + +/** * Search Module */ const Search = { |
