From: Vincent Vanwaelscappel Date: Thu, 14 Sep 2023 13:46:49 +0000 (+0200) Subject: wip #6188 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=63102f3136a389e834b4f2cd52be89adf8c64d40;p=fluidbook-html5.git wip #6188 @1 --- diff --git a/js/libs/fluidbook/fluidbook.search.js b/js/libs/fluidbook/fluidbook.search.js index 96b17fae..b4b11e95 100644 --- a/js/libs/fluidbook/fluidbook.search.js +++ b/js/libs/fluidbook/fluidbook.search.js @@ -503,6 +503,7 @@ FluidbookSearch.prototype = { q = q.replace(/\s+/g, ' '); if (removeSpaces) { q = q.replace(/\s+/g, ''); + q = this.removeSpaceAndPoints(q); } q = q.toLowerCase(); if (split) { @@ -561,6 +562,8 @@ FluidbookSearch.prototype = { setRobustHighlightTerms: function (terms) { let term = terms.join(''); + term = this.removeSpaceAndPoints(term); + console.log(term); let letters = term.split(''); let occurences = []; @@ -598,6 +601,15 @@ FluidbookSearch.prototype = { } }, + removeSpaceAndPoints: function (str) { + str = str.replace(/[-\/_]/g, ""); + str = str.replace(/[』『「」!?。。。」﹂”』’》)]}〕〗〙〛〉】"#$%&'()*+,-/:;<=>@[\]^_`{|}~⦅⦆「」、 、〃〈〉《》【】〕〔〗〖〙〘〛〚〜〞〝〟〰〾〿–—‘’“‛”„‟…‧﹏﹑﹔·〇一。]/g, ""); + str = str.replace(/[\u2000-\u20ff\u2122\x21-\x2f\x3a-\x3f\x5b-\x60\x7b-\xa0\xaa-\xbf]/g, ""); + str = str.replace(/\\p{Cc}/g, ""); + str = str.replace(/\\p{Whitespace}/g, ""); + return str; + }, + clearHighlights: function () { $("#searchHighlights").html(''); for (var p in this.plugins) {