mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
🎨 Improve ref count rendering https://github.com/siyuan-note/siyuan/issues/12738
This commit is contained in:
parent
5bb7a630a3
commit
daf964d8d3
1 changed files with 22 additions and 4 deletions
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/88250/gulu"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
"github.com/88250/lute/parse"
|
"github.com/88250/lute/parse"
|
||||||
"github.com/open-spaced-repetition/go-fsrs/v3"
|
"github.com/open-spaced-repetition/go-fsrs/v3"
|
||||||
|
|
@ -859,13 +860,30 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
|
||||||
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
|
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
|
||||||
var defIDs []string
|
var defIDs []string
|
||||||
for _, n := range nodes {
|
for _, n := range nodes {
|
||||||
defIDs = append(defIDs, n.ID)
|
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
|
if !entering {
|
||||||
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.IsBlock() {
|
||||||
|
defIDs = append(defIDs, n.ID)
|
||||||
|
}
|
||||||
|
return ast.WalkContinue
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
defIDs = gulu.Str.RemoveDuplicatedElem(defIDs)
|
||||||
refCount := sql.QueryRefCount(defIDs)
|
refCount := sql.QueryRefCount(defIDs)
|
||||||
for _, n := range nodes {
|
for _, n := range nodes {
|
||||||
if cnt := refCount[n.ID]; 0 < cnt {
|
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
n.SetIALAttr("refcount", strconv.Itoa(cnt))
|
if !entering || !n.IsBlock() {
|
||||||
}
|
return ast.WalkContinue
|
||||||
|
}
|
||||||
|
|
||||||
|
if cnt := refCount[n.ID]; 0 < cnt {
|
||||||
|
n.SetIALAttr("refcount", strconv.Itoa(cnt))
|
||||||
|
}
|
||||||
|
return ast.WalkContinue
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue