| name | format-word-screenplay |
| description | Format Chinese screenplay manuscripts into Word .docx files with aligned character names and hanging dialogue indentation. Use when Codex is asked to 排版剧本, align 人名 and 台词 in Word, convert txt or docx script drafts into a screenplay .docx, or apply a Word character-style screenplay formatting workflow. |
Format Word Screenplay
Core Rule
Apply the Word workflow summarized in references/source-workflow.md: speaker names use a character style named 人名, dialogue uses a character style named 台词, speaker names are fitted to a fixed character width, and dialogue paragraphs use a hanging indent equal to name width + 1 characters so wrapped dialogue lines align after the colon.
Quick Start
Use scripts/format_screenplay_docx.py when the manuscript is plain text, Markdown, or a simple DOCX whose paragraphs look like 角色:台词.
python3 path/to/format-word-screenplay/scripts/format_screenplay_docx.py input.txt -o output.docx
The script:
- Reads
.txt, .md, or .docx input.
- Detects dialogue paragraphs by the first Chinese or ASCII colon.
- Computes
--name-width auto from the longest detected speaker name, with a minimum of 3 Chinese characters.
- Creates a Word
.docx with 人名 and 台词 character styles.
- Applies fixed-width speaker-name fitting and paragraph hanging indent.
For four-character or wider names, either rely on auto width or set it explicitly:
python3 path/to/format-word-screenplay/scripts/format_screenplay_docx.py input.docx -o output.docx --name-width 4
Workflow
- Inspect the source manuscript enough to see how dialogue is written.
- If dialogue is in
人物:台词 form, run the script and create a new output DOCX. Keep the original file unchanged unless the user explicitly asks for in-place replacement.
- If the source has rich formatting, tables, comments, images, or ambiguous dialogue markup, ask whether to preserve layout manually or normalize the text into screenplay paragraphs before formatting.
- Use
--name-width when the user specifies a target width or when parenthetical cues make auto-detection too wide.
- Open or inspect the output when practical. At minimum, verify
word/document.xml contains w:fitText, w:ind, ScreenplayCharacter, and ScreenplayDialogue.
Input Conventions
Dialogue lines should be written as:
张三:今天几点开会?
李四:三点。
Non-dialogue lines without a colon are kept as normal paragraphs. Common metadata labels such as 场景:, 地点:, 时间:, 备注:, 镜头:, and 字幕: are treated as normal paragraphs instead of speakers.
For ambiguous drafts, normalize them before running the script:
- Put one dialogue turn per paragraph.
- Put the speaker before the first
: or :.
- Keep action, scene headings, and transitions as separate paragraphs without a speaker colon when they should not be dialogue.
Manual Word Fallback
When the user wants to work directly in Word instead of generating a new DOCX:
- Create two character styles, not paragraph styles:
人名 and 台词.
- Apply
人名 only to speaker names.
- Apply
台词 to the colon and dialogue text.
- Select all instances of
人名, then use Word's adjust-width command to set the speaker width to the longest name, usually 3 characters.
- Select all dialogue paragraphs and set hanging indent to
speaker width + 1 characters, for example 4 characters when names are fitted to 3.
- Set font, font size, and line spacing on the styles so changes apply globally.