Export to Word¶
Action v0.4.3
Export conversation to Word (.docx) with syntax highlighting, native math equations, Mermaid diagrams, citations, and enhanced table formatting.
Overview¶
The Export to Word plugin converts chat messages from Markdown to a polished Word document. It handles headings, lists, tables, code blocks, and blockquotes while keeping both English and Chinese text rendering clean.
Features¶
- One-Click Export: Adds an "Export to Word" action button to the chat.
- Markdown Conversion: Converts Markdown syntax to Word formatting (headings, bold, italic, code, tables, lists).
- Syntax Highlighting: Code blocks are highlighted with Pygments (supports 500+ languages).
- Native Math Equations: LaTeX math (
$$...$$,\[...\],$...$,\(...\)) converted to editable Word equations. - Mermaid Diagrams: Mermaid flowcharts and sequence diagrams rendered as images in the document.
- Citations & References: Auto-generates a References section from OpenWebUI sources with clickable citation links.
- :material-brain-off: Reasoning Stripping: Automatically removes AI thinking blocks (
<think>,<analysis>) from exports. - Enhanced Tables: Smart column widths, column alignment (
:---,---:,:---:), header row repeat across pages. - Blockquote Support: Markdown blockquotes are rendered with left border and gray styling.
- Multi-language Support: Properly handles both Chinese and English text.
- Smarter Filenames: Configurable title source (Chat Title, AI Generated, or Markdown Title).
Configuration¶
You can configure the following settings via the Valves button in the plugin settings:
| Valve | Description | Default |
|---|---|---|
TITLE_SOURCE | Source for document title/filename. Options: chat_title, ai_generated, markdown_title | chat_title |
MAX_EMBED_IMAGE_MB | Maximum image size to embed into DOCX (MB). | 20 |
UI_LANGUAGE | User interface language. Options: en (English), zh (Chinese). | en |
FONT_LATIN | Font name for Latin characters. | Times New Roman |
FONT_ASIAN | Font name for Asian characters. | SimSun |
FONT_CODE | Font name for code blocks. | Consolas |
TABLE_HEADER_COLOR | Table header background color (Hex without #). | F2F2F2 |
TABLE_ZEBRA_COLOR | Table alternating row background color (Hex without #). | FBFBFB |
MERMAID_JS_URL | URL for the Mermaid.js library. | https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js |
MERMAID_JSZIP_URL | URL for the JSZip library (required for DOCX manipulation). | https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js |
MERMAID_PNG_SCALE | Scale factor for Mermaid PNG generation (Resolution). | 3.0 |
MERMAID_DISPLAY_SCALE | Scale factor for Mermaid visual size in Word. | 1.0 |
MERMAID_OPTIMIZE_LAYOUT | Automatically convert LR (Left-Right) flowcharts to TD (Top-Down). | False |
MERMAID_BACKGROUND | Background color for Mermaid diagrams (e.g., white, transparent). | transparent |
MERMAID_CAPTIONS_ENABLE | Enable/disable figure captions for Mermaid diagrams. | True |
MERMAID_CAPTION_STYLE | Paragraph style name for Mermaid captions. | Caption |
MERMAID_CAPTION_PREFIX | Caption prefix label (e.g., 'Figure'). Empty = auto-detect based on language. | "" |
MATH_ENABLE | Enable LaTeX math block conversion. | True |
MATH_INLINE_DOLLAR_ENABLE | Enable inline $ ... $ math conversion. | True |
🔥 What's New in v0.4.3¶
User-Level Configuration (UserValves)¶
Users can override the following settings in their personal settings: - TITLE_SOURCE - UI_LANGUAGE - FONT_LATIN, FONT_ASIAN, FONT_CODE - TABLE_HEADER_COLOR, TABLE_ZEBRA_COLOR - MERMAID_... (Selected Mermaid settings) - MATH_... (Math settings)
Installation¶
- Download the plugin file:
export_to_word.py - Upload to OpenWebUI: Admin Panel → Settings → Functions
- Enable the plugin
Usage¶
- Open the conversation you want to export
- Click the Export to Word button in the message action bar
- The
.docxfile will download automatically
Supported Markdown Syntax¶
| Syntax | Word Result |
|---|---|
# Heading 1 to ###### Heading 6 | Heading levels 1-6 |
**bold** or __bold__ | Bold text |
*italic* or _italic_ | Italic text |
***bold italic*** | Bold + Italic |
`inline code` | Monospace with gray background |
``` code block ``` | Syntax highlighted code block |
> blockquote | Left-bordered gray italic text |
[link](url) | Blue underlined link text |
~~strikethrough~~ | Strikethrough text |
- item or * item | Bullet list |
1. item | Numbered list |
| Markdown tables | Enhanced table with smart widths |
--- or *** | Horizontal rule |
$$LaTeX$$ or \[LaTeX\] | Native Word equation (display) |
$LaTeX$ or \(LaTeX\) | Native Word equation (inline) |
```mermaid ... ``` | Mermaid diagram as image |
[1] citation markers | Clickable links to References |
Requirements¶
Prerequisites
python-docx==1.1.2- Word document generationPygments>=2.15.0- Syntax highlightinglatex2mathml- LaTeX to MathML conversionmathml2omml- MathML to Office Math (OMML) conversion
Source Code¶
View on GitHub Author: Fu-Jie | Version: 0.4.3 | Project: Awesome OpenWebUI