thai-docx

Generate Word documents with correct Thai line breaking using zero-width space insertion.

Updated Aug 21, 2026
One-click install
npx skills add https://github.com/dohcivil-ui/naichangmoo.com --skill thai-docx-dohcivil-ui
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: thai-docx
Source: https://github.com/dohcivil-ui/naichangmoo.com/tree/main/.agents/skills/thai-docx
Command: npx skills add https://github.com/dohcivil-ui/naichangmoo.com --skill thai-docx-dohcivil-ui

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pythainlp, python-docx, and includes scripts (resource) components.

What problem does it solve? Thai has no spaces between words, so Microsoft Word does not know where to break lines, producing short lines and wasted right-margin space in Thai documents. This Skill inserts invisible Zero-Width Spaces (U+200B) between Thai words before writing the .docx file, giving Word valid break points so text fills each line fully. ## Core Features & Use Cases - Automatic Thai word segmentation: Uses pythainlp's newmm tokenizer to split Thai text and insert ZWS only in Thai character runs, leaving English, numbers, and URLs untouched. - Full document generation: Builds .docx files with python-docx supporting body text and heading levels 1-3, configurable font (default TH Sarabun New), font size, A4/Letter page size, margins, and line spacing. - CLI and Python API: Run from the command line on a plain text file (blank lines separate paragraphs, numbered lines become headings) or call create_docx() programmatically. - Use Case: A user needs a formal Thai report in Word format. Provide the Thai text, and the Skill produces a properly wrapped .docx with TH Sarabun New 14pt, 1.5 line spacing, and correct line breaks. ## Quick Start Ask the AI to create a Word document from your Thai text using the thai-docx skill, for example: "สร้างเอกสาร Word จากข้อความภาษาไทยนี้และบันทึกเป็น report.docx".

Frequently Asked Questions about thai-docx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Word document with proper Thai line breaking in Python?

Use pythainlp to tokenize Thai text and insert Zero-Width Spaces (U+200B) between words, then write the result with python-docx. The ZWS characters are invisible but tell Word where it may break lines, so Thai text fills each line fully.

Why does Thai text wrap incorrectly in Microsoft Word?

Thai script has no spaces between words, so Word cannot find valid break points and wraps lines too early, leaving short lines and wasted right-margin space. Inserting zero-width spaces between words gives Word the break points it needs.

Should I use python-docx or docx-js for Thai Word documents?

Use python-docx (Python) for Thai documents. The docx-js JavaScript library does not handle Thai line breaking well, so this Skill mandates python-docx combined with pythainlp word tokenization for all Thai content.

Does inserting zero-width spaces change how Thai text looks?

No. Zero-Width Space (U+200B) is invisible and has zero width, so the document's appearance is unchanged. It only provides Word with valid line-break positions, and English text, numbers, and URLs are left untouched.

What text alignment should Thai Word documents use?

Always use LEFT alignment for Thai documents. JUSTIFIED alignment stretches inter-word spaces grotesquely, and THAI_DISTRIBUTE stretches characters, both producing poor typography in Thai text.