word-format-extractor

Word format extraction and copy tool: extracts all formatting settings (fonts, paragraphs, alignment, borders, shading, numbering, etc.) from .docx template files into structured JSON, and precisely applies those formats to target documents; suitable for unifying formats in meeting minutes, reports, official documents, etc. Trigger phrases include "format extraction", "format copy", "format template", and "format application".

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 "word-format-extractor" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-fe294a27eff25c38889350070b3a2c28855b5cfa3e2f8eabce8d1b2750a02880. Verify the upstream source and version against https://skillhub.cn/skills/user_7c11bc40/state-owned-enterprise-meeting-minutes-template 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

Word format extraction and copy tool: extracts all formatting settings (fonts, paragraphs, alignment, borders, shading, numbering, etc.) from .docx template files into structured JSON, and precisely applies those formats to target documents; suitable for unifying formats in meeting minutes, reports, official documents, etc. Trigger phrases include "format extraction", "format copy", "format template", and "format application".

0 Downloads

Introduction source: third_party · user_7c11bc40 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: word-format-extractor
description: "Word 格式提取与复制工具。从 .docx 模板文件中完整提取所有格式配置(字体、段落、对齐、边框、底纹、编号等),生成结构化 JSON 格式档案,再将格式精准应用到目标文档。适用于会议纪要、报告、公文等文档格式统一场景。触发词:提取Word格式、复制格式、格式模板、格式应用、format extraction、format copy、word formatting。"
agent_created: true

Word 格式提取与复制

从 .docx 模板文件完整提取所有格式配置,生成结构化 JSON 格式档案,再精准应用到目标文档,确保两份文档视觉呈现与排版风格完全一致。

工作流程

阶段一:格式提取

用户提供模板文件后,运行提取脚本:

python scripts/extract_format.py <模板文件.docx> --output <格式档案.json>

脚本自动解析并记录以下格式信息:

类别 属性
字符格式 字体名称(中文/西文)、字号、字体颜色、加粗、斜体、下划线、删除线、上下标、字间距、突出显示、着色、边框、大小写转换
段落格式 行间距(倍数/固定值)、段前距、段后距、首行缩进、左缩进、右缩进、悬挂缩进(支持字符数与厘米双单位)
对齐方式 居中、左对齐、右对齐、两端对齐、分散对齐
段落属性 段落边框(上下左右)、段落底纹、编号/列表格式、大纲级别、制表位、分页控制(段前分页/与下段同页/孤行控制)、上下文间距
样式定义 所有命名样式(Normal/Heading1-9/Title 等)、文档默认设置、编号定义
段落分类 自动识别:大标题、一级标题、二级标题、三级标题、正文、子正文、元数据行

提取完成后打印格式摘要供确认,JSON 档案包含 paragraphs 数组,每个元素记录段落的 type、paragraphProperties、runs(含每个 run 的 runProperties)。

阶段二:格式应用

用户提供目标文件后,运行应用脚本:

python scripts/apply_format.py <格式档案.json> <目标文件.docx> --output <输出文件.docx>

映射模式

模式 参数 说明
位置映射 (默认) --mapping auto 按段落顺序一一对应,跳过空段落
类型映射 --mapping type 按段落类型分组,同类型按出现顺序对应(标题→标题、正文→正文)
手动映射 --mapping manual --map-file mapping.json 使用 JSON 映射文件指定 {"目标段落序号": "源段落序号"}

附加选项

  • --copy-styles:同时将模板的样式定义合并到目标文档
  • --quiet:不打印报告

格式应用规则

  1. 段落格式:用模板段落属性完整替换目标段落的 <w:pPr>
  2. 字符格式:按 run 对应关系替换 <w:rPr>;run 数量不匹配时使用主格式统一应用
  3. 文字内容:保留目标文件全部原始文字,仅替换格式
  4. 样式定义:可选合并模板的命名样式到目标文档的 styles.xml

映射文件格式(手动模式)

{
  "0": 0,
  "1": 1,
  "3": 6,
  "5": 7
}

键为目标段落序号,值为格式档案中的源段落序号。未列出的段落保留原始格式。

段落类型说明

脚本自动将段落分类为以下类型,用于类型映射模式:

类型标识 说明 典型特征
title 大标题 字号≥32半磅、居中、加粗
heading1 一级标题 字号28半磅(14pt)、加粗、无缩进
heading2 二级标题 字号24半磅(12pt)、加粗、无缩进、无冒号
heading3 三级标题 字号24半磅(12pt)、加粗、无缩进
body 正文 有首行缩进、非加粗
sub_body 子正文 字号22半磅(11pt)、有首行缩进
metadata 元数据行 包含冒号(:/:)
empty 空段落 无文本内容

脚本文件

scripts/extract_format.py

格式提取脚本。无需第三方依赖,仅使用 Python 标准库。

输入:.docx 文件路径 输出:结构化 JSON 文件(包含 docDefaults、styles、numbering、paragraphs、summary)

python scripts/extract_format.py 模板.docx --output 格式档案.json
python scripts/extract_format.py 模板.docx --output 格式档案.json --quiet

scripts/apply_format.py

格式应用脚本。无需第三方依赖,仅使用 Python 标准库。

输入:格式档案 JSON + 目标 .docx 文件 输出:应用格式后的 .docx 文件

python scripts/apply_format.py 格式档案.json 目标.docx --output 结果.docx
python scripts/apply_format.py 格式档案.json 目标.docx --mapping type --output 结果.docx
python scripts/apply_format.py 格式档案.json 目标.docx --copy-styles --output 结果.docx

单位换算参考

属性 XML 单位 换算
字号 半磅 (half-points) ÷2 = 磅 (pt)
段间距 缇 (twips) ÷20 = 磅 (pt)
缩进 缇 (twips) ÷567 = 厘米 (cm)
行距 (auto) 240 = 单倍 ÷240 = 倍数
行距 (exact) 缇 (twips) ÷20 = 磅 (pt)
字符缩进 字符数 ×240 = 缇

典型使用场景

  1. 会议纪要格式统一:从会议纪要模板提取格式,应用到新生成的会议纪要
  2. 公文格式标准化:将标准公文格式提取为档案,批量应用到各科室文档
  3. 报告排版统一:从标准报告模板提取格式,应用到不同内容的报告
  4. 格式迁移:将旧文档格式提取后应用到新文档

注意事项

  • 仅支持 .docx 格式(不支持 .doc)
  • 格式应用时保留目标文件全部原始文字内容
  • 目标文档段落数可少于模板(按映射模式处理)
  • 如目标文档使用命名样式而模板使用直接格式,建议使用 --copy-styles 选项
  • 脚本不修改原始文件,输出为独立的新文件

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 解决文档格式统一这一明确办公场景需求
  • 适用于会议纪要、报告、公文等高频场景
  • 具有广泛实用价值
Trigger Precision85/100

Highlights

  • 触发词覆盖中英文,边界清晰
  • 包含'提取Word格式'、'复制格式'、'format extraction'等关键词
Structure and Standards90/100

Highlights

  • 文档结构完整,包含工作流程、阶段划分、映射模式
  • 有端到端示例,frontmatter完整
  • 详细说明三种映射模式和附加选项
Execution Reliability88/100

Highlights

  • 脚本使用Python标准库,无需第三方依赖
  • 参数说明清晰,覆盖主要异常场景
  • 有确认机制和多种映射模式
Evidence Verifiability (mean of the first four)87/100

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.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.