mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Virtual references exclude the name and aliases from the current document https://github.com/siyuan-note/siyuan/issues/9204
This commit is contained in:
parent
58d1978eb8
commit
21aabc216d
1 changed files with 17 additions and 6 deletions
|
|
@ -56,15 +56,15 @@ func getBlockVirtualRefKeywords(root *ast.Node) (ret []string) {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
})
|
})
|
||||||
content := buf.String()
|
content := buf.String()
|
||||||
ret = putBlockVirtualRefKeywords(content, root.ID, root.IALAttr("title"))
|
ret = putBlockVirtualRefKeywords(content, root)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ret = val.([]string)
|
ret = val.([]string)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) (ret []string) {
|
func putBlockVirtualRefKeywords(blockContent string, root *ast.Node) (ret []string) {
|
||||||
keywords := getVirtualRefKeywords(docTitle)
|
keywords := getVirtualRefKeywords(root)
|
||||||
if 1 > len(keywords) {
|
if 1 > len(keywords) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ func putBlockVirtualRefKeywords(blockContent, blockID, docTitle string) (ret []s
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||||
virtualBlockRefCache.SetWithTTL(blockID, ret, 1, 10*time.Minute)
|
virtualBlockRefCache.SetWithTTL(root.ID, ret, 1, 10*time.Minute)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,7 +174,7 @@ func processVirtualRef(n *ast.Node, unlinks *[]*ast.Node, virtualBlockRefKeyword
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVirtualRefKeywords(docName string) (ret []string) {
|
func getVirtualRefKeywords(root *ast.Node) (ret []string) {
|
||||||
if !Conf.Editor.VirtualBlockRef {
|
if !Conf.Editor.VirtualBlockRef {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -225,7 +225,18 @@ func getVirtualRefKeywords(docName string) (ret []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537
|
// 虚拟引用排除当前文档名 https://github.com/siyuan-note/siyuan/issues/4537
|
||||||
ret = gulu.Str.ExcludeElem(ret, []string{docName})
|
// Virtual references exclude the name and aliases from the current document https://github.com/siyuan-note/siyuan/issues/9204
|
||||||
|
title := root.IALAttr("title")
|
||||||
|
ret = gulu.Str.ExcludeElem(ret, []string{title})
|
||||||
|
if name := root.IALAttr("name"); "" != name {
|
||||||
|
ret = gulu.Str.ExcludeElem(ret, []string{name})
|
||||||
|
}
|
||||||
|
if alias := root.IALAttr("alias"); "" != alias {
|
||||||
|
for _, a := range strings.Split(alias, ",") {
|
||||||
|
ret = gulu.Str.ExcludeElem(ret, []string{a})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret = prepareMarkKeywords(ret)
|
ret = prepareMarkKeywords(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue