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

First pass at linting lib dir

This commit is contained in:
Laurent Cozic
2019-07-29 15:43:53 +02:00
parent 64b7bc3d62
commit 86dc72b204
170 changed files with 4140 additions and 3119 deletions

View File

@ -1,4 +1,4 @@
const markJsUtils = {}
const markJsUtils = {};
markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
if (typeof keyword === 'string') {
@ -11,24 +11,31 @@ 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 : { value: 'exactly', limiters: ":;.,-–—‒_(){}[]!'\"+=".split("") };
let accuracy = keyword.accuracy ? keyword.accuracy : { value: 'exactly', limiters: ':;.,-–—‒_(){}[]!\'"+='.split('') };
if (isBasicSearch) accuracy = 'partially';
if (keyword.type === 'regex') {
accuracy = 'complementary';
// 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));
}
mark.mark(
[value],
Object.assign(
{},
{
accuracy: accuracy,
},
extraOptions
)
);
};
if (typeof module !== 'undefined') {
module.exports = markJsUtils;
}
}