docx-cjk-formatter
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "docx-cjk-formatter" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-411e1624c291b18c27496813676d0af61d5e84acbbf45ad16e655e64e227d2d1. Verify the upstream source and version against https://skillhub.cn/skills/user_fb0c5f0e/docx-cjk-formatter before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Fix font and size disorder in Chinese Word documents generated by python-docx. Automatically merge multiple runs and fill eastAsia font and szCs size settings, solved with one line of code.
Introduction source: third_party · user_fb0c5f0e · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Not specified in the source documentation.
- Software, accounts and paid services
- python-docx
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: "docx-cjk-formatter"
description: "修复 python-docx 生成的中文 Word 文档字体/字号错乱问题。自动合并多 run、补写 eastAsia 字体和 szCs 字号,一行代码搞定。"Docx CJK Formatter
问题背景
python-docx 库存在 CJK(中日韩)兼容缺陷:
run.font.name只写w:ascii/w:hAnsi,不写w:eastAsia→ 中文字符用默认字体渲染run.font.size只写w:sz,不写w:szCs→ 中文字符用默认字号渲染- 原文档多 run 各有格式,部分清理后残留旧格式
结果:同一行文字有大有小、有加粗有不加粗。
本 Skill 提供完整格式化和轻量修复两种方案,解决上述问题。
工作流程
标准化流程(完整格式化)
用于从头生成的文档或需要统一样式的场景:
from scripts.format_docx import format_docx
format_docx(
input_path, # 源文件路径(必填)
output_path=None, # 输出路径,默认覆盖源文件
font_name='宋体', # 正文字体
body_size=12, # 正文字号(pt)
title_size=18, # 标题字号(pt)
subtitle_size=15, # 副标题字号(pt)
line_spacing=1.5, # 行距
first_line_indent=True, # 首行缩进2字符
bold_titles=True, # 标题加粗
)
轻量级修复(追加后补救)
用于已有文档,只是追加/修改了少量内容后补 CJK 属性,不改变原有格式:
from scripts.format_docx import fix_cjk
fix_cjk('文件路径.docx')
关键原则
- 先合并 run 再设格式:把段落内所有 run 合并为一个,杜绝残留
- 字体三写:
ascii+hAnsi+eastAsia全部写入 - 字号双写:
sz+szCs同时写入 - 只做排版,不改内容:保留原文,仅做格式调整
- 简洁输出:仅保留必要格式,不添加多余装饰
依赖
- python-docx
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 解决 python-docx 库在处理 CJK 字符时的实际痛点
- 提供完整格式化和轻量修复两种实用方案
- 面向开发者群体的明确技术需求
Areas to improve
-
触发词可补充更多变体 Reported severity: Minor
当前触发词已覆盖主要场景,但可补充如'中日韩文档'、'word格式修复'等变体
Recommendation: 在description中增加更多相关关键词变体,提高触发覆盖率
Highlights
- description明确描述核心功能
- 触发词覆盖python-docx、中文Word文档等关键要素
Highlights
- 文档结构清晰,包含问题背景、工作流程、关键原则
- 提供完整的代码示例和使用说明
- frontmatter完整,单文件长度适中
Areas to improve
-
缺少异常处理机制 Reported severity: Major
未提及文件不存在、格式错误等常见异常的處理方式
Recommendation: 在文档中补充异常处理说明,或在代码中增加try-catch机制
-
覆盖源文件操作无确认机制 Reported severity: Minor
format_docx默认覆盖源文件,但未提供确认机制
Recommendation: 建议增加覆盖确认参数或在文档中明确提醒用户备份
Highlights
- 依赖明确,参数说明完整
- 关键原则清晰说明了实现逻辑
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
python-docx
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.