From 7a3bfc50e78da32daa5aadd468d687d87c358b6a Mon Sep 17 00:00:00 2001 From: User Date: Mon, 23 Feb 2026 04:39:14 +0800 Subject: [PATCH] fix: preserve single line breaks, only collapse 2+ consecutive whitespace Address review feedback: the previous \s+ regex was too aggressive and broke text-only summaries with legitimate line breaks. Now: - Collapse runs of 2+ non-newline whitespace into a single space - Collapse 3+ consecutive newlines into double newline (paragraph break) - Single line breaks are preserved --- lib/feed.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/feed.ts b/lib/feed.ts index 6a2f0b0..79e6545 100644 --- a/lib/feed.ts +++ b/lib/feed.ts @@ -232,8 +232,9 @@ export async function parseTextFromHtml(html: string): Promise { // Extract text from body to avoid any artifacts from the document wrapper const text = (document?.querySelector('body')?.textContent || document?.textContent || '') - // Collapse multiple whitespace/newlines into single spaces - .replace(/\s+/g, ' ') + // Collapse runs of 2+ whitespace/newline characters, preserving single line breaks + .replace(/[^\S\n]{2,}/g, ' ') + .replace(/\n{3,}/g, '\n\n') .trim(); return text;