From 84e9a003e8d12ba619eecb73fd54cf15502c6684 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 29 May 2025 20:30:59 +0800 Subject: [PATCH] :art: Revert Improve backlink filtering below the heading Improve backlink filtering below the heading --- kernel/model/backlink.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 5cff17ead..ea2543303 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -476,7 +476,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChild var paragraphParentIDs []string for _, link := range links { for _, ref := range link.Refs { - if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type { + if "NodeParagraph" == ref.Type { paragraphParentIDs = append(paragraphParentIDs, ref.ParentID) } } @@ -494,7 +494,7 @@ func GetBacklink(id, keyword, mentionKeyword string, beforeLen int, containChild } for _, link := range links { for _, ref := range link.Refs { - if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type { + if "NodeParagraph" == ref.Type { if processedParagraphs.Contains(ref.ParentID) { continue } @@ -580,7 +580,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret [] var paragraphParentIDs []string for _, link := range links { for _, ref := range link.Refs { - if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type { + if "NodeParagraph" == ref.Type { parentRefParagraphs[ref.ParentID] = ref paragraphParentIDs = append(paragraphParentIDs, ref.ParentID) } @@ -615,15 +615,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret [] continue } - text := c.Text() - if strings.HasPrefix(text, "#") { - tmp := strings.ReplaceAll(text, "#", "") - if " " == tmp { // 如果是标题标记符则跳过 - continue - } - } - - if "" != strings.TrimSpace(text) { + if "" != strings.TrimSpace(c.Text()) { paragraphUseParentLi = false break } @@ -648,7 +640,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret [] } for _, link := range links { for _, ref := range link.Refs { - if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type { + if "NodeParagraph" == ref.Type { if processedParagraphs.Contains(ref.ParentID) { continue }