Skip to content

fix(search): ignore accents when matching - #845

Draft
SebastienSyd wants to merge 1 commit into
cooklang:mainfrom
snicot:fix/search-ignore-accents
Draft

SebastienSyd wants to merge 1 commit into
cooklang:mainfrom
snicot:fix/search-ignore-accents

Conversation

@SebastienSyd

Copy link
Copy Markdown

Fixes #844: search treats accented letters as different letters, so crepes misses Crêpes.cook in cook 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 and cooklang-find is bumped in both Cargo.toml and crates/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 with cooklang_find::normalize_for_search instead of to_lowercase(). Using the library's own function keeps the invariant documented on matches_every_term: the AND filter can't drop a recipe the library matched.
  • static/js/search.js (static cook build sites): the same fold in the browser, via toLowerCase().normalize("NFD").replace(/\p{M}/gu, "").
  • Module docs now say matching ignores accents as well as case.

Tests

  • New 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 --check and cargo 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) and update::tests::release_workflow_builds_this_platform (aarch64 Linux isn't in the release matrix).

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search does not ignore accents: crepes misses Crêpes

1 participant