mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Show heading block appearance style in the Outline Panel Fix https://github.com/siyuan-note/siyuan/issues/7872
This commit is contained in:
parent
ae4717710d
commit
193e50090d
1 changed files with 19 additions and 5 deletions
|
|
@ -33,19 +33,26 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
|
func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) {
|
||||||
if nil == node {
|
if nil == heading {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if ast.NodeDocument == node.Type {
|
if ast.NodeDocument == heading.Type {
|
||||||
return node.IALAttr("title")
|
return heading.IALAttr("title")
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
buf.Grow(4096)
|
buf.Grow(4096)
|
||||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(heading, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if !entering {
|
if !entering {
|
||||||
|
switch n.Type {
|
||||||
|
case ast.NodeHeading:
|
||||||
|
// Show heading block appearance style in the Outline Panel https://github.com/siyuan-note/siyuan/issues/7872
|
||||||
|
if style := n.IALAttr("style"); "" != style {
|
||||||
|
buf.WriteString("</span>")
|
||||||
|
}
|
||||||
|
}
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,6 +64,13 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch n.Type {
|
switch n.Type {
|
||||||
|
case ast.NodeHeading:
|
||||||
|
// Show heading block appearance style in the Outline Panel https://github.com/siyuan-note/siyuan/issues/7872
|
||||||
|
if style := n.IALAttr("style"); "" != style {
|
||||||
|
buf.WriteString("<span style=\"")
|
||||||
|
buf.WriteString(style)
|
||||||
|
buf.WriteString("\">")
|
||||||
|
}
|
||||||
case ast.NodeText, ast.NodeLinkText, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
|
case ast.NodeText, ast.NodeLinkText, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
|
||||||
tokens := html.EscapeHTML(n.Tokens)
|
tokens := html.EscapeHTML(n.Tokens)
|
||||||
tokens = bytes.ReplaceAll(tokens, []byte(" "), []byte(" ")) // 大纲面板条目中无法显示多个空格 https://github.com/siyuan-note/siyuan/issues/4370
|
tokens = bytes.ReplaceAll(tokens, []byte(" "), []byte(" ")) // 大纲面板条目中无法显示多个空格 https://github.com/siyuan-note/siyuan/issues/4370
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue