mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 12:28:48 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
786a9ecedb
5 changed files with 23 additions and 32 deletions
2
app/stage/protyle/js/lute/lute.min.js
vendored
2
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/88250/clipboard v0.1.5
|
||||
github.com/88250/css v0.1.2
|
||||
github.com/88250/gulu v1.2.3-0.20221007162906-ded80d955178
|
||||
github.com/88250/lute v1.7.5-0.20221017121757-79d323e15149
|
||||
github.com/88250/lute v1.7.5-0.20221017124812-7539fdd90818
|
||||
github.com/88250/pdfcpu v0.3.13
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ github.com/88250/lute v1.7.5-0.20221017121334-7f401bccd11f h1:BTk5fjhrsuWNCu/XKi
|
|||
github.com/88250/lute v1.7.5-0.20221017121334-7f401bccd11f/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/lute v1.7.5-0.20221017121757-79d323e15149 h1:b9Fte/WIY/ye253978/rPZ6lXVNYcgHDLXJPbrHSE8o=
|
||||
github.com/88250/lute v1.7.5-0.20221017121757-79d323e15149/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/lute v1.7.5-0.20221017124812-7539fdd90818 h1:51yurqD1vo46Ba4DoZRhoMIM9VBbYM/vEeiDjcFlNiA=
|
||||
github.com/88250/lute v1.7.5-0.20221017124812-7539fdd90818/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
|
||||
github.com/88250/pdfcpu v0.3.13/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
|||
|
|
@ -769,7 +769,6 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
|||
}
|
||||
blocks := fromSQLBlocks(&sqlBlocks, strings.Join(terms, search.TermSep), beforeLen)
|
||||
|
||||
// 排除链接文本 https://github.com/siyuan-note/siyuan/issues/1542
|
||||
luteEngine := NewLute()
|
||||
var tmp []*Block
|
||||
for _, b := range blocks {
|
||||
|
|
@ -783,40 +782,20 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
|||
if !entering || n.IsBlock() {
|
||||
return ast.WalkContinue
|
||||
}
|
||||
if ast.NodeText == n.Type || ast.NodeLinkText == n.Type {
|
||||
if ast.NodeText == n.Type {
|
||||
textBuf.Write(n.Tokens)
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
|
||||
text := textBuf.String()
|
||||
text = strings.ToLower(text)
|
||||
text = luteEngine.Space(text)
|
||||
var contain bool
|
||||
for _, mentionKeyword := range mentionKeywords {
|
||||
parts := strings.Split(text, " ")
|
||||
for _, part := range parts {
|
||||
if "" == part {
|
||||
continue
|
||||
}
|
||||
|
||||
if gulu.Str.IsASCII(mentionKeyword) {
|
||||
if part == mentionKeyword {
|
||||
contain = true
|
||||
break
|
||||
}
|
||||
} else {
|
||||
if strings.Contains(part, strings.ToLower(mentionKeyword)) {
|
||||
contain = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if contain {
|
||||
break
|
||||
}
|
||||
text = strings.TrimSpace(text)
|
||||
if "" == text {
|
||||
continue
|
||||
}
|
||||
if contain {
|
||||
|
||||
newText := markReplaceSpan(text, mentionKeywords, searchMarkSpanStart, searchMarkSpanEnd)
|
||||
if text != newText {
|
||||
tmp = append(tmp, b)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ func stringQuery(query string) string {
|
|||
return strings.TrimSpace(buf.String())
|
||||
}
|
||||
|
||||
func markReplaceSpan(text string, keywords []string, replacementStart, replacementEnd string) string {
|
||||
func markReplaceSpan(text string, keywords []string, replacementStart, replacementEnd string) (ret string) {
|
||||
parts := strings.Split(text, " ")
|
||||
for i, part := range parts {
|
||||
if "" == part {
|
||||
|
|
@ -676,5 +676,15 @@ func markReplaceSpan(text string, keywords []string, replacementStart, replaceme
|
|||
parts[i] = search.EncloseHighlighting(part, hitKeywords, replacementStart, replacementEnd, Conf.Search.CaseSensitive)
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, " ")
|
||||
|
||||
ret = strings.Join(parts, " ")
|
||||
if ret != text {
|
||||
return
|
||||
}
|
||||
|
||||
// 包含非 ASCII 字符时再试试不分词匹配
|
||||
if !gulu.Str.IsASCII(text) {
|
||||
ret = search.EncloseHighlighting(text, keywords, replacementStart, replacementEnd, Conf.Search.CaseSensitive)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue