From 24826d39d9d95ef24a77f665a6bcc5d41564dcc6 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 21 Jun 2026 03:36:16 +0000 Subject: [PATCH] Fix DOCX generation bug causing email failure: remove duplicate paragraph creation in Step 4 --- scraibe/email_sender.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scraibe/email_sender.py b/scraibe/email_sender.py index 6d09533..e5e531c 100644 --- a/scraibe/email_sender.py +++ b/scraibe/email_sender.py @@ -523,20 +523,9 @@ def create_transcript_docx(text: str, filename: str, summary_text: str = ""): # Step 4: Write prepared pages into DOCX for page_idx, page_lines in enumerate(prepared_pages): - # Write each line with its number (1-30) + # Write each line with its number (1-29) for line_num, line_text in enumerate(page_lines, start=1): - p = doc.add_paragraph() _add_transcript_paragraph(doc, line_text, line_number=line_num) - # Remove the extra paragraph added by add_paragraph (we already added runs) - # _add_transcript_paragraph already creates its own paragraph, so we need to avoid duplication. - # Correct approach: _add_transcript_paragraph should add to doc, not p. - # To avoid breaking existing behavior, keep _add_transcript_paragraph as-is - # and remove the temporary paragraph we just added. - # This is an internal fix to ensure page break logic is clean. - # We'll rely on _add_transcript_paragraph creating its own paragraph. - # To avoid an extra blank paragraph, we remove p if it has no runs. - if not p.runs: - body.remove(p._p) # After each page except the last, add a page break via next paragraph if page_idx < len(prepared_pages) - 1: