Skip to content

Commit 0c5be73

Browse files
committed
test message
1 parent 977d2e3 commit 0c5be73

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

internal/commands/mode.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"path/filepath"
88
"sort"
99
"strings"
10+
11+
"github.com/GrayCodeAI/iterate/internal/ui/highlight"
1012
)
1113

1214
// RegisterModeCommands adds agent mode and display commands.
@@ -78,6 +80,7 @@ func registerDisplayNavCommands(r *Registry) {
7880
"/theme", "set color theme", cmdTheme,
7981
"/shortcuts", "list all keyboard shortcuts", cmdShortcuts,
8082
"/providers", "list configured providers and status", cmdProviders,
83+
"/render", "toggle markdown vs raw response rendering", cmdRender,
8184
)
8285
}
8386

@@ -459,3 +462,27 @@ func cmdProviders(ctx Context) Result {
459462
fmt.Printf(" Use %s/provider <name>%s to switch providers.\n\n", ColorBold, ColorReset)
460463
return Result{Handled: true}
461464
}
465+
466+
func cmdRender(ctx Context) Result {
467+
// Toggle or explicitly set: /format [markdown|raw|on|off]
468+
if ctx.HasArg(1) {
469+
arg := strings.ToLower(ctx.Arg(1))
470+
switch arg {
471+
case "markdown", "md", "on", "true":
472+
highlight.MarkdownEnabled = true
473+
case "raw", "plain", "off", "false":
474+
highlight.MarkdownEnabled = false
475+
default:
476+
fmt.Printf("Usage: /format [markdown|raw]\n")
477+
return Result{Handled: true}
478+
}
479+
} else {
480+
highlight.MarkdownEnabled = !highlight.MarkdownEnabled
481+
}
482+
if highlight.MarkdownEnabled {
483+
PrintSuccess("format: markdown (syntax highlighting on)")
484+
} else {
485+
PrintSuccess("format: raw (plain text output)")
486+
}
487+
return Result{Handled: true}
488+
}

internal/ui/highlight/highlight.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ var (
1717
// contextWindow is the assumed token context window size used for % calculations.
1818
const ContextWindow = 200_000
1919

20+
// MarkdownEnabled controls whether RenderResponse applies markdown formatting.
21+
// When false, responses are printed as plain text.
22+
var MarkdownEnabled = true
23+
2024
// RenderResponse prints a markdown response with syntax highlighting.
25+
// If MarkdownEnabled is false, the text is printed raw.
2126
func RenderResponse(text string) {
27+
if !MarkdownEnabled {
28+
fmt.Print(text)
29+
return
30+
}
2231
lines := strings.Split(text, "\n")
2332
inCode := false
2433
lang := ""

0 commit comments

Comments
 (0)