From 193e50090dbad8dbd5a5c352c6094ba565b77510 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 7 Apr 2023 09:49:40 +0800 Subject: [PATCH] :art: Show heading block appearance style in the Outline Panel Fix https://github.com/siyuan-note/siyuan/issues/7872 --- kernel/model/render.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/kernel/model/render.go b/kernel/model/render.go index 1c9ccc3bd..41542f34c 100644 --- a/kernel/model/render.go +++ b/kernel/model/render.go @@ -33,19 +33,26 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) { - if nil == node { +func renderOutline(heading *ast.Node, luteEngine *lute.Lute) (ret string) { + if nil == heading { return "" } - if ast.NodeDocument == node.Type { - return node.IALAttr("title") + if ast.NodeDocument == heading.Type { + return heading.IALAttr("title") } buf := bytes.Buffer{} 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 { + 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("") + } + } return ast.WalkContinue } @@ -57,6 +64,13 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) { } 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("") + } case ast.NodeText, ast.NodeLinkText, ast.NodeCodeBlockCode, ast.NodeMathBlockContent: tokens := html.EscapeHTML(n.Tokens) tokens = bytes.ReplaceAll(tokens, []byte(" "), []byte(" ")) // 大纲面板条目中无法显示多个空格 https://github.com/siyuan-note/siyuan/issues/4370