Skip to content

Commit

Permalink
🎨 支持代码块搜索定位和高亮 #5520
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jul 26, 2022
1 parent 7f9ef30 commit ac357ad
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/stage/protyle/js/lute/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kernel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/88250/css v0.1.2
github.com/88250/flock v0.8.2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583
github.com/88250/lute v1.7.5-0.20220724154255-81edef2f3ae2
github.com/88250/lute v1.7.5-0.20220726162257-7b9da9eaea07
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1
github.com/88250/pdfcpu v0.3.13
github.com/88250/protyle v0.0.0-20220519012506-0a2c8dc24397
Expand Down
4 changes: 2 additions & 2 deletions kernel/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ github.com/88250/gulu v1.2.0/go.mod h1:ZhEJ98UjR2y7j2toGj4/b+1rRELcZFQAPq/Yjyin2
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583 h1:FhA/zJemLrbOYJpdMIMBezO5rGigQSdPR1kv+aztHfA=
github.com/88250/gulu v1.2.3-0.20220720144315-065ef35ec583/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.4-0.20220426011157-34c9bfa2e148/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/lute v1.7.5-0.20220724154255-81edef2f3ae2 h1:nwgPx0LUAQ1sWlcBm/VSNK7RAHBdtOTNiPaEUFnuISQ=
github.com/88250/lute v1.7.5-0.20220724154255-81edef2f3ae2/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/lute v1.7.5-0.20220726162257-7b9da9eaea07 h1:lP/RM3N3Hm+H6Jng/DfCzVwcrkPOrUkrjCC5///rtBg=
github.com/88250/lute v1.7.5-0.20220726162257-7b9da9eaea07/go.mod h1:Bdu9LRNjQhtL3TftbtpjIWTwDVAXoS7AD8QsZQPk7zo=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1 h1:9Cb+iN639vUI2OcIBc+4oGwml9/0J6bL6dWNb8Al+1s=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1/go.mod h1:jH6MMPr8G7AMzaVmWHXZQiB1DKO3giWbcWZ7UoJ1teI=
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
Expand Down
8 changes: 8 additions & 0 deletions kernel/model/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// 搜索高亮
Expand Down

0 comments on commit ac357ad

Please sign in to comment.