Skip to content

Commit 14534fb

Browse files
committed
fix logging render
1 parent d1b9045 commit 14534fb

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

cmd/root.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"regexp"
1010
"strings"
1111

12+
"github.com/charmbracelet/lipgloss"
1213
"github.com/charmbracelet/log"
1314
"github.com/elewis787/boa"
1415
"github.com/spf13/cobra"
@@ -96,14 +97,13 @@ func setupLogger(atmosConfig *schema.AtmosConfiguration) {
9697
}
9798

9899
if atmosConfig.Settings.Terminal.NoColor {
99-
styles := log.DefaultStyles()
100+
stylesDefault := log.DefaultStyles()
100101
// Clear colors for levels
101-
styles.Levels[log.DebugLevel] = styles.Levels[log.DebugLevel].UnsetForeground()
102-
styles.Levels[log.InfoLevel] = styles.Levels[log.InfoLevel].UnsetForeground()
103-
styles.Levels[log.WarnLevel] = styles.Levels[log.WarnLevel].UnsetForeground()
104-
styles.Levels[log.ErrorLevel] = styles.Levels[log.ErrorLevel].UnsetForeground()
105-
styles.Levels[log.FatalLevel] = styles.Levels[log.FatalLevel].UnsetForeground()
106-
102+
styles := &log.Styles{}
103+
styles.Levels = make(map[log.Level]lipgloss.Style)
104+
for k, val := range stylesDefault.Levels {
105+
styles.Levels[k] = val.UnsetForeground().Bold(false)
106+
}
107107
log.SetStyles(styles)
108108
}
109109
var output io.Writer

pkg/ui/markdown/renderer.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/muesli/termenv"
1313
)
1414

15+
const defaultWidth = 80
16+
1517
// Renderer is a markdown renderer using Glamour
1618
type Renderer struct {
1719
renderer *glamour.TermRenderer
@@ -25,7 +27,7 @@ type Renderer struct {
2527
// NewRenderer creates a new markdown renderer with the given options
2628
func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Renderer, error) {
2729
r := &Renderer{
28-
width: 80, // default width
30+
width: defaultWidth, // default width
2931
profile: termenv.ColorProfile(), // default color profile
3032
isTTYSupportForStdout: term.IsTTYSupportForStdout,
3133
isTTYSupportForStderr: term.IsTTYSupportForStderr,
@@ -38,7 +40,7 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
3840

3941
if atmosConfig.Settings.Terminal.NoColor {
4042
renderer, err := glamour.NewTermRenderer(
41-
glamour.WithAutoStyle(),
43+
glamour.WithStandardStyle(styles.AsciiStyle),
4244
glamour.WithWordWrap(int(r.width)),
4345
glamour.WithColorProfile(r.profile),
4446
glamour.WithEmoji(),
@@ -75,14 +77,28 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
7577

7678
func (r *Renderer) RenderWithoutWordWrap(content string) (string, error) {
7779
// Render without line wrapping
78-
out, err := glamour.NewTermRenderer(
79-
glamour.WithAutoStyle(), // Uses terminal's default style
80-
glamour.WithWordWrap(0),
81-
glamour.WithColorProfile(r.profile),
82-
glamour.WithEmoji(),
83-
)
84-
if err != nil {
85-
return "", err
80+
var out *glamour.TermRenderer
81+
var err error
82+
if r.atmosConfig.Settings.Terminal.NoColor {
83+
out, err = glamour.NewTermRenderer(
84+
glamour.WithStandardStyle(styles.AsciiStyle),
85+
glamour.WithWordWrap(0),
86+
glamour.WithColorProfile(r.profile),
87+
glamour.WithEmoji(),
88+
)
89+
if err != nil {
90+
return "", err
91+
}
92+
} else {
93+
out, err = glamour.NewTermRenderer(
94+
glamour.WithAutoStyle(), // Uses terminal's default style
95+
glamour.WithWordWrap(0),
96+
glamour.WithColorProfile(r.profile),
97+
glamour.WithEmoji(),
98+
)
99+
if err != nil {
100+
return "", err
101+
}
86102
}
87103
result := ""
88104
if r.isTTYSupportForStdout() {
@@ -155,22 +171,6 @@ func (r *Renderer) RenderAscii(content string) (string, error) {
155171
return renderer.Render(content)
156172
}
157173

158-
// RenderWithStyle renders markdown content with a specific style
159-
func (r *Renderer) RenderWithStyle(content string, style []byte) (string, error) {
160-
renderer, err := glamour.NewTermRenderer(
161-
glamour.WithAutoStyle(),
162-
glamour.WithWordWrap(int(r.width)),
163-
glamour.WithStylesFromJSONBytes(style),
164-
glamour.WithColorProfile(r.profile),
165-
glamour.WithEmoji(),
166-
)
167-
if err != nil {
168-
return "", err
169-
}
170-
171-
return renderer.Render(content)
172-
}
173-
174174
// RenderWorkflow renders workflow documentation with specific styling
175175
func (r *Renderer) RenderWorkflow(content string) (string, error) {
176176
// Add workflow header

0 commit comments

Comments
 (0)