mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 支持代码块搜索定位和高亮 https://github.com/siyuan-note/siyuan/issues/5520
This commit is contained in:
parent
7f9ef304cf
commit
ac357adc73
4 changed files with 12 additions and 4 deletions
|
|
@ -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) {
|
||||
// 搜索高亮
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue