Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added prefix matching in search #2375

Merged
merged 18 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b858db5
- Changed LunrJs to MinisearchJs for client-side search
Hetarth02 Jul 5, 2023
34303e0
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl i…
Hetarth02 Jul 16, 2023
1fb8e07
- Updated the duplication issue
Hetarth02 Jul 16, 2023
724bd89
- Corrected typo
Hetarth02 Jul 16, 2023
bb1dbc4
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Aug 24, 2023
defe107
New Search Modal UI (#2202)
Hetarth02 Aug 24, 2023
f32d6de
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Aug 24, 2023
984ef8c
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Sep 26, 2023
149bdd0
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Oct 15, 2023
24d8a5f
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 4, 2023
60ca700
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 10, 2023
be00b02
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 13, 2023
b2feabd
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 13, 2023
85828de
Merge branch 'JuliaDocs:master' into master
Hetarth02 Dec 10, 2023
5084cb2
- Added prefix search
Hetarth02 Dec 10, 2023
ef2d399
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl i…
Hetarth02 Jan 19, 2024
7914758
- Removed changelog extra content due to EOL (End of line) mismatch
Hetarth02 Jan 19, 2024
a00881b
update CHANGELOG
mortenpi Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Unreleased

### Changed

* The search in the HTML output now prioritizes prefix matches. ([#2203], [#2375])

## Version [v1.2.1] - 2023-12-02

### Fixed
Expand Down Expand Up @@ -1721,6 +1727,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2191]: https://github.com/JuliaDocs/Documenter.jl/issues/2191
[#2194]: https://github.com/JuliaDocs/Documenter.jl/issues/2194
[#2202]: https://github.com/JuliaDocs/Documenter.jl/issues/2202
[#2203]: https://github.com/JuliaDocs/Documenter.jl/issues/2203
[#2205]: https://github.com/JuliaDocs/Documenter.jl/issues/2205
[#2211]: https://github.com/JuliaDocs/Documenter.jl/issues/2211
[#2213]: https://github.com/JuliaDocs/Documenter.jl/issues/2213
Expand Down Expand Up @@ -1765,6 +1772,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2348]: https://github.com/JuliaDocs/Documenter.jl/issues/2348
[#2364]: https://github.com/JuliaDocs/Documenter.jl/issues/2364
[#2365]: https://github.com/JuliaDocs/Documenter.jl/issues/2365
[#2375]: https://github.com/JuliaDocs/Documenter.jl/issues/2375
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
[JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841
Expand Down
7 changes: 4 additions & 3 deletions assets/html/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ let index = new minisearch({
tokenize: (string) => string.split(/[\s\-\.]+/),
// options which will be applied during the search
searchOptions: {
prefix: true,
boost: { title: 100 },
fuzzy: 2,
processTerm: (term) => {
Expand Down Expand Up @@ -322,7 +323,7 @@ function make_search_result(result, querystring) {
display_link += ` (${result.page})`;
}

let textindex = new RegExp(`\\b${querystring}\\b`, "i").exec(result.text);
let textindex = new RegExp(`${querystring}`, "i").exec(result.text);
let text =
textindex !== null
? result.text.slice(
Expand All @@ -337,8 +338,8 @@ function make_search_result(result, querystring) {
let display_result = text.length
? "..." +
text.replace(
new RegExp(`\\b${querystring}\\b`, "i"), // For first occurrence
'<span class="search-result-highlight p-1">$&</span>'
new RegExp(`${querystring}`, "i"), // For first occurrence
'<span class="search-result-highlight py-1">$&</span>'
) +
"..."
: ""; // highlights the match
Expand Down
Loading