Skip to content

DOCX export #97

@TomMaSS

Description

@TomMaSS

Goal

Export a complete PRD as a formatted Word document. Product managers and executives expect Word files.

Backend

Install python-docx in api/requirements.txt.

Endpoint: GET /api/projects/{slug}/export?format=docx

When format=docx:

  1. Load all sections ordered by sort_order
  2. Build a python-docx Document:
    • Title page: project name, description, export date
    • Table of contents (built-in TOC field)
    • For each section:
      • Heading 1: section title
      • Status badge as inline text: "[APPROVED]" / "[DRAFT]" etc.
      • Content: convert markdown to docx paragraphs via markdown-it-py AST
      • Dependencies listed as italic paragraph
    • Appendix: dependency graph as text-based adjacency list
  3. Return as application/vnd.openxmlformats-officedocument.wordprocessingml.document

Markdown-to-docx conversion priorities:

  • Headings (##, ###) -> Word Heading 2, Heading 3
  • Bold, italic -> Run formatting
  • Code blocks -> Monospace font with light gray shading
  • Bullet lists -> Word bullet list
  • Tables -> Word tables
  • Links -> Hyperlinks (or plain text with URL)
  • Anything unconvertible -> render as plain text (no crashes)

Frontend

Add "Export DOCX" option in the project export dropdown alongside existing PDF and Markdown exports. Triggers a download.

Acceptance Criteria

  • Generated .docx opens in Word, Google Docs, LibreOffice without errors
  • All sections present with correct content
  • Markdown formatting (bold, lists, code blocks) renders correctly
  • Status badges visible
  • File downloads with correct filename

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions