You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
More search engine improvements
This commit is contained in:
@ -242,6 +242,54 @@ function surroundKeywords(keywords, text, prefix, suffix) {
|
||||
return text.replace(re, prefix + '$1' + suffix);
|
||||
}
|
||||
|
||||
function replaceRegexDiacritics(regexString) {
|
||||
if (!regexString) return '';
|
||||
|
||||
const diacriticReplacements = {
|
||||
'a': '[aàáâãäåāą]',
|
||||
'A': '[AÀÁÂÃÄÅĀĄ]',
|
||||
'c': '[cçćč]',
|
||||
'C': '[CÇĆČ]',
|
||||
'd': '[dđď]',
|
||||
'D': '[DĐĎ]',
|
||||
'e': '[eèéêëěēę]',
|
||||
'E': '[EÈÉÊËĚĒĘ]',
|
||||
'i': '[iìíîïī]',
|
||||
'I': '[IÌÍÎÏĪ]',
|
||||
'l': '[lł]',
|
||||
'L': '[LŁ]',
|
||||
'n': '[nñňń]',
|
||||
'N': '[NÑŇŃ]',
|
||||
'o': '[oòóôõöøō]',
|
||||
'O': '[OÒÓÔÕÖØŌ]',
|
||||
'r': '[rř]',
|
||||
'R': '[RŘ]',
|
||||
's': '[sšś]',
|
||||
'S': '[SŠŚ]',
|
||||
't': '[tť]',
|
||||
'T': '[TŤ]',
|
||||
'u': '[uùúûüůū]',
|
||||
'U': '[UÙÚÛÜŮŪ]',
|
||||
'y': '[yÿý]',
|
||||
'Y': '[YŸÝ]',
|
||||
'z': '[zžżź]',
|
||||
'Z': '[ZŽŻŹ]',
|
||||
};
|
||||
|
||||
let output = '';
|
||||
for (let i = 0; i < regexString.length; i++) {
|
||||
let c = regexString[i];
|
||||
const r = diacriticReplacements[c];
|
||||
if (r) {
|
||||
output += r;
|
||||
} else {
|
||||
output += c;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
const REGEX_JAPANESE = /[\u3000-\u303f]|[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff00-\uff9f]|[\u4e00-\u9faf]|[\u3400-\u4dbf]/;
|
||||
const REGEX_CHINESE = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]|[\uf900-\ufaff]|[\u{2f800}-\u{2fa1f}]/u;
|
||||
const REGEX_KOREAN = /[\uac00-\ud7af]|[\u1100-\u11ff]|[\u3130-\u318f]|[\ua960-\ua97f]|[\ud7b0-\ud7ff]/;
|
||||
@ -253,4 +301,4 @@ function scriptType(s) {
|
||||
return 'en';
|
||||
}
|
||||
|
||||
module.exports = { removeDiacritics, escapeFilename, wrap, splitCommandString, padLeft, toTitleCase, urlDecode, escapeHtml, pregQuote, surroundKeywords, scriptType };
|
||||
module.exports = { removeDiacritics, escapeFilename, wrap, splitCommandString, padLeft, toTitleCase, urlDecode, escapeHtml, pregQuote, surroundKeywords, scriptType, replaceRegexDiacritics };
|
||||
|
Reference in New Issue
Block a user