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
This commit is contained in:
@@ -438,12 +438,10 @@ def create_transcript_docx(
|
|||||||
_configure_base_font(doc)
|
_configure_base_font(doc)
|
||||||
_configure_section_margins(doc)
|
_configure_section_margins(doc)
|
||||||
|
|
||||||
# Remove the default empty paragraph so line numbering starts
|
# Fully clear default paragraphs so Word's line numbering starts at line 1
|
||||||
# at the first real line of content (Word counts paragraphs, not text lines).
|
body = doc.element.body
|
||||||
if doc.paragraphs:
|
for p in body.findall(qn('w:p')):
|
||||||
p = doc.paragraphs[0]
|
body.remove(p)
|
||||||
if p.text.strip() == "":
|
|
||||||
p._p.getparent().remove(p._p)
|
|
||||||
|
|
||||||
# Enable line numbering for transcript section
|
# Enable line numbering for transcript section
|
||||||
_enable_line_numbering(doc.sections[0])
|
_enable_line_numbering(doc.sections[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user