mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Support search with or without diacritics (bug 1508345, bug 916883, bug 1651113)
- get original index in using a dichotomic seach instead of a linear one; - normalize the text in using NFD; - convert the query string into a RegExp; - replace whitespaces in the query with \s+; - handle hyphens at eol use to break a word; - add some \s* around punctuation signs
This commit is contained in:
parent
70073ed81c
commit
1f41028fcb
12 changed files with 604 additions and 172 deletions
|
@ -227,8 +227,8 @@ function removeNullCharacters(str, replaceInvisible = false) {
|
|||
* @returns {number} Index of the first array element to pass the test,
|
||||
* or |items.length| if no such element exists.
|
||||
*/
|
||||
function binarySearchFirstItem(items, condition) {
|
||||
let minIndex = 0;
|
||||
function binarySearchFirstItem(items, condition, start = 0) {
|
||||
let minIndex = start;
|
||||
let maxIndex = items.length - 1;
|
||||
|
||||
if (maxIndex < 0 || !condition(items[maxIndex])) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue