Skip to content

fix(tts): skip br elements in PDF text layer to prevent TTS interruptions, closes #3771#3811

Merged
chrox merged 1 commit intomainfrom
fix/tts-pdf-line-breaks-3771
Apr 9, 2026
Merged

fix(tts): skip br elements in PDF text layer to prevent TTS interruptions, closes #3771#3811
chrox merged 1 commit intomainfrom
fix/tts-pdf-line-breaks-3771

Conversation

@chrox
Copy link
Copy Markdown
Collaborator

@chrox chrox commented Apr 9, 2026

Summary

  • PDF.js TextLayer renders <br> elements between text spans for visual line wrapping within paragraphs
  • The TTS SSML generator was converting these to <break> elements, causing TTS engines to pause at every PDF line break
  • Fix detects PDF documents (via .textLayer presence) and adds br, canvas, and annotationLayer to the node filter reject list, preventing spurious SSML breaks

Test plan

  • Added 2 new tests verifying <br> elements in PDF text layers don't produce SSML <break> elements
  • All 24 PDF TTS tests pass
  • Full test suite passes (3123 tests)
  • Lint passes
  • Manual test: open a PDF with multi-line paragraphs and verify TTS reads through line breaks without pausing

🤖 Generated with Claude Code

@chrox chrox force-pushed the fix/tts-pdf-line-breaks-3771 branch 3 times, most recently from 65fa4e3 to d35952c Compare April 9, 2026 18:27
…ions at line breaks, closes #3771

PDF.js TextLayer renders <br> between text spans for visual line wrapping.
The TTS SSML generator was converting these to <break> elements, causing
TTS engines to pause at every PDF line break within paragraphs. Fix by
rejecting <br> (along with canvas and annotationLayer) via the node filter
when the document is detected as a PDF.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chrox chrox force-pushed the fix/tts-pdf-line-breaks-3771 branch from d35952c to 493c808 Compare April 9, 2026 18:29
@chrox chrox merged commit a5690e9 into main Apr 9, 2026
7 checks passed
@chrox chrox deleted the fix/tts-pdf-line-breaks-3771 branch April 9, 2026 18:34
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.

1 participant