From dea24a8b93d63d21dfc353d77d0631806e84b28a Mon Sep 17 00:00:00 2001
From: bread <136384195+bbbreaddd@users.noreply.github.com>
Date: Mon, 26 Jan 2026 04:37:10 -0800
Subject: [PATCH] fix exact search (#4640)
* disable select all text when clicked
* fix exact match search
* small fixes
* improve fuzzy search
* ignore invisible characters in search
* feature to navigate and scroll multiple search results in the same section
* add keyboard shortcut for highlight matches and also combine nearby highlighted matches
* comments
---------
Co-authored-by: nbats <44333466+nbats@users.noreply.github.com>
---
docs/.vitepress/constants.ts | 14 +-
.../theme/components/VPLocalSearchBox.vue | 457 ++++++++++++++++--
docs/ai.md | 4 +-
docs/audio.md | 4 +-
docs/educational.md | 2 +-
docs/mobile.md | 2 +-
docs/social-media-tools.md | 2 +-
scripts/lint-markdown.js | 40 +-
8 files changed, 456 insertions(+), 69 deletions(-)
diff --git a/docs/.vitepress/constants.ts b/docs/.vitepress/constants.ts
index 108d4359d..10e73e887 100644
--- a/docs/.vitepress/constants.ts
+++ b/docs/.vitepress/constants.ts
@@ -66,11 +66,11 @@ export const search: DefaultTheme.Config['search'] = {
_render(src, env, md) {
// Check if current file should be excluded from search
const relativePath = env.relativePath || env.path || ''
- const shouldExclude = excluded.some(excludedFile =>
- relativePath.includes(excludedFile) ||
+ const shouldExclude = excluded.some(excludedFile =>
+ relativePath.includes(excludedFile) ||
relativePath.endsWith(excludedFile)
)
-
+
// Return empty content for excluded files so they don't appear in search
if (shouldExclude) {
return ''
@@ -86,7 +86,7 @@ export const search: DefaultTheme.Config['search'] = {
},
miniSearch: {
options: {
- tokenize: (text) => text.split(/[\n\r #%*,=/:;?[\]{}()&]+/u), // simplified charset: removed [-_.@] and non-english chars (diacritics etc.)
+ tokenize: (text) => text.replace(/[\u2060\u200B]/g, '').split(/[\n\r #%*,=/:;?[\]{}()&]+/u), // simplified charset: removed [-_.@] and non-english chars (diacritics etc.)
processTerm: (term, fieldName) => {
// biome-ignore lint/style/noParameterAssign: h
term = term
@@ -319,9 +319,9 @@ export const sidebar: DefaultTheme.Sidebar | DefaultTheme.NavItemWithLink[] = [
items: [
meta.build.nsfw
? {
- text: ' NSFW',
- link: 'https://rentry.org/NSFW-Checkpoint'
- }
+ text: ' NSFW',
+ link: 'https://rentry.org/NSFW-Checkpoint'
+ }
: {},
{
text: ' Unsafe Sites',
diff --git a/docs/.vitepress/theme/components/VPLocalSearchBox.vue b/docs/.vitepress/theme/components/VPLocalSearchBox.vue
index 6592f0612..a29a82027 100644
--- a/docs/.vitepress/theme/components/VPLocalSearchBox.vue
+++ b/docs/.vitepress/theme/components/VPLocalSearchBox.vue
@@ -1,4 +1,28 @@