This commit is contained in:
Liang Ding 2022-09-14 01:30:10 +08:00
parent f0a6c2be8a
commit eefede8fff
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 19 additions and 7 deletions

File diff suppressed because one or more lines are too long

View file

@ -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.20220909041418-fdfa4d7380bf
github.com/88250/lute v1.7.5-0.20220913162658-41481d72c8f4
github.com/88250/lute v1.7.5-0.20220913172545-b1d7f2231ec9
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1
github.com/88250/pdfcpu v0.3.13
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1

View file

@ -19,8 +19,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20220909041418-fdfa4d7380bf h1:q+iiBuKjdvUKj5dQQHCRs+g9oChTWkZmm7r1FMvtkfI=
github.com/88250/gulu v1.2.3-0.20220909041418-fdfa4d7380bf/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.5-0.20220913162658-41481d72c8f4 h1:U5jrcA+x5IZ4NnDSC94YN0xqNSCbFI9xV6FCGbjhi7M=
github.com/88250/lute v1.7.5-0.20220913162658-41481d72c8f4/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/lute v1.7.5-0.20220913172545-b1d7f2231ec9 h1:MZzkCt80ARMKBEo74Ps/VcvvlVErsUu6lBVBqupNfWA=
github.com/88250/lute v1.7.5-0.20220913172545-b1d7f2231ec9/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
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=

View file

@ -34,7 +34,6 @@ import (
"github.com/88250/lute/ast"
"github.com/88250/lute/html"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
util2 "github.com/88250/lute/util"
"github.com/dustin/go-humanize"
"github.com/facette/natsort"
@ -644,7 +643,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size
}
// 支持代码块搜索定位 https://github.com/siyuan-note/siyuan/issues/5520
if ast.NodeCodeBlockCode == n.Type && 0 < len(keywords) && !render.IsChartCodeBlockCode(n) {
if ast.NodeCodeBlockCode == n.Type && 0 < len(keywords) && !treenode.IsChartCodeBlockCode(n) {
text := string(n.Tokens)
text = search.EncloseHighlighting(text, keywords, search.SearchMarkLeft, search.SearchMarkRight, Conf.Search.CaseSensitive)
n.Tokens = gulu.Str.ToBytes(text)

View file

@ -22,9 +22,12 @@ import (
"github.com/88250/lute"
"github.com/88250/lute/ast"
"github.com/88250/lute/editor"
"github.com/88250/lute/html"
"github.com/88250/lute/lex"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
"github.com/88250/lute/util"
"github.com/siyuan-note/logging"
)
@ -325,3 +328,13 @@ func GetDynamicBlockRefText(blockRef *ast.Node) string {
}
return "ref resolve failed"
}
func IsChartCodeBlockCode(code *ast.Node) bool {
if nil == code.Previous || ast.NodeCodeBlockFenceInfoMarker != code.Previous.Type || 1 > len(code.Previous.CodeBlockInfo) {
return false
}
language := util.BytesToStr(code.Previous.CodeBlockInfo)
language = strings.ReplaceAll(language, editor.Caret, "")
return render.NoHighlight(language)
}