Replace \s+ with [^\S\n]+ to preserve newlines (#299)

This commit is contained in:
mattn
2026-02-19 10:02:28 +09:00
committed by GitHub
parent d167b47431
commit e8afd31b28
2 changed files with 78 additions and 2 deletions
+4 -2
View File
@@ -492,8 +492,10 @@ func (t *WebFetchTool) extractText(htmlContent string) string {
result = strings.TrimSpace(result)
re = regexp.MustCompile(`\s+`)
result = re.ReplaceAllLiteralString(result, " ")
re = regexp.MustCompile(`[^\S\n]+`)
result = re.ReplaceAllString(result, " ")
re = regexp.MustCompile(`\n{3,}`)
result = re.ReplaceAllString(result, "\n\n")
lines := strings.Split(result, "\n")
var cleanLines []string