فهرست منبع

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 2 سال پیش
والد
کامیت
628a83eaef
1فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 12 1
      kernel/search/mark.go

+ 12 - 1
kernel/search/mark.go

@@ -18,10 +18,12 @@ package search
 
 
 import (
 import (
 	"fmt"
 	"fmt"
+	"github.com/88250/gulu"
 	"regexp"
 	"regexp"
 	"strings"
 	"strings"
 	"unicode/utf8"
 	"unicode/utf8"
 
 
+	"github.com/88250/lute/lex"
 	"github.com/siyuan-note/siyuan/kernel/util"
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 )
 
 
@@ -86,8 +88,17 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
 	}
 	}
 	re := ic + "("
 	re := ic + "("
 	for i, k := range keywords {
 	for i, k := range keywords {
+		wordBoundary := lex.IsASCIILetterNums(gulu.Str.ToBytes(k)) // Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
 		k = regexp.QuoteMeta(k)
 		k = regexp.QuoteMeta(k)
-		re += "(" + k + ")"
+		re += "("
+		if wordBoundary {
+			re += "\\b"
+		}
+		re += k
+		if wordBoundary {
+			re += "\\b"
+		}
+		re += ")"
 		if i < len(keywords)-1 {
 		if i < len(keywords)-1 {
 			re += "|"
 			re += "|"
 		}
 		}