Repository navigation
fix(search): ignore accents when matching - #845
Draft
SebastienSyd wants to merge 1 commit into
Draft
SebastienSyd wants to merge 1 commit into
SebastienSyd wants to merge 1 commit into
Conversation
Fold terms, file stems and contents with `cooklang_find::normalize_for_search`, the same function the library scores with, so the AND filter keeps the recipes `cooklang-find` now matches without accents. Fold the same way in the static site's `search.js`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #844: search treats accented letters as different letters, so
crepesmissesCrêpes.cookincook search,/api/search, the header dropdown and/search.Draft, depends on cooklang/cooklang-find#41. This uses
cooklang_find::normalize_for_search, which only exists on that branch, so CI won't compile until it's released andcooklang-findis bumped in bothCargo.tomlandcrates/core/Cargo.toml. I'll push the bump here once there's a version.Change
crates/core/src/search.rs: terms, file stems and contents are folded withcooklang_find::normalize_for_searchinstead ofto_lowercase(). Using the library's own function keeps the invariant documented onmatches_every_term: the AND filter can't drop a recipe the library matched.static/js/search.js(staticcook buildsites): the same fold in the browser, viatoLowerCase().normalize("NFD").replace(/\p{M}/gu, "").Tests
terms_match_regardless_of_accents: an unaccented term finds an accented file name, unaccented terms find accented contents (ANDed), and an accented term finds unaccented text.Run locally against the cooklang-find branch through a temporary
[patch.crates-io](not committed):cargo fmt --all --checkandcargo clippy --all-targets -- -D warnings: clean.cargo test: all search, server and API tests pass. Three tests failed, and all three are environment-specific: two pantry permission tests (the run was as root, as noted in CLAUDE.md) andupdate::tests::release_workflow_builds_this_platform(aarch64 Linux isn't in the release matrix).🤖 Generated with Claude Code