Fix excessive vertical whitespace in passage headers#181
Conversation
- Updated `ParseNodesForPassage` to trim header text. - Added `CleanPassageText` with regex cleanup to normalize newlines to max 2. - Verified with reproduction test case covering the reported issue. - Ensured existing tests pass.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This change fixes the issue where excessive vertical whitespace (large gaps) appeared before headers in Telegram messages for Bible passages. This was caused by the accumulation of newlines from various HTML elements (paragraphs, spans, headers) and whitespace text nodes.
The fix involves:
h*tag handler inParseNodesForPassagenow trims the text content before wrapping it in bold tags. This removes internal newlines that were being bolded.CleanPassageTextfunction that uses a regular expression (\n\s*\n[\s\n]*->\n\n) to collapse any sequence of 3 or more newlines (including those with intervening spaces) into a standard double newline (one blank line). This runs on the final parsed text string.This solution is robust against variations in the input HTML structure and ensures consistent spacing without modifying the fragile logic for individual elements like
span.PR created automatically by Jules for task 18071459911303667092 started by @julwrites