Ensure appropriate speech pauses by adding newlines at epub processing

This commit is contained in:
Vladimir Sol
2026-02-17 19:59:03 -08:00
parent cc9c2a22ba
commit 2c15d2f78a
2 changed files with 11 additions and 2 deletions
+5 -1
View File
@@ -915,7 +915,11 @@ class EpubParser(BaseBookParser):
if slice_html.strip():
slice_soup = BeautifulSoup(slice_html, "html.parser")
for tag in slice_soup.find_all(["p", "div"]):
# Add line breaks after block-level elements to ensure pauses in speech
for tag in slice_soup.find_all(
["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote"]
):
tag.append("\n\n")
for ol in slice_soup.find_all("ol"):
+6 -1
View File
@@ -1023,8 +1023,13 @@ class EpubExtractor:
if not html:
return ""
soup = BeautifulSoup(html, "html.parser")
for tag in soup.find_all(["p", "div"]):
# Add line breaks after block-level elements to ensure pauses in speech
for tag in soup.find_all(
["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote"]
):
tag.append("\n\n")
for ol in soup.find_all("ol"):
start_attr = ol.get("start")
try: