From 7fac0e7d9c2fbf9afc59082753353d43e3f05b25 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 15 Jun 2026 16:26:28 +0000 Subject: [PATCH] Fix transcript DOCX line numbering starting at line 2 (robust) - Fully clear default paragraphs from document body so Word's line numbering starts at the first real line --- scraibe/email_sender.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scraibe/email_sender.py b/scraibe/email_sender.py index 975452b..f9b1433 100644 --- a/scraibe/email_sender.py +++ b/scraibe/email_sender.py @@ -438,12 +438,10 @@ def create_transcript_docx( _configure_base_font(doc) _configure_section_margins(doc) - # Remove the default empty paragraph so line numbering starts - # at the first real line of content (Word counts paragraphs, not text lines). - if doc.paragraphs: - p = doc.paragraphs[0] - if p.text.strip() == "": - p._p.getparent().remove(p._p) + # Fully clear default paragraphs so Word's line numbering starts at line 1 + body = doc.element.body + for p in body.findall(qn('w:p')): + body.remove(p) # Enable line numbering for transcript section _enable_line_numbering(doc.sections[0])