Fix line numbering: only transcript pages; ensure page numbering fields are set correctly
Mirror and run GitLab CI / build (push) Has been cancelled
Ruff / ruff (push) Has been cancelled

This commit is contained in:
admin
2026-06-14 22:25:26 +00:00
parent e0d2fd6963
commit 2f9299389b
+27 -14
View File
@@ -291,6 +291,29 @@ def send_email(
raise EmailError(f"Failed to send email: {e}")
def _remove_line_numbering(section):
"""
Explicitly remove line numbering from a section.
"""
sectPr = section._sectPr
lnNumType = sectPr.find(qn("w:lnNumType"))
if lnNumType is not None:
sectPr.remove(lnNumType)
def _enable_line_numbering(section):
"""
Enable continuous line numbering for a section.
"""
sectPr = section._sectPr
lnNumType = sectPr.find(qn("w:lnNumType"))
if lnNumType is None:
lnNumType = OxmlElement("w:lnNumType")
sectPr.append(lnNumType)
lnNumType.set(qn("w:start"), "continuous")
lnNumType.set(qn("w:countBy"), "1")
def _setup_docx_style(doc, enable_line_numbering=False):
"""
Base document setup (margins, font, footer).
@@ -304,13 +327,9 @@ def _setup_docx_style(doc, enable_line_numbering=False):
# Line numbering (only for transcript sections)
if enable_line_numbering:
sectPr = section._sectPr
lnNumType = sectPr.find(qn("w:lnNumType"))
if lnNumType is None:
lnNumType = OxmlElement("w:lnNumType")
sectPr.append(lnNumType)
lnNumType.set(qn("w:start"), "continuous")
lnNumType.set(qn("w:countBy"), "1")
_enable_line_numbering(section)
else:
_remove_line_numbering(section)
# Default font
style = doc.styles["Normal"]
@@ -583,13 +602,7 @@ def create_combined_docx(
section_transcript.bottom_margin = Inches(1.0)
# Enable line numbering in transcript section
sectPr = section_transcript._sectPr
lnNumType = sectPr.find(qn("w:lnNumType"))
if lnNumType is None:
lnNumType = OxmlElement("w:lnNumType")
sectPr.append(lnNumType)
lnNumType.set(qn("w:start"), "continuous")
lnNumType.set(qn("w:countBy"), "1")
_enable_line_numbering(section_transcript)
# 5) Transcript content (with line numbering)
_add_transcript_content(doc, transcript_text)