Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

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:

  1. Trimming Header Text: The h* tag handler in ParseNodesForPassage now trims the text content before wrapping it in bold tags. This removes internal newlines that were being bolded.
  2. Whitespace Normalization: Introduced a CleanPassageText function 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.
  3. Performance Optimization: The regex is compiled once at the package level.

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

- 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.
@google-labs-jules
Copy link
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@julwrites julwrites marked this pull request as ready for review January 5, 2026 17:39
@julwrites julwrites merged commit 673da16 into staging Jan 5, 2026
1 check passed
@julwrites julwrites deleted the fix-passage-headers-18071459911303667092 branch January 5, 2026 17:39
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