From 8ff473f3e66c4cbb17cb602a87abcf2b47d6c1ed Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 16 Jun 2026 16:00:09 +0000 Subject: [PATCH] Fix transcript DOCX line numbering starting at 2 (docGrid) - Disable document grid (w:type='none') when enabling line numbering - Prevents Word from treating an empty grid line as line 1 --- scraibe/email_sender.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scraibe/email_sender.py b/scraibe/email_sender.py index 6596dfe..7ea7910 100644 --- a/scraibe/email_sender.py +++ b/scraibe/email_sender.py @@ -327,9 +327,15 @@ def _configure_section_margins(doc, margin=1.0): def _enable_line_numbering(section, start_at=1, count_by=1, restart=True): """ Enable line numbering for a specific section. + Disables the document grid so Word counts lines based on content, not grid lines. """ sectPr = section._sectPr + # Disable document grid to avoid Word treating a grid line as line 1 + docGrid = sectPr.find(qn("w:docGrid")) + if docGrid is not None: + docGrid.set(qn("w:type"), "none") + # Create the line numbering element: lnNumType = OxmlElement("w:lnNumType") lnNumType.set(qn("w:start"), str(start_at))