---
metadata.spec: USF/1.0
name: markdown-to-amazon-narrative
display_name: Markdown to Amazon Narrative
icon: "📄"
description: "Convert Markdown files to Amazon narrative-formatted Word documents (.docx). Uses the embedded Writing Hub template for pixel-accurate rendering. Optionally upload to OneDrive/SharePoint with comment permissions."
version: 2.2.0
trigger: "convert to narrative, md to docx, markdown to word, narrative format, convert this to word, make this a narrative, export as docx, format as narrative"
last_validated: 2026-06-19
model_compatibility: [fast, balanced, smart]
code_first: true
inputs:
  - name: md_path
    description: "Path to the Markdown file to convert. Accepts absolute path or workspace-relative path."
    type: string
author: gesked
tools: [run_python, file_read, open_in_session_tab, open_file]
requires:
  mcp: []
  optional_mcp: [amazon_onedrive]
---

# Markdown to Amazon Narrative v2.2.0

Converts a Markdown file with YAML front matter into a properly-formatted Amazon narrative .docx. Uses the real Writing Hub template (embedded, self-extracts on first run) so output matches pixel-for-pixel.

## What it does

- Parses front matter (title, team, author, date, classification, line_numbers)
- Maps markdown to Word styles (Normal, Heading 1-3, List Paragraph, tables, code blocks)
- Builds header/footer from metadata, sets dc:creator
- Output filename: {slug}-{author}-{YYYY-MM-DD}.docx (fully code-driven, zero LLM discretion)
- Optional OneDrive upload with comment permissions

## Changes from v2.1.1

- BUG FIX: Filename is now fully code-driven. Removed `output_path` param. Function derives slug from front-matter title > H1 > filename, slugifies, truncates to 60 chars at word boundary, saves to `WORKSPACE_DIR/artifacts/{slug}-{author}-{YYYY-MM-DD}.docx`. Zero LLM discretion on naming.
- BUG FIX: `open_in_session_tab` title now equals the filename stem (not a display name), preventing save-as filename mismatch.
- Version bump to 2.2.0, last_validated 2026-06-19

## Template

Amazon Writing Hub Narrative Template, snapshot 2026-06-17.
Source: https://w.amazon.com/bin/view/WritingHub/Document_Repository/Narrative/

Template is embedded as base64 for single-file distribution. Self-extracts on first run.

## Template formatting

- 10pt Calibri body (Normal style), single-spaced, 6pt after
- Headings: 11pt Calibri bold. H1 has bottom rule line. H3 has underline.
- US Letter, 0.75in L/R margins, 1in T/B
- Header: date, team, title (9pt)
- Footer: classification left, page numbers right (field codes)
- Line numbers: continuous, in margin
- Tables: gray borders, 9pt
- Code blocks: Consolas 9pt

## Front matter

```yaml
---
title: "Doc Title"
team: "Team Name"
author: "alias"
date: "June 2026"
classification: "Amazon Confidential"
line_numbers: true
---
```

## Triggers

- convert to narrative
- md to docx
- markdown to word
- narrative format
- convert this to word
- make this a narrative
- export as docx
- format as narrative
