From 3a8bc87c788be5c71c1ed8f539c5911dd47f8a3a Mon Sep 17 00:00:00 2001 From: Cerebrovinny Date: Thu, 19 Dec 2024 21:25:42 +0000 Subject: [PATCH] markdown renderer --- pkg/ui/markdown/renderer.go | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkg/ui/markdown/renderer.go b/pkg/ui/markdown/renderer.go index bfba82782b..bf07a6df5c 100644 --- a/pkg/ui/markdown/renderer.go +++ b/pkg/ui/markdown/renderer.go @@ -1,6 +1,9 @@ package markdown import ( + "fmt" + "strings" + "github.com/charmbracelet/glamour" "github.com/muesli/termenv" ) @@ -61,6 +64,43 @@ func (r *Renderer) RenderWithStyle(content string, style []byte) (string, error) return renderer.Render(content) } +// RenderWorkflow renders workflow documentation with specific styling +func (r *Renderer) RenderWorkflow(content string) (string, error) { + // Add workflow header + content = "# Workflow\n\n" + content + return r.Render(content) +} + +// RenderError renders an error message with specific styling +func (r *Renderer) RenderError(title, details, examples string) (string, error) { + var content string + + if details != "" { + content += fmt.Sprintf("%s\n\n", details) + } + + if examples != "" { + if !strings.Contains(examples, "## Examples") { + content += fmt.Sprintf("## Examples\n\n%s", examples) + } else { + content += examples + } + } + + return r.Render(content) +} + +// RenderSuccess renders a success message with specific styling +func (r *Renderer) RenderSuccess(title, details string) (string, error) { + content := fmt.Sprintf("# %s\n\n", title) + + if details != "" { + content += fmt.Sprintf("## Details\n%s\n\n", details) + } + + return r.Render(content) +} + // Option is a function that configures the renderer type Option func(*Renderer)