🎨 支持代码块搜索定位和高亮 https://github.com/siyuan-note/siyuan/issues/5520

This commit is contained in:
Liang Ding 2022-07-27 00:27:20 +08:00
parent 7f9ef304cf
commit ac357adc73
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 12 additions and 4 deletions

View file

@ -615,6 +615,14 @@ func GetDoc(id string, index int, keyword string, mode int, size int) (blockCoun
return ast.WalkSkipChildren
}
// TODO: 支持代码块搜索定位和高亮 https://github.com/siyuan-note/siyuan/issues/5520
if ast.NodeCodeBlockCode == n.Type {
// 搜索高亮
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, "__@mark__", "__mark@__", Conf.Search.CaseSensitive)
n.Tokens = gulu.Str.ToBytes(text)
}
if ast.NodeText == n.Type {
if 0 < len(keywords) {
// 搜索高亮