@QingQ77: 一个 Open WebUI 工具,用 python-docx 把模型产出的 Markdown(含 YAML 头)或 JSON 规范直接生成为原生、可编辑的 Word(.docx)文档。 https://github.com/ianuste…
Summary
一个 Open WebUI 工具,使用 python-docx 将模型产出的 Markdown(含 YAML 头)或 JSON 规范直接生成为原生、可编辑的 Word (.docx) 文档,支持多种模板和样式。
View Cached Full Text
Cached at: 07/11/26, 05:28 PM
一个 Open WebUI 工具,用 python-docx 把模型产出的 Markdown(含 YAML 头)或 JSON 规范直接生成为原生、可编辑的 Word(.docx)文档。 https://github.com/ianustec/openwebui-generate-documents…
ianustec/openwebui-generate-documents
Source: https://github.com/ianustec/openwebui-generate-documents
Generate Documents — Native DOCX engine for Open WebUI
A Open WebUI Tool that generates
native Word (.docx) documents from Markdown (with YAML frontmatter) or a JSON
spec produced by the model. It doesn’t export HTML or PDF: it builds the document
directly with python-docx, with a coherent design system — cover pages, numbered
headings with rules, styled tables, callouts, code blocks, signatures, TOC and a
running header/footer.
The resulting file is saved through Open WebUI’s Files API (with a /cache/files
fallback) and a clickable download link appears in the chat.
License: MIT · Author: IANUSTEC

Document generated from the example examples/report.md → examples/demo_report.docx.
Features
- Native, editable .docx (text, tables and styles are editable in Word / Pages / LibreOffice).
- Dual input, auto-detected: Markdown-with-frontmatter (preferred) or JSON — same output.
- 7 templates with a coherent palette derived from a single
accentcolor:report,whitepaper,proposal,letter,memo,minutes,blank. - Cover pages:
band(accent panel),rule(editorial) orplain. - Numbered headings (1, 1.1, 1.1.1) with H1/H2 accent rules — auto-strips any manual number.
- Rich tables: filled accent header, zebra rows, automatic right-alignment of numeric/currency columns.
- Callouts:
info,success,warning,danger(colored bar + tint). - Lists (bullets, ordered, checklists), blockquotes, code blocks, signatures, TOC, page breaks.
==highlight==maps to accent-colored emphasis; smart quotes; typographic spacing.- Header / footer with 3 zones (
left/center/right) and live page numbers ({{page}}/{{pages}}). - Human-readable filename derived from the title (e.g.
Q3 Board Report.docx). - Optional images from Unsplash (with a key) or generated via Open WebUI.
- Single-file: one self-contained
.py, ready to paste into the Tools registry.
Requirements
- Open WebUI
>= 0.4.0 - Python:
python-docx,Pillow,markdown-it-py,mdit-py-plugins,PyYAML,lxml(declared in the frontmatter → Open WebUI installs them automatically) - Optional:
httpx(fetch images from URL / Unsplash)
Installation
Option A — from the Open WebUI community
- Open the tool page on the Open WebUI community site.
- Click Get / Import to your instance.
Option B — manual
- In your Open WebUI instance go to Workspace → Tools → +.
- Paste the contents of
generate_documents.py. - Save. The declared dependencies are installed on first use.
- Enable the tool for the model (or chat) that should use it.
Usage
The model calls generate_document(content), where content is either
Markdown-with-frontmatter (preferred) or a JSON string.
Markdown (preferred)
---
template: report
title: "Digital Transformation Program — FY 2026"
subtitle: "Strategic plan, roadmap and budget"
author: "Northwind Analytics"
cover: auto
header:
left: "Northwind Analytics — Confidential"
right: "Rev. 1.0"
footer:
center: "Page {{page}} of {{pages}}"
styles:
accent: "#1B6B93"
---
# Executive Summary
Revenue grew **24%** year over year.
::: callout type="success" title="Highlight"
Operating margin expanded by ==6 pp==.
:::
| Objective | KPI target | Priority |
|-----------|-----------|----------|
| Process automation | 80% of flows | ==High== |
See the full example in examples/report.md.
JSON (legacy, still supported)
{
"template": "report",
"title": "FY 2026 Report",
"cover": "auto",
"styles": { "accent": "#1B6B93" },
"blocks": [
{ "type": "heading", "level": 1, "text": "Executive Summary" },
{ "type": "paragraph", "text": "Revenue grew 24% YoY." },
{ "type": "callout", "kind": "success", "title": "Highlight", "text": "Margin +6pp." }
]
}
Templates
report · whitepaper · proposal · letter · memo · minutes · blank.
Every template derives its full palette from a single accent color, so
styles: { accent: "#C0392B" } re-themes the whole document.
Content blocks (Markdown syntax)
| Block | Syntax |
|---|---|
| Headings | # H1 … #### H4 (auto-numbered in report/whitepaper) |
| Emphasis | **bold**, *italic*, `code`, ==highlight== |
| Lists | - bullet, 1. ordered, - [ ] checklist |
| Table | standard Markdown pipe table (numeric columns auto right-aligned) |
| Callout | ::: callout type="info|success|warning|danger" title="..." … ::: |
| Quote | > quoted text |
| Code | fenced ``` block |
| Signature | ::: signature name="..." role="..." date="..." … ::: |
| TOC | [[toc]] |
| Page break | \newpage |
Screenshots
| Cover | Content |
|---|---|
![]() | ![]() |
| Callouts & tables | Risk matrix & signatures |
![]() | ![]() |
Valves (configuration)
| Valve | Default | Description |
|---|---|---|
default_template | blank | Template used when the spec doesn’t set one |
unsplash_access_key | "" | Unsplash key for stock images (optional) |
image_generation_url | "" | OpenAI-compatible image endpoint (optional) |
image_generation_api_key | "" | Bearer token for image_generation_url |
docx_export_dir | /app/backend/data/cache/files | Fallback directory for saving |
emit_status | true | Emit status events in chat |
How it works
- The model produces Markdown (or JSON) and calls
generate_document. - The parser normalizes both formats into one spec, merges it with the template defaults, and resolves the accent palette.
- Each block is written as native OOXML (paragraphs, tables, shading, borders, fields).
- The
.docxis saved via the Files API (fallback/cache/files) and the link is returned in chat.
Local development / testing
Requires python-docx, markdown-it-py, mdit-py-plugins, PyYAML (and optionally pillow/httpx):
pip install python-docx pillow httpx markdown-it-py mdit-py-plugins PyYAML
python examples/build.py # → examples/demo_report.docx
The file is designed to run inside Open WebUI: the open_webui.* imports are optional
and the tool degrades gracefully when they’re missing (handy for isolated render tests).
Contributing
Issues and PRs welcome. Please keep the file single-file and free of mandatory network dependencies for the core features.
License
MIT © IANUSTEC
Similar Articles
@Chenzeze777: Microsoft open-sourced a document tool with 140k stars — I compiled its 5 most practical use cases. MarkItDown, a Python tool, converts PDF/Word/PPT/Excel/HTML/images into clean Markdown text with one click. What you can do with it: · P…
Microsoft open-sourced MarkItDown, a lightweight Python tool that converts PDF, Word, PPT, Excel, HTML, and images into clean, structured Markdown text in one go, ideal for AI summarization, data analysis, knowledge base construction, and more.
@MindfulReturn: I've decided that from now on, my output won't be docx, PPT, pdf, or md—it will be HTML. With this html-anything, I can turn all the above into HTML. Sharing only takes a few hundred KB, whereas sharing the same content as docx before was at least 2MB.
This tool allows users to convert documents (docx, PPT, pdf, md) into HTML format, and edit them using an AI agent CLI. It supports multiple output formats, is local-first, and open source.
@kiwiflysky: Highly recommend @xicilion's Markdown plugin (https://docu.md). Finally found one that renders PlantUML diagrams without overlapping lines, making them human-readable. Figure 1 is the plugin-rendered version, Figure 2 is the original.
Recommend a Markdown plugin docu.md that perfectly renders PlantUML and other diagrams, and supports exporting to DOCX, PDF, HTML, etc. Suitable for beautifying and publishing AI-generated Markdown documents.
@Jolyne_AI: When writing technical documentation, we often use Markdown, but it falls short when dealing with complex layouts. I stumbled upon an open-source tool on GitHub: Quarkdown. Think of it as "Markdown on steroids" — it keeps the lightweight syntax but cranks up formatting, generation, and automation to the max. GitH…
Quarkdown is an enhanced typesetting system based on Markdown, supporting variables and functions, multi-format output, real-time preview and other powerful features. It is suitable for books, papers, presentations, etc. Installation requires Java 17+.
@nini_incrypto_: A severely underrated side hustle: converting files to Markdown for others. There's a tool called markitdown on GitHub, made by Microsoft. It can convert Word / Excel / PDF / PPT all to Markdown.
Introducing Microsoft's open-source tool markitdown, which can convert Word, Excel, PDF, PPT and other files into Markdown format, suitable as a side hustle.



