mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Improve backlink filtering below the heading https://github.com/siyuan-note/siyuan/issues/14929
This commit is contained in:
parent
066fbd40d2
commit
4528be886e
1 changed files with 13 additions and 5 deletions
|
|
@ -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 {
|
||||
if "NodeParagraph" == ref.Type || "NodeHeading" == 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 {
|
||||
if "NodeParagraph" == ref.Type || "NodeHeading" == 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 {
|
||||
if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type {
|
||||
parentRefParagraphs[ref.ParentID] = ref
|
||||
paragraphParentIDs = append(paragraphParentIDs, ref.ParentID)
|
||||
}
|
||||
|
|
@ -615,7 +615,15 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
|
|||
continue
|
||||
}
|
||||
|
||||
if "" != strings.TrimSpace(c.Text()) {
|
||||
text := c.Text()
|
||||
if strings.HasPrefix(text, "#") {
|
||||
tmp := strings.ReplaceAll(text, "#", "")
|
||||
if " " == tmp { // 如果是标题标记符则跳过
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if "" != strings.TrimSpace(text) {
|
||||
paragraphUseParentLi = false
|
||||
break
|
||||
}
|
||||
|
|
@ -640,7 +648,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref, keywords []string) (ret []
|
|||
}
|
||||
for _, link := range links {
|
||||
for _, ref := range link.Refs {
|
||||
if "NodeParagraph" == ref.Type {
|
||||
if "NodeParagraph" == ref.Type || "NodeHeading" == ref.Type {
|
||||
if processedParagraphs.Contains(ref.ParentID) {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue