Explorar o código

fix(tui): less incorrect escapingn of < and >

adamdottv hai 8 meses
pai
achega
5e79e3d7a5
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      packages/tui/internal/components/chat/message.go

+ 4 - 2
packages/tui/internal/components/chat/message.go

@@ -25,8 +25,6 @@ import (
 func toMarkdown(content string, width int, backgroundColor compat.AdaptiveColor) string {
 	r := styles.GetMarkdownRenderer(width, backgroundColor)
 	content = strings.ReplaceAll(content, app.RootPath+"/", "")
-	content = strings.ReplaceAll(content, "<", "\\<")
-	content = strings.ReplaceAll(content, ">", "\\>")
 	rendered, _ := r.Render(content)
 	lines := strings.Split(rendered, "\n")
 
@@ -230,6 +228,10 @@ func renderText(message client.MessageInfo, text string, author string) string {
 	if message.Role == client.Assistant {
 		markdownWidth = width - padding - 4 - 2
 	}
+	if message.Role == client.User {
+		text = strings.ReplaceAll(text, "<", "\\<")
+		text = strings.ReplaceAll(text, ">", "\\>")
+	}
 	content := toMarkdown(text, markdownWidth, t.BackgroundPanel())
 	content = strings.Join([]string{content, info}, "\n")