Word Document Generator
Create professional Word documents using company templates. Write content
in Markdown, convert to styled .docx via bundled scripts.
Workflow
- •Gather Context: Clarify scope, data sources, template choice
- •Generate Charts: If needed, create images using
chart_generator.py - •Write Markdown: Create content file with YAML frontmatter
- •Convert: Run
md_to_docx.pyto produce final document
Templates
Store templates in templates/ directory. Each template can have:
- •
template_name.docx— The styled Word template - •
template_name.palette.json— Optional color palette for charts
The template provides fonts, margins, header/footer, and named styles. Content is generated and appended by the converter.
Creating a Document
Step 1: Prepare Charts (if needed)
bash
uv run python scripts/chart_generator.py \ --type line \ --data /path/to/data.csv \ --x "month" --y "revenue" \ --palette "#1a73e8,#34a853" \ --output charts/revenue.png
Supported types: line, bar, scatter, area, pie, heatmap, box
Step 2: Write Content Markdown
Create a .md file with YAML frontmatter:
markdown
---
template: templates/report.docx
placeholders:
client_name: "Acme Corp"
date: "2026-01-18"
project_code: "PRJ-001"
---
# Executive Summary
This report analyzes {{client_name}}'s Q1 performance...
## Revenue Analysis
| Quarter | Revenue | Growth |
|---------|---------|--------|
| Q1 | €1.2M | +12% |

## Recommendations
1. **Expand** northern operations
2. **Monitor** supply chain costs
Step 3: Convert to Word
bash
uv run python scripts/md_to_docx.py \ --input content.md \ --template templates/report.docx \ --output final_report.docx
Supported Markdown
See references/markdown_syntax.md for full syntax reference.
Quick reference:
- •
# H1through###### H6→ Heading styles - •
**bold**,*italic*,`code` - •
- bulletand1. numberedlists - •
| tables |with headers - •
→ Centered images - •
{{placeholder}}→ YAML value substitution
Error Handling
| Issue | Behavior |
|---|---|
| Template not found | Create blank document, warn |
| Missing placeholder | Leave {{var}} visible, warn |
| Image not found | Insert [Image not found: path] |
| Invalid markdown | Skip block, continue |
Adding New Templates
- •Create styled
.docxwith heading styles, fonts, margins - •Drop into
templates/folder - •(Optional) Add
template_name.palette.json:json{"colors": ["#1a73e8", "#34a853", "#ea4335", "#fbbc04"]}