Skip to content

Commit

Permalink
markdown renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerebrovinny committed Dec 19, 2024
1 parent 2783c87 commit 3a8bc87
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/ui/markdown/renderer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package markdown

import (
"fmt"
"strings"

"github.com/charmbracelet/glamour"
"github.com/muesli/termenv"
)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 3a8bc87

Please sign in to comment.