Skip to content

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

Open
mattn wants to merge 1 commit intosipeed:mainfrom
mattn:fix/truncation-and-extracttext-bugs
Open

Replace \s+ with [^\S\n]+ to preserve newlines#299
mattn wants to merge 1 commit intosipeed:mainfrom
mattn:fix/truncation-and-extracttext-bugs

Conversation

@mattn
Copy link
Contributor

@mattn mattn commented Feb 16, 2026

extractText in pkg/tools/web.go replaces all whitespace (including newlines) with a single space using \s+, then tries to split by \n to filter empty lines. Since all newlines are already gone, the output is always a single line.

@Leeaandrob
Copy link
Collaborator

@Zepan This PR by @mattn replaces \s+ with [^\S\n]+ in regex patterns to preserve newlines. This is a subtle but important fix — without it, multi-line content gets collapsed into single lines.

Recommendation: Merge. Correct regex behavior that preserves formatting. Well-tested by a contributor who clearly understands Go regex edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants