← 返回 Skills 市场
43
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install docx-template-strict
功能描述
Strictly fill a DOCX template (preserving cover/headers/sections/styles) using placeholder tokens, with optional figures and references. For any task like: ‘...
使用说明 (SKILL.md)
docx-template-strict
目的:把 .docx 当作“模板”来用,完整保留模板的封面、分节(sectPr)、页眉页脚、样式、下划线 run 结构、字体与布局;只在模板中指定的占位符位置填充文本/图片/参考文献。
关键原则:不要用 python-docx 重新生成段落结构(这会破坏模板 run/sectPr)。 本 skill 采用:
docx(zip) → XML 精确替换 → 写回 docx。
适用场景
- “按某个 Word 模板格式提交作业/论文/报告,封面与排版必须和模板一致”。
- 需要插图、图题、参考文献,同时保持模板视觉 1:1。
输入要求(模板必须包含占位符)
占位符格式
- 统一:
{{TOKEN_NAME}} - 必须是连续字符串,避免被 Word 拆成多个 run。
常用占位符(建议)
{{TITLE_CN}}/{{TITLE_EN}}{{NAME_CN}}/{{NAME_EN}}{{MAJOR}}{{CLASS}}{{STUDENT_ID}}{{COURSE}}{{TEACHER}}{{DATE_CN}}{{ABSTRACT_CN}}{{KEYWORDS_CN}}{{ABSTRACT_EN}}{{KEYWORDS_EN}}
图占位符(段落级)
每张图推荐 3 段占位符(各占一整段,且仅包含该 token):
{{FIG1}}{{FIG1_CAPTION_CN}}{{FIG1_CAPTION_EN}}
第二张图:FIG2 同理。
参考文献占位符
- 推荐整块替换:
{{REFERENCES}}(多行文本,包含[1]...)
用法
1) 填充模板生成 docx
运行脚本:
python3 ~/.openclaw/skills/docx-template-strict/scripts/fill_template.py \
--template "/path/to/template.docx" \
--out "/path/to/output.docx" \
--data "/path/to/data.json"
data.json 示例:
{
"TITLE_CN": "...",
"TITLE_EN": "...",
"NAME_CN": "林佩权",
"NAME_EN": "Lin Peiquan",
"ABSTRACT_CN": "...",
"ABSTRACT_EN": "...",
"KEYWORDS_CN": "...",
"KEYWORDS_EN": "...",
"REFERENCES": "[1] ...\
[2] ...\
"
}
2) 插图(可选)
在 data.json 中提供:
{
"FIG1": {"path": "/path/to/fig1.png"},
"FIG2": {"path": "/path/to/fig2.jpg"}
}
脚本会:
- 把
{{FIG1}}所在段落替换为图片 drawing - 保留模板段落样式(对齐/缩进)
输出 QA(脚本自动做)
- 扫描是否仍存在
{{...}}未替换 token - 检查模板分节数量(sectPr)是否被破坏(必须一致)
- 检查 media 资源是否写入且 rels 指向有效
注意事项 / 已知限制
- 强依赖占位符:如果模板里没有 token,无法保证 1:1。
- 若 Word/WPS 将 token 拆成多个 run:脚本可能无法识别(建议复制 token 时使用“仅保留文本”)。
- PDF 导出不在本 skill 保真范围内:建议用本机 Word/WPS 导出 PDF,避免 LibreOffice 渲染漂移。
安全使用建议
This skill is reasonable to install if you want local DOCX template filling. Before running it, verify the template, data JSON, image paths, and output path are the ones you intend, and only install any missing Python dependency from a trusted source.
功能分析
Type: OpenClaw Skill
Name: docx-template-strict
Version: 1.0.0
The docx-template-strict skill is a utility for populating Word document templates while maintaining layout integrity. The core logic in scripts/fill_template.py uses zipfile and lxml to perform XML-based text and image replacement, which is consistent with its stated purpose. No indicators of data exfiltration, unauthorized execution, or malicious intent were found.
能力评估
Purpose & Capability
The SKILL.md purpose is to fill DOCX placeholders while preserving template layout, and the included script implements local DOCX XML token replacement and optional image embedding.
Instruction Scope
The documented workflow is user-directed and does not instruct the agent to override user intent, bypass review, or perform unrelated actions.
Install Mechanism
There is no install spec, but the workflow relies on running Python and the script imports lxml, so dependency availability is not fully declared.
Credentials
The script reads and writes user-specified local document, JSON, image, and output paths, which is proportionate to DOCX templating but should be limited to intended files.
Persistence & Privilege
The artifacts show no credentials, privileged account access, background process, persistent memory, or continuing autonomous behavior.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install docx-template-strict - 安装完成后,直接呼叫该 Skill 的名称或使用
/docx-template-strict触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: Strictly fills DOCX templates by replacing placeholder tokens while fully preserving template layout and styles.
- Replaces template tokens (e.g., {{TITLE_CN}}, {{FIG1}}) with data, including text, images, and references.
- Maintains all original DOCX structures: cover, headers/footers, sections, styles, fonts, and layout.
- Image placeholders are replaced at the paragraph level, preserving paragraph styles.
- Provides quality checks to ensure tokens are replaced and template structure remains intact.
- Requires explicit placeholders in the template; does not generate PDF output.
元数据
常见问题
Docx Template Strict 是什么?
Strictly fill a DOCX template (preserving cover/headers/sections/styles) using placeholder tokens, with optional figures and references. For any task like: ‘... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 43 次。
如何安装 Docx Template Strict?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install docx-template-strict」即可一键安装,无需额外配置。
Docx Template Strict 是免费的吗?
是的,Docx Template Strict 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Docx Template Strict 支持哪些平台?
Docx Template Strict 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Docx Template Strict?
由 lpq6(@lpq6)开发并维护,当前版本 v1.0.0。
推荐 Skills