fix: removeCodeBlocks 给每行末尾追加 \n 导致发送消息多一个换行
改为用 strings.Join 拼接,只在行间加 \n,末行不追加。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -594,20 +594,17 @@ func removeHeadings(s string) string {
|
||||
}
|
||||
|
||||
func removeCodeBlocks(s string) string {
|
||||
result := ""
|
||||
var kept []string
|
||||
inCode := false
|
||||
for _, line := range splitLines(s) {
|
||||
if hasPrefix(line, "```") {
|
||||
inCode = !inCode
|
||||
continue
|
||||
}
|
||||
if inCode {
|
||||
result += line + "\n"
|
||||
} else {
|
||||
result += line + "\n"
|
||||
}
|
||||
kept = append(kept, line)
|
||||
}
|
||||
return result
|
||||
_ = inCode
|
||||
return strings.Join(kept, "\n")
|
||||
}
|
||||
|
||||
func splitLines(s string) []string {
|
||||
|
||||
Reference in New Issue
Block a user