소스 검색

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 2 년 전
부모
커밋
d349f897c9
4개의 변경된 파일39개의 추가작업 그리고 4개의 파일을 삭제
  1. 0 0
      app/stage/protyle/js/lute/lute.min.js
  2. 1 1
      kernel/go.mod
  3. 4 0
      kernel/go.sum
  4. 34 3
      kernel/model/search.go

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
app/stage/protyle/js/lute/lute.min.js


+ 1 - 1
kernel/go.mod

@@ -6,7 +6,7 @@ require (
 	github.com/88250/clipboard v0.1.5
 	github.com/88250/css v0.1.2
 	github.com/88250/gulu v1.2.3-0.20221117052724-cd06804db798
-	github.com/88250/lute v1.7.5-0.20221228064057-0c7be092096b
+	github.com/88250/lute v1.7.5-0.20221228082840-f51571fe01c5
 	github.com/88250/pdfcpu v0.3.13
 	github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
 	github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732

+ 4 - 0
kernel/go.sum

@@ -21,6 +21,10 @@ github.com/88250/lute v1.7.5-0.20221218043446-d967dba6874e h1:W9QP3v4GnZZkwKln5j
 github.com/88250/lute v1.7.5-0.20221218043446-d967dba6874e/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
 github.com/88250/lute v1.7.5-0.20221228064057-0c7be092096b h1:GtIZfyOZagH+2UYEkBprh+cqJhjqTkLnVhAjkI397fc=
 github.com/88250/lute v1.7.5-0.20221228064057-0c7be092096b/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
+github.com/88250/lute v1.7.5-0.20221228075634-633aed35b3a7 h1:NjYTH2y9xTjp4+PmZmiPajvS530iopaq2i9d19B1cJU=
+github.com/88250/lute v1.7.5-0.20221228075634-633aed35b3a7/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
+github.com/88250/lute v1.7.5-0.20221228082840-f51571fe01c5 h1:TAfGEgAW0OMzwNIxvhnNrpwTgmKyQDlBZI8zg1CUqK0=
+github.com/88250/lute v1.7.5-0.20221228082840-f51571fe01c5/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
 github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
 github.com/88250/pdfcpu v0.3.13/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
 github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=

+ 34 - 3
kernel/model/search.go

@@ -878,7 +878,7 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS
 	if ast.NodeText == n.Type {
 		text = search.EncloseHighlighting(text, keywords, getMarkSpanStart(markSpanDataType), getMarkSpanEnd(), Conf.Search.CaseSensitive)
 		n.Tokens = gulu.Str.ToBytes(text)
-		if bytes.Contains(n.Tokens, []byte("search-mark")) {
+		if bytes.Contains(n.Tokens, []byte(searchMarkDataType)) {
 			n.Tokens = lex.EscapeMarkers(n.Tokens)
 			linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions)
 			var children []*ast.Node
@@ -892,8 +892,39 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS
 			return true
 		}
 	} else if ast.NodeTextMark == n.Type {
-		// TODO 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
-		
+		// 搜索结果高亮支持大部分行级元素 https://github.com/siyuan-note/siyuan/issues/6745
+		if n.IsTextMarkType("inline-math") || n.IsTextMarkType("inline-memo") {
+			return false
+		}
+
+		startTag := getMarkSpanStart(markSpanDataType)
+		text = search.EncloseHighlighting(text, keywords, startTag, getMarkSpanEnd(), Conf.Search.CaseSensitive)
+		if strings.Contains(text, searchMarkDataType) {
+			dataType := getMarkSpanStart(n.TextMarkType + " " + searchMarkDataType)
+			text = strings.ReplaceAll(text, startTag, dataType)
+			tokens := gulu.Str.ToBytes(text)
+			linkTree := parse.Inline("", tokens, luteEngine.ParseOptions)
+			var children []*ast.Node
+			for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {
+				if ast.NodeText == c.Type {
+					c.Type = ast.NodeTextMark
+					c.TextMarkType = n.TextMarkType
+					c.TextMarkTextContent = string(c.Tokens)
+				}
+
+				children = append(children, c)
+				if nil != n.Next && ast.NodeKramdownSpanIAL == n.Next.Type {
+					c.KramdownIAL = n.KramdownIAL
+					ial := &ast.Node{Type: ast.NodeKramdownSpanIAL, Tokens: n.Next.Tokens}
+					children = append(children, ial)
+				}
+			}
+			for _, c := range children {
+				n.InsertBefore(c)
+			}
+			*unlinks = append(*unlinks, n)
+			return true
+		}
 	}
 	return false
 }

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.