diff --git a/scraibe/email_sender.py b/scraibe/email_sender.py index d55d789..bed38b5 100644 --- a/scraibe/email_sender.py +++ b/scraibe/email_sender.py @@ -318,7 +318,7 @@ def _create_transcript_section_properties(section): - Margins: 1 inch all sides - Single column layout - Line numbering: start=1, countBy=1, restart each page - - Disable document grid to avoid off-by-one line numbering + - Remove document grid to avoid off-by-one line numbering """ sectPr = section._sectPr @@ -341,10 +341,13 @@ def _create_transcript_section_properties(section): _set_element_attr(cols, "num", "1") _set_element_attr(cols, "space", "720") - # Disable document grid to avoid Word counting phantom grid lines - docGrid = sectPr.find(f"{{{W_NS}}}docGrid") - if docGrid is not None: - _set_element_attr(docGrid, "type", "none") + # Remove document grid entirely to avoid phantom grid-based line numbering + for docGrid in sectPr.findall(f"{{{W_NS}}}docGrid"): + sectPr.remove(docGrid) + + # Ensure exactly one lnNumType element (remove any existing) + for lnNumType in sectPr.findall(f"{{{W_NS}}}lnNumType"): + sectPr.remove(lnNumType) # Line numbering: start=1, countBy=1, restart each page lnNumType = OxmlElement("w:lnNumType")