@@ -12,6 +12,8 @@ import (
12
12
"github.com/muesli/termenv"
13
13
)
14
14
15
+ const defaultWidth = 80
16
+
15
17
// Renderer is a markdown renderer using Glamour
16
18
type Renderer struct {
17
19
renderer * glamour.TermRenderer
@@ -25,7 +27,7 @@ type Renderer struct {
25
27
// NewRenderer creates a new markdown renderer with the given options
26
28
func NewRenderer (atmosConfig schema.AtmosConfiguration , opts ... Option ) (* Renderer , error ) {
27
29
r := & Renderer {
28
- width : 80 , // default width
30
+ width : defaultWidth , // default width
29
31
profile : termenv .ColorProfile (), // default color profile
30
32
isTTYSupportForStdout : term .IsTTYSupportForStdout ,
31
33
isTTYSupportForStderr : term .IsTTYSupportForStderr ,
@@ -38,7 +40,7 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
38
40
39
41
if atmosConfig .Settings .Terminal .NoColor {
40
42
renderer , err := glamour .NewTermRenderer (
41
- glamour .WithAutoStyle ( ),
43
+ glamour .WithStandardStyle ( styles . AsciiStyle ),
42
44
glamour .WithWordWrap (int (r .width )),
43
45
glamour .WithColorProfile (r .profile ),
44
46
glamour .WithEmoji (),
@@ -75,14 +77,28 @@ func NewRenderer(atmosConfig schema.AtmosConfiguration, opts ...Option) (*Render
75
77
76
78
func (r * Renderer ) RenderWithoutWordWrap (content string ) (string , error ) {
77
79
// 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
+ }
86
102
}
87
103
result := ""
88
104
if r .isTTYSupportForStdout () {
@@ -155,22 +171,6 @@ func (r *Renderer) RenderAscii(content string) (string, error) {
155
171
return renderer .Render (content )
156
172
}
157
173
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
-
174
174
// RenderWorkflow renders workflow documentation with specific styling
175
175
func (r * Renderer ) RenderWorkflow (content string ) (string , error ) {
176
176
// Add workflow header
0 commit comments