Overview
Converts a markdown file to a formatted Word document with proper styles, clickable hyperlinks, inline formatting, lists, tables, blockquotes, code blocks, images, and horizontal rules. Produces a .docx that opens cleanly in Microsoft Word, Google Docs, and LibreOffice.
Workflow
<Definition - Style Defaults>
- Normal: Calibri 11pt, 1.15 line spacing
- Heading 1: Calibri Light 24pt bold, dark blue (#1F3864)
- Heading 2: Calibri Light 18pt bold, medium blue (#2E75B6)
- Heading 3: Calibri Light 14pt bold, medium blue (#2E75B6)
- Heading 4: Calibri Light 12pt bold, medium blue (#2E75B6)
- Code: Consolas 10pt (inline), Consolas 9pt (blocks)
- Lists: Built-in List Bullet and List Number styles with level 2 variants for nesting </Definition - Style Defaults>
<Workflow - Convert description="Convert a markdown file to a formatted Word document." tools=[run_python, file_read, open_in_session_tab] triggers=["convert to Word", "export as docx", "make a Word doc", "markdown to docx", "turn .md into document"]
-
[Agent] Identify the source markdown file path. If the user provided a path, use it. If the user mentioned a file by name, locate it with file_read or folder_list. If the content is inline (pasted markdown), write it to a temp .md file first. Validate: source_path points to an existing .md file. If fails: Ask user for the correct path.
-
[Agent] Determine the output path. If the user specified one, use it. Otherwise, replace the .md extension with .docx in the same directory. Validate: output_path ends in .docx and the parent directory is writable. If fails: Default to workspace/artifacts/{filename}.docx.
-
[Agent] Run the conversion script via run_python. The script is in scripts/convert.py. Execute it inline:
- Define all functions from the script in the run_python namespace.
- Call convert_markdown_to_docx(source_path, output_path, title).
- Print the result path, file size, and verification stats (paragraph count, table count, hyperlink count). Validate: Script completes without exception and output file exists with size > 0. If fails: Read the traceback, identify the problematic markdown line, fix or skip it, and retry.
-
[Agent] Open the output .docx file in a session tab for the user to review. Validate: open_in_session_tab returns success. If fails: Report the file path so the user can open it manually.
-
[Agent] Report results to the user: output path, file size, paragraph count, table count, and hyperlink count. Note any skipped elements (missing images, malformed tables). Validate: Summary is concise and accurate. If fails: At minimum, report the output path.
</Workflow - Convert>
- Unit tests (scripts/tests/unit/test_convert.py) provide filesystem-free coverage of the scripts. Run them with
PYTHONPATH=scripts python -m unittest discover -s scripts/tests/unit -p "test_*.py".


