Skip to content

feat: add ignoreDiacritics option for accent-insensitive matching - #898

Closed
tkirda wants to merge 1 commit into
masterfrom
feat/ignore-diacritics
Closed

tkirda wants to merge 1 commit into
masterfrom
feat/ignore-diacritics

Conversation

@tkirda

@tkirda tkirda commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Closes #893.

What

New opt-in option ignoreDiacritics (default false). When true, the default lookupFilter and formatResult ignore accents, so typing cafe finds Café in a local lookup and the highlight wraps the original Café.

  • Folding is done one character at a time (NFD → strip combining marks → NFC → lowercase), with a map from folded text back to the source string. That keeps highlights on the original characters, including accents stored as separate combining marks.
  • Only diacritics are folded; ß is not treated as ss.
  • For Ajax lookups the server still decides what matches; the option only affects highlighting there.

API

formatResult and lookupFilter now receive the resolved options as an extra, optional last argument, so the defaults can read the flag. Existing custom callbacks and direct calls to the defaults are unaffected. The non-folding highlight path produces the same output as before.

Docs

README: new option row, updated callback signatures, and a Styling example for highlighting with <mark> instead of <strong> by wrapping the default formatter (the other half of #893).

Tests

9 new specs: off by default, filtering, highlighting, decomposed marks, repeated matches, ß, HTML escaping, a query that folds to nothing, and an end-to-end lookup.

🤖 Generated with Claude Code

Opt-in (default false). When on, the default lookupFilter and formatResult
fold case and strip combining marks per character, so "cafe" matches and
highlights "Café". A per-character fold map lets highlights wrap the original
accented text, including decomposed marks.

Both callbacks now also receive the resolved options (additive, optional
parameter) so the defaults can read the flag. The README documents the
option and a wrapper for highlighting with <mark> instead of <strong>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tkirda

tkirda commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

Closing in favour of README recipes (see #893): accent-insensitive filtering is a one-line custom lookupFilter, and a built-in option plus the callback signature change isn't worth the permanent API surface for one request. Branch feat/ignore-diacritics is kept in case highlighting of accent-folded matches is requested again.

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.

Allow more customizations of formatResult()

2 participants