Selaa lähdekoodia

:art: 行级元素支持嵌套和交叉 https://github.com/siyuan-note/siyuan/issues/2911

Liang Ding 2 vuotta sitten
vanhempi
commit
ef17af099a
2 muutettua tiedostoa jossa 11 lisäystä ja 3 poistoa
  1. 2 0
      kernel/sql/block_query.go
  2. 9 3
      kernel/sql/database.go

+ 2 - 0
kernel/sql/block_query.go

@@ -654,6 +654,8 @@ func GetContainerText(container *ast.Node) string {
 		case ast.NodeText, ast.NodeLinkText, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
 		case ast.NodeText, ast.NodeLinkText, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
 			ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
 			ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
 			buf.Write(n.Tokens)
 			buf.Write(n.Tokens)
+		case ast.NodeTextMark:
+			buf.WriteString(n.TextMarkTextContent)
 		case ast.NodeBlockRef:
 		case ast.NodeBlockRef:
 			if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
 			if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
 				buf.WriteString(anchor.Text())
 				buf.WriteString(anchor.Text())

+ 9 - 3
kernel/sql/database.go

@@ -399,6 +399,8 @@ func resolveRefContent0(node *ast.Node, anchors *map[string]string, depth *int,
 		case ast.NodeText, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
 		case ast.NodeText, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
 			ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
 			ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
 			buf.Write(n.Tokens)
 			buf.Write(n.Tokens)
+		case ast.NodeTextMark:
+			buf.WriteString(n.TextMarkTextContent)
 		case ast.NodeBlockRef:
 		case ast.NodeBlockRef:
 			if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
 			if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
 				buf.WriteString(anchor.Text())
 				buf.WriteString(anchor.Text())
@@ -537,7 +539,8 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
 		spans = append(spans, span)
 		spans = append(spans, span)
 		walkStatus = ast.WalkContinue
 		walkStatus = ast.WalkContinue
 		return
 		return
-	case ast.NodeTag, ast.NodeInlineMath, ast.NodeCodeSpan, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline:
+	case ast.NodeTag, ast.NodeInlineMath, ast.NodeCodeSpan, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline, ast.NodeTextMark:
+		typ := treenode.TypeAbbr(n.Type.String())
 		var text string
 		var text string
 		switch n.Type {
 		switch n.Type {
 		case ast.NodeTag, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline:
 		case ast.NodeTag, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline:
@@ -546,6 +549,9 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
 			text = n.ChildByType(ast.NodeInlineMathContent).TokensStr()
 			text = n.ChildByType(ast.NodeInlineMathContent).TokensStr()
 		case ast.NodeCodeSpan:
 		case ast.NodeCodeSpan:
 			text = n.ChildByType(ast.NodeCodeSpanContent).TokensStr()
 			text = n.ChildByType(ast.NodeCodeSpanContent).TokensStr()
+		case ast.NodeTextMark:
+			text = n.TextMarkTextContent
+			typ = typ + " " + n.TextMarkType
 		}
 		}
 
 
 		markdown := treenode.FormatNode(n, luteEngine)
 		markdown := treenode.FormatNode(n, luteEngine)
@@ -558,7 +564,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
 			Path:     p,
 			Path:     p,
 			Content:  text,
 			Content:  text,
 			Markdown: markdown,
 			Markdown: markdown,
-			Type:     treenode.TypeAbbr(n.Type.String()),
+			Type:     typ,
 			IAL:      treenode.IALStr(n),
 			IAL:      treenode.IALStr(n),
 		}
 		}
 		spans = append(spans, span)
 		spans = append(spans, span)
@@ -1202,7 +1208,7 @@ func nSort(n *ast.Node) int {
 	case ast.NodeSuperBlock:
 	case ast.NodeSuperBlock:
 		return 30
 		return 30
 	// 以下为行级元素
 	// 以下为行级元素
-	case ast.NodeText:
+	case ast.NodeText, ast.NodeTextMark:
 		return 200
 		return 200
 	case ast.NodeTag:
 	case ast.NodeTag:
 		return 205
 		return 205