🎨 Improve virtual reference split words https://github.com/siyuan-note/siyuan/issues/7833
This commit is contained in:
parent
8545454f74
commit
ed3fe917e5
1 changed files with 12 additions and 1 deletions
|
@ -18,10 +18,12 @@ package search
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/88250/gulu"
|
||||
"regexp"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/88250/lute/lex"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
|
@ -86,8 +88,17 @@ func EncloseHighlighting(text string, keywords []string, openMark, closeMark str
|
|||
}
|
||||
re := ic + "("
|
||||
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)
|
||||
re += "(" + k + ")"
|
||||
re += "("
|
||||
if wordBoundary {
|
||||
re += "\\b"
|
||||
}
|
||||
re += k
|
||||
if wordBoundary {
|
||||
re += "\\b"
|
||||
}
|
||||
re += ")"
|
||||
if i < len(keywords)-1 {
|
||||
re += "|"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue