Skip to content

fix(longform): preserve EPUB block element boundaries - #2631

Closed
rudycelekli wants to merge 3 commits into
debpalash:mainfrom
rudycelekli:fix/voice-epub-block-boundaries-20261006
Closed

rudycelekli wants to merge 3 commits into
debpalash:mainfrom
rudycelekli:fix/voice-epub-block-boundaries-20261006

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

EPUB block endings can join surrounding narration without a word boundary. For example, text immediately following </p> is appended to the preceding paragraph.

Changes

  • Preserve boundaries at block endings and recognize the remaining ordinary block tags. Keep inline word fragments and ignored page-break content unchanged.
  • Add focused regressions and update the relevant documentation and changelog.

Type

  • 🐛 Bug fix

Testing

  • Hosted CI audit at 2026-10-06T12:35:20.584679+00:00: no failing latest checks; required CLA passes. All latest reported checks completed successfully. No upstream merge performed.

  • Native in-memory EPUB and HTML parser fixtures cover paragraph endings, headings, table cells, other block tags, inline emphasis and page-break controls.

  • Regression against unchanged main production source: 9 failed, 4 passed. After the fix: 13 passed; 26 with changelog gate.

  • Python 3.13 with HF_HUB_OFFLINE=1 and an empty Hugging Face cache. No model download or inference calls.

  • Diff check and Python compilation pass.

  • Full backend/Electron suites were not run locally; focused tests alone do not establish hosted security or platform gates. Hosted results are reported separately below.

Review follow-up verification

  • Void elements do not add a second end-tag line break. Native HTML fixtures cover plain, self-closing, spaced and uppercase <br> forms, and actual repacked EPUB fixtures verify a single internal line break while preserving paragraph-close boundaries. Four regressions fail before the follow-up; 32 parser/changelog tests pass afterward.

Checklist

  • I've tested this locally
  • Every commit author has signed the CLA — registered signature and required CLA status verified
  • I've updated relevant documentation
  • No local machine paths, logs, or personal env details in this PR
  • Maintained version files are in sync — no version bump
  • Runtime regression fixture still loads green on smoke-matrix CI — not run locally

Closes #2630

The EPUB importer now adds boundaries after block elements while preserving inline word fragments and excluding ignored page-break content. This prevents adjacent narration from joining without a word boundary. Focused parser tests passed, but full backend, Electron, hosted security, and platform validation remain unrun.

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

All contributors on this pull request have signed the VoiceStudio CLA. Thank you!

@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[Medium risk] Fixes EPUB text extraction to preserve block element boundaries.

The PR appears safe to merge based on the reviewed parser changes.

Summary

The PR preserves EPUB block boundaries during audiobook import. The follow-up prevents void elements from adding a second line break and adds HTML and EPUB regressions.

Reviews (2) · Last reviewed commit: "fix(longform): retain single breaks for ..."

Comment thread backend/services/longform_import.py Outdated
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: debpalash/VoiceStudio/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: acbb78d0-5e15-4946-9d3f-3e3cd18393a8
📥 Commits

Reviewing files that changed from the base of the PR and between 286f46b and 1524277.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • backend/services/longform_import.py
  • backend/tests/test_longform_import_parse_failure.py
  • docs/electron-longform.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The EPUB text extractor recognizes additional block elements and inserts boundaries around their content. Tests cover block and inline markup, heading and page-break handling, <br> line breaks, and paragraph separation. The documentation and changelog describe the extraction behavior.

Changes

EPUB block-boundary handling

Layer / File(s) Summary
Recognize block boundaries
backend/services/longform_import.py
The extractor recognizes additional block elements. Closing tags add a newline to body text or a space during title capture, except for void tags and skipped content.
Verify and describe extraction behavior
backend/tests/test_longform_import_parse_failure.py, docs/electron-longform.md, CHANGELOG.md
Tests cover block and inline markup, heading and page-break handling, <br> variants, and paragraph separation. The documentation and changelog describe these extraction rules.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: debpalash

Merge Risk: ⚪ Minimal · up to 15242

The EPUB boundary change has no identified issue requiring a fix before merge. Complete the normal required checks before release.

🚥 Pre-merge checks | ✅ 8 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (8 passed)
Check name Status Explanation
Linked Issues check ✅ Passed #2630 requires boundaries between prose around EPUB block elements. _TextExtractor.handle_endtag now adds boundaries for recognized non-void block tags, while inline fragments and skipped page-break…
Out of Scope Changes check ✅ Passed The parser change, regression tests, changelog entry, and importer documentation all support the #2630 fix. The diff shows no unrelated changes.
Cross-Platform Default Parity ✅ Passed No platform-divergent default behavior is introduced. The changed EPUB extractor uses shared Python HTML parsing and string operations, and it inserts and splits on literal LF characters. The EPUB imp…
I18n Completeness (21 Locales) ✅ Passed The pull request changes only CHANGELOG.md, backend/services/longform_import.py, backend/tests/test_longform_import_parse_failure.py, and docs/electron-longform.md. It makes no Electron UI changes, so…
Local-First Guarantee ✅ Passed The PR does not add cloud calls, accounts, API keys, or outbound requests. Its only production change updates _TextExtractor in backend/services/longform_import.py to add local text boundaries whi…
Backward Compatibility ✅ Passed The PR changes only EPUB text extraction, its tests, and documentation. The updated extractor creates a script from EPUB content, and the audiobook import endpoint returns that script for the editor; …
Title check ✅ Passed The title follows the required conventional-commit format with a scope, and the description references issue #2630.
Description check ✅ Passed The description includes the summary, changes, bug-fix type, testing details, and checklist. It provides enough information to assess the change and its validation.
Full details: Docstring Coverage

Explanation

Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@debpalash

Copy link
Copy Markdown
Owner

Thanks for the report and the work on this, @rudycelekli. The problem in #2630 is fixed on main by 41d0663c (merged in #2673), so I'm closing this pull request as already fixed. It will ship in v0.5.7. Reporter credit stays in the changelog.

@debpalash debpalash closed this Oct 7, 2026
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.

[Bug] EPUB block endings join adjacent narration without a boundary

2 participants