diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go index d09f566c6..08e56d495 100644 --- a/kernel/model/blockial.go +++ b/kernel/model/blockial.go @@ -63,7 +63,7 @@ func SetBlockReminder(id string, timed string) (err error) { if ast.NodeDocument != node.Type && node.IsContainerBlock() { node = treenode.FirstLeafBlock(node) } - content := treenode.NodeStaticContent(node, nil) + content := treenode.NodeStaticContent(node, nil, false) content = gulu.Str.SubStr(content, 128) err = SetCloudBlockReminder(id, content, timedMills) if nil != err { diff --git a/kernel/model/render.go b/kernel/model/render.go index 73047513c..10198ea25 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -78,7 +78,7 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) { } func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) { - ret = treenode.NodeStaticContent(node, excludeTypes) + ret = treenode.NodeStaticContent(node, excludeTypes, false) ret = strings.TrimSpace(ret) ret = strings.ReplaceAll(ret, "\n", "") ret = util.EscapeHTML(ret) @@ -141,7 +141,7 @@ func renderBlockContentByNodes(nodes []*ast.Node) string { buf := bytes.Buffer{} for _, n := range subNodes { - buf.WriteString(treenode.NodeStaticContent(n, nil)) + buf.WriteString(treenode.NodeStaticContent(n, nil, false)) } return buf.String() } diff --git a/kernel/model/virutalref.go b/kernel/model/virutalref.go index f16defad2..0130b1469 100644 --- a/kernel/model/virutalref.go +++ b/kernel/model/virutalref.go @@ -51,7 +51,7 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) { return ast.WalkContinue } - content := treenode.NodeStaticContent(n, nil) + content := treenode.NodeStaticContent(n, nil, false) buf.WriteString(content) return ast.WalkContinue }) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 0187e20cd..502a87eb4 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -699,9 +699,10 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes fcontent = content length = utf8.RuneCountInString(fcontent) } else if n.IsContainerBlock() { - markdown, content = treenode.NodeStaticMdContent(n, luteEngine) + markdown = treenode.ExportNodeStdMd(n, luteEngine) + content = treenode.NodeStaticContent(n, nil, true) fc := treenode.FirstLeafBlock(n) - fcontent = treenode.NodeStaticContent(fc, nil) + fcontent = treenode.NodeStaticContent(fc, nil, false) parentID = n.Parent.ID // 将标题块作为父节点 if h := heading(n); nil != h { @@ -709,7 +710,8 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes } length = utf8.RuneCountInString(fcontent) } else { - markdown, content = treenode.NodeStaticMdContent(n, luteEngine) + markdown = treenode.ExportNodeStdMd(n, luteEngine) + content = treenode.NodeStaticContent(n, nil, true) parentID = n.Parent.ID // 将标题块作为父节点 if h := heading(n); nil != h { diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go index d94b5eda8..e2eb2528a 100644 --- a/kernel/treenode/node.go +++ b/kernel/treenode/node.go @@ -114,12 +114,6 @@ func IsEmbedBlockRef(n *ast.Node) bool { return "" != GetEmbedBlockRef(n) } -func NodeStaticMdContent(node *ast.Node, luteEngine *lute.Lute) (md, content string) { - md = ExportNodeStdMd(node, luteEngine) - content = NodeStaticContent(node, nil) - return -} - func FormatNode(node *ast.Node, luteEngine *lute.Lute) string { markdown, err := lute.FormatNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions) if nil != err { @@ -138,7 +132,7 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string { return markdown } -func NodeStaticContent(node *ast.Node, excludeTypes []string) string { +func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL bool) string { if nil == node { return "" } @@ -225,7 +219,7 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string) string { if n.IsTextMarkType("tag") { buf.WriteByte('#') } - if n.IsTextMarkType("a") { + if n.IsTextMarkType("a") && includeTextMarkATitleURL { // 搜索不到超链接元素的 URL 和标题 https://github.com/siyuan-note/siyuan/issues/7352 if "" != n.TextMarkATitle { buf.WriteString(" " + n.TextMarkATitle)