Fix DOCX generation bug causing email failure: remove duplicate paragraph creation in Step 4
This commit is contained in:
+1
-12
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user