From ef17af099a68e579017b17cd7cf2cb167ee65eb6 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 14 Sep 2022 19:45:51 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=A1=8C=E7=BA=A7=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=B5=8C=E5=A5=97=E5=92=8C=E4=BA=A4=E5=8F=89?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/2911?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/sql/block_query.go | 2 ++ kernel/sql/database.go | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/sql/block_query.go b/kernel/sql/block_query.go index 50de73a61..690c0dd9e 100644 --- a/kernel/sql/block_query.go +++ b/kernel/sql/block_query.go @@ -654,6 +654,8 @@ func GetContainerText(container *ast.Node) string { case ast.NodeText, ast.NodeLinkText, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef, ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent: buf.Write(n.Tokens) + case ast.NodeTextMark: + buf.WriteString(n.TextMarkTextContent) case ast.NodeBlockRef: if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor { buf.WriteString(anchor.Text()) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 362bd86cb..8f05a5ddf 100644 --- a/kernel/sql/database.go +++ b/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, ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent: buf.Write(n.Tokens) + case ast.NodeTextMark: + buf.WriteString(n.TextMarkTextContent) case ast.NodeBlockRef: if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor { buf.WriteString(anchor.Text()) @@ -537,7 +539,8 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) ( spans = append(spans, span) walkStatus = ast.WalkContinue 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 switch n.Type { 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() case ast.NodeCodeSpan: text = n.ChildByType(ast.NodeCodeSpanContent).TokensStr() + case ast.NodeTextMark: + text = n.TextMarkTextContent + typ = typ + " " + n.TextMarkType } markdown := treenode.FormatNode(n, luteEngine) @@ -558,7 +564,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) ( Path: p, Content: text, Markdown: markdown, - Type: treenode.TypeAbbr(n.Type.String()), + Type: typ, IAL: treenode.IALStr(n), } spans = append(spans, span) @@ -1202,7 +1208,7 @@ func nSort(n *ast.Node) int { case ast.NodeSuperBlock: return 30 // 以下为行级元素 - case ast.NodeText: + case ast.NodeText, ast.NodeTextMark: return 200 case ast.NodeTag: return 205