mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 反链提及搜索范围增加命名、别名和备注 Fix https://github.com/siyuan-note/siyuan/issues/7639
This commit is contained in:
parent
66f6388c3d
commit
18f6bc3073
1 changed files with 14 additions and 2 deletions
|
|
@ -642,7 +642,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
buf.WriteString("SELECT * FROM " + table + " WHERE " + table + " MATCH '{content}:(")
|
buf.WriteString("SELECT * FROM " + table + " WHERE " + table + " MATCH '" + columnFilter() + ":(")
|
||||||
for i, mentionKeyword := range mentionKeywords {
|
for i, mentionKeyword := range mentionKeywords {
|
||||||
if Conf.Search.BacklinkMentionKeywordsLimit < i {
|
if Conf.Search.BacklinkMentionKeywordsLimit < i {
|
||||||
util.PushMsg(fmt.Sprintf(Conf.Language(38), len(mentionKeywords)), 5000)
|
util.PushMsg(fmt.Sprintf(Conf.Language(38), len(mentionKeywords)), 5000)
|
||||||
|
|
@ -688,7 +688,7 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
||||||
if !entering || n.IsBlock() {
|
if !entering || n.IsBlock() {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
if ast.NodeText == n.Type {
|
if ast.NodeText == n.Type { // 这里包含了标签命中的情况,因为 Lute 没有启用 TextMark
|
||||||
textBuf.Write(n.Tokens)
|
textBuf.Write(n.Tokens)
|
||||||
}
|
}
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
|
|
@ -703,6 +703,14 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
||||||
newText := markReplaceSpanWithSplit(text, mentionKeywords, search.GetMarkSpanStart(search.MarkDataType), search.GetMarkSpanEnd())
|
newText := markReplaceSpanWithSplit(text, mentionKeywords, search.GetMarkSpanStart(search.MarkDataType), search.GetMarkSpanEnd())
|
||||||
if text != newText {
|
if text != newText {
|
||||||
tmp = append(tmp, b)
|
tmp = append(tmp, b)
|
||||||
|
} else {
|
||||||
|
// columnFilter 中的命名、别名和备注命中的情况
|
||||||
|
// 反链提及搜索范围增加命名、别名和备注 https://github.com/siyuan-note/siyuan/issues/7639
|
||||||
|
if gulu.Str.Contains(trimMarkTags(b.Name), mentionKeywords) ||
|
||||||
|
gulu.Str.Contains(trimMarkTags(b.Alias), mentionKeywords) ||
|
||||||
|
gulu.Str.Contains(trimMarkTags(b.Memo), mentionKeywords) {
|
||||||
|
tmp = append(tmp, b)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blocks = tmp
|
blocks = tmp
|
||||||
|
|
@ -727,6 +735,10 @@ func searchBackmention(mentionKeywords []string, keyword string, excludeBacklink
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trimMarkTags(str string) string {
|
||||||
|
return strings.TrimSuffix(strings.TrimPrefix(str, "<mark>"), "</mark>")
|
||||||
|
}
|
||||||
|
|
||||||
func getContainStr(str string, strs []string) string {
|
func getContainStr(str string, strs []string) string {
|
||||||
str = strings.ToLower(str)
|
str = strings.ToLower(str)
|
||||||
for _, s := range strs {
|
for _, s := range strs {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue