mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 05:51:48 +08:00
🎨 Improve block ref anchor text rendering in templates https://github.com/siyuan-note/siyuan/issues/14457
This commit is contained in:
parent
86106d62c0
commit
98c51a8fd0
@ -355,7 +355,6 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
|
||||
nodesNeedAppendChild = append(nodesNeedAppendChild, n)
|
||||
}
|
||||
|
||||
// 块引缺失锚文本情况下自动补全 https://github.com/siyuan-note/siyuan/issues/6087
|
||||
if n.IsTextMarkType("block-ref") {
|
||||
if refText := n.Text(); "" == refText {
|
||||
refText = strings.TrimSpace(sql.GetRefText(n.TextMarkBlockRefID))
|
||||
@ -365,6 +364,17 @@ func RenderTemplate(p, id string, preview bool) (tree *parse.Tree, dom string, e
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
}
|
||||
} else if ast.NodeBlockRef == n.Type {
|
||||
if refText := n.Text(); "" == refText {
|
||||
if refID := n.ChildByType(ast.NodeBlockRefID); nil != refID {
|
||||
refText = strings.TrimSpace(sql.GetRefText(refID.TokensStr()))
|
||||
if "" != refText {
|
||||
treenode.SetDynamicBlockRefText(n, refText)
|
||||
} else {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if n.IsTextMarkType("inline-math") {
|
||||
if n.ParentIs(ast.NodeTableCell) {
|
||||
// 表格中的公式中带有管道符时使用 HTML 实体替换管道符 Improve the handling of inline-math containing `|` in the table https://github.com/siyuan-note/siyuan/issues/9227
|
||||
|
@ -469,6 +469,14 @@ func SetDynamicBlockRefText(blockRef *ast.Node, refText string) {
|
||||
return
|
||||
}
|
||||
|
||||
if ast.NodeBlockRef == blockRef.Type {
|
||||
if refID := blockRef.ChildByType(ast.NodeBlockRefID); nil != refID {
|
||||
refID.InsertAfter(&ast.Node{Type: ast.NodeBlockRefDynamicText, Tokens: []byte(refText)})
|
||||
refID.InsertAfter(&ast.Node{Type: ast.NodeBlockRefSpace})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
refText = strings.TrimSpace(refText)
|
||||
if "" == refText {
|
||||
refText = blockRef.TextMarkBlockRefID
|
||||
|
Loading…
Reference in New Issue
Block a user