From 7bdff9eaeb6c7639ebf21c51d835ff90671b4610 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 10 Feb 2023 15:21:20 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=B9=E8=BF=9B=E5=BB=BA=E7=AB=8B?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E7=B4=A2=E5=BC=95=20https://github.com/siyua?= =?UTF-8?q?n-note/siyuan/issues/7320?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/export.go | 2 +- kernel/model/index.go | 6 ++---- kernel/model/search.go | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/model/export.go b/kernel/model/export.go index 8a04d6402..013fecedd 100644 --- a/kernel/model/export.go +++ b/kernel/model/export.go @@ -1362,7 +1362,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool, if n.IsTextMarkType("inline-math") { n.TextMarkInlineMathContent = strings.TrimSpace(n.TextMarkInlineMathContent) return ast.WalkContinue - } else if n.IsTextMarkType("file-annotation-ref") { + } else if treenode.IsFileAnnotationRef(n) { refID := n.TextMarkFileAnnotationRefID status := processFileAnnotationRef(refID, n, fileAnnotationRefMode) unlinks = append(unlinks, n) diff --git a/kernel/model/index.go b/kernel/model/index.go index 9c4aa152f..f03446067 100644 --- a/kernel/model/index.go +++ b/kernel/model/index.go @@ -172,10 +172,8 @@ func IndexRefs() { return ast.WalkContinue } - if n.IsTextMarkType("block-ref") { - defBlockIDs = append(defBlockIDs, n.TextMarkBlockRefID) - } else if n.IsTextMarkType("file-annotation-ref") { - defBlockIDs = append(defBlockIDs, n.TextMarkFileAnnotationRefID) + if treenode.IsBlockRef(n) || treenode.IsFileAnnotationRef(n) { + defBlockIDs = append(defBlockIDs, tree.Root.ID) } return ast.WalkContinue }) diff --git a/kernel/model/search.go b/kernel/model/search.go index f7e00c5db..4168c6b44 100644 --- a/kernel/model/search.go +++ b/kernel/model/search.go @@ -943,19 +943,19 @@ func markReplaceSpan(n *ast.Node, unlinks *[]*ast.Node, keywords []string, markS c.TextMarkTextContent = string(c.Tokens) if n.IsTextMarkType("a") { c.TextMarkAHref, c.TextMarkATitle = n.TextMarkAHref, n.TextMarkATitle - } else if n.IsTextMarkType("block-ref") { + } else if treenode.IsBlockRef(n) { c.TextMarkBlockRefID = n.TextMarkBlockRefID c.TextMarkBlockRefSubtype = n.TextMarkBlockRefSubtype - } else if n.IsTextMarkType("file-annotation-ref") { + } else if treenode.IsFileAnnotationRef(n) { c.TextMarkFileAnnotationRefID = n.TextMarkFileAnnotationRefID } } else if ast.NodeTextMark == c.Type { if n.IsTextMarkType("a") { c.TextMarkAHref, c.TextMarkATitle = n.TextMarkAHref, n.TextMarkATitle - } else if n.IsTextMarkType("block-ref") { + } else if treenode.IsBlockRef(n) { c.TextMarkBlockRefID = n.TextMarkBlockRefID c.TextMarkBlockRefSubtype = n.TextMarkBlockRefSubtype - } else if n.IsTextMarkType("file-annotation-ref") { + } else if treenode.IsFileAnnotationRef(n) { c.TextMarkFileAnnotationRefID = n.TextMarkFileAnnotationRefID } }