1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

All: Search: More multi-language support, and started updating mobile app

This commit is contained in:
Laurent Cozic
2019-01-18 18:31:07 +00:00
parent 8fdc0bf17c
commit 42a674008f
6 changed files with 14 additions and 49 deletions

View File

@ -10,46 +10,23 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
const isBasicSearch = ['ja', 'zh', 'ko'].indexOf(keyword.scriptType) >= 0;
let value = keyword.value;
let accuracy = keyword.accuracy ? keyword.accuracy : 'exactly';
let accuracy = keyword.accuracy ? keyword.accuracy : { value: 'exactly', limiters: ":;.,-–—‒_(){}[]!'\"+=".split("") };
if (isBasicSearch) accuracy = 'partially';
if (keyword.type === 'regex') {
accuracy = 'complementary';
value = keyword.originalValue.substr(0, keyword.originalValue.length - 1);
// Remove the trailing wildcard and "accuracy = complementary" will take care of
// highlighting the relevant keywords.
// Known bug: it will also highlight word that contain the term as a suffix for example for "ent*", it will highlight "present"
// which is incorrect (it should only highlight what starts with "ent") but for now will do. Mark.js doesn't have an option
// to tweak this behaviour.
value = keyword.value.substr(0, keyword.value.length - 1);
}
mark.mark([value], Object.assign({}, {
accuracy: accuracy,
}, extraOptions));
// if (keyword.type === 'regex') {
// const b = '[' + stringUtils.pregQuote(' \t\n\r,.,+-*?!={}<>|:"\'()[]') + ']+';
// // The capturing groups are a hack to go around the strange behaviour of the ignoreGroups property. What we want is to
// // exclude the first and last matches (the boundaries). What ignoreGroups does is ignore the first X groups. So
// // we put the first boundary and the keyword inside a group, that way the first groups is ignored (ignoreGroups = 1)
// // the second is included. And the last boundary is dropped because it's not in any group (it's important NOT to
// // put this one in a group because otherwise it cannot be excluded).
// let regexString = '(' + b + ')' + '(' + stringUtils.replaceRegexDiacritics(keyword.value) + ')' + b;
// if (isBasicSearch) regexString = keyword.value;
// mark.markRegExp(new RegExp(regexString, 'gmi'), Object.assign({
// acrossElements: true,
// ignoreGroups: 1,
// }, extraOptions));
// } else {
// let accuracy = keyword.accuracy ? keyword.accuracy : 'exactly';
// if (isBasicSearch) accuracy = 'partially';
// mark.mark([keyword.value], Object.assign({}, {
// accuracy: accuracy,
// }, extraOptions));
// }
}
if (typeof module !== 'undefined') {