Skip to content

fix(reader): support TTS for br-only chapter content - #13

Open
beer-on-ice wants to merge 1 commit into
givenge:masterfrom
beer-on-ice:bugfix/tts-br-only-content
Open

fix(reader): support TTS for br-only chapter content#13
beer-on-ice wants to merge 1 commit into
givenge:masterfrom
beer-on-ice:bugfix/tts-br-only-content

Conversation

@beer-on-ice

Copy link
Copy Markdown

问题

当前自动朗读仅从 .chapter-text p 收集段落。一些书源返回的正文使用 <br> 分隔,没有生成任何 <p>,因此段落列表为空;点击“开始”后会直接进入下一章,而不会朗读当前章节。

修改

  • 正常存在 <p> 时保持原来的逐段朗读逻辑不变。
  • 没有 <p>、但正文容器包含有效文本时,将 .chapter-text 容器作为一个朗读目标。
  • 不修改正文 DOM,避免影响阅读排版和其他依赖元素结构的功能。
  • 增加回归测试,覆盖:
    • 仅由文本和 <br> 组成的章节可以开始朗读;
    • 已有 <p> 的章节仍使用原来的段落目标。

验证

  • npm test:20 个测试文件、74 个测试全部通过。
  • npm run build:构建通过。
  • 在实际章节(724 个 <br>、0 个 <p>)中验证:点击“开始”后正常进入播放状态,不再直接跳章。

影响范围

仅调整前端自动朗读目标的收集逻辑,并新增对应单元测试;不涉及后端、数据库或正文缓存格式。

- fall back to the chapter root when rendered content has no paragraphs
- preserve existing paragraph targets without rewriting chapter HTML
- add regression coverage for br-only and paragraph content
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