]> _ Git - fluidbook-html5.git/commitdiff
wip #6188 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Sep 2023 13:46:49 +0000 (15:46 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 14 Sep 2023 13:46:49 +0000 (15:46 +0200)
js/libs/fluidbook/fluidbook.search.js

index 96b17fae0dc64bbd1e1bb1f5702826b1badf940a..b4b11e950436bfc025a4f8a55265701ee12eeccd 100644 (file)
@@ -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) {