Improve summary prompt, add markdown-to-DOCX styling, and add cover pages
Mirror and run GitLab CI / build (push) Waiting to run
Ruff / ruff (push) Waiting to run

- Configurable summary prompts via ENV or file; stronger default prompt.
- New docx_styles.py: converts markdown (headings, bullets, bold/italic) to DOCX.
- Updated create_summary_docx to use markdown-aware styling.
- New docx_cover.py: reusable cover page for transcript and summary.
- Cover pages enabled when COVER_PAGE_ENABLED=true.
This commit is contained in:
admin
2026-06-19 17:16:46 +00:00
parent 54414def26
commit 7a31be9de5
4 changed files with 369 additions and 37 deletions
+32 -11
View File
@@ -505,7 +505,19 @@ def create_transcript_docx(text: str, filename: str):
_create_transcript_section_properties(doc.sections[0])
# Step 3: Write prepared pages into DOCX
# Step 3: Optionally add cover page
from . import docx_cover
cover_enabled = os.getenv("COVER_PAGE_ENABLED", "false").strip().lower() in ("true", "1", "yes")
if cover_enabled:
docx_cover.add_cover_page(
doc,
title="TRANSCRIPT",
subtitle=None,
metadata=None,
include_logo=True,
)
# Step 4: Write prepared pages into DOCX
for page_idx, page_lines in enumerate(prepared_pages):
# Insert page break between pages
if page_idx > 0:
@@ -523,7 +535,7 @@ def create_transcript_docx(text: str, filename: str):
for line_num, line_text in enumerate(page_lines, start=1):
_add_transcript_paragraph(doc, line_text, line_number=line_num)
# Step 4: Add footer: "X of Y" centered
# Step 5: Add footer: "X of Y" centered
section = doc.sections[0]
footer = section.footer
footer.is_linked_to_previous = False
@@ -563,8 +575,10 @@ def create_summary_docx(text: str, filename: str):
Create a summary DOCX with:
- 1" margins on all sides
- 12pt Courier font
- No line numbering
- Markdown-aware WYSIWYG styling (headings, bullets, bold/italic)
"""
from . import docx_styles
doc = Document()
# Base font
@@ -584,13 +598,20 @@ def create_summary_docx(text: str, filename: str):
for p in list(body.findall(f"{{{W_NS}}}p")):
body.remove(p)
# Add summary content
lines = text.strip().splitlines()
for line in lines:
line = line.strip()
if not line:
continue
p = doc.add_paragraph(line)
p.paragraph_format.space_after = Pt(4)
# Optionally add cover page
from . import docx_cover
cover_enabled = os.getenv("COVER_PAGE_ENABLED", "false").strip().lower() in ("true", "1", "yes")
if cover_enabled:
docx_cover.add_cover_page(
doc,
title="SUMMARY",
subtitle=None,
metadata=None,
include_logo=True,
)
# Add summary content using markdown-aware styling
if text.strip():
docx_styles.parse_simple_md_to_paragraphs(doc, text.strip())
doc.save(filename)