Fix line numbering: only transcript pages; ensure page numbering fields are set correctly
This commit is contained in:
+27
-14
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user