docx-perfect

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DOCX文档美化专家

DOCX Document Beautification Expert

将Word文档中的内容转换为专业表格格式,支持版本化迭代优化。
Convert content in Word documents into professional table formats, supporting versioned iterative optimization.

快速开始

Quick Start

文档美化采用递增式版本管理(v0.1, v0.2, ..., v1.0),每次优化一个章节后生成新版本。
Document beautification uses incremental version management (v0.1, v0.2, ..., v1.0), generating a new version after optimizing one section each time.

工作流程

Workflow

1. 分析源文档

1. Analyze the Source Document

bash
python -c "import sys; sys.stdout.reconfigure(encoding='utf-8'); from docx import Document; doc = Document('source.docx'); [print(p.text.strip()) for p in doc.paragraphs if p.text.strip()]"
bash
python -c "import sys; sys.stdout.reconfigure(encoding='utf-8'); from docx import Document; doc = Document('source.docx'); [print(p.text.strip()) for p in doc.paragraphs if p.text.strip()]"

2. 确定本次优化的章节

2. Identify the Section to Optimize This Time

识别需要美化的章节标题,如:
  • 3.1  实体识别
    → 创建实体属性表格
  • 3.2  实体间联系
    → 创建联系关系表格
  • 5.2  索引优化设计
    → 创建索引汇总表格
Identify the section titles that need beautification, such as:
  • 3.1  Entity Recognition
    → Create entity attribute table
  • 3.2  Relationships Between Entities
    → Create relationship table
  • 5.2  Index Optimization Design
    → Create index summary table

3. 创建表格

3. Create Tables

使用
scripts/create_table.py
创建表格,参考下方脚本模板。
Use
scripts/create_table.py
to create tables, referring to the script template below.

4. 应用样式

4. Apply Styles

使用统一样式:
  • 表头: 深蓝色背景 (#4472C4) + 白色粗体文字
  • 数据行: 白色/浅灰色隔行变色
  • 边框: 黑色单线边框
Use consistent styles:
  • Header: Dark blue background (#4472C4) + white bold text
  • Data Rows: Alternating white/light gray colors
  • Borders: Black single-line borders

5. 版本号管理

5. Version Number Management

自动递增版本号,保存为新文件:
文档名-v0.X.docx
Automatically increment the version number and save as a new file:
DocumentName-v0.X.docx

脚本模板

Script Template

详见
scripts/README.md
See
scripts/README.md
for details

常见表格模式

Common Table Patterns

实体属性表格

Entity Attribute Table

| 属性名 | 类型/约束 | 说明 |
|--------|-----------|------|
| field1 | INT, PK   | 主键   |
| Attribute Name | Type/Constraint | Description |
|----------------|-----------------|-------------|
| field1         | INT, PK         | Primary Key |

联系关系表格

Relationship Table

| 联系 | 实体A | 实体B | 说明 |
|------|-------|-------|------|
| Relationship | Entity A | Entity B | Description |
|--------------|----------|----------|-------------|

索引汇总表格

Index Summary Table

| 表名 | 索引名 | 字段 | 类型 | 说明 |
| Table Name | Index Name | Fields | Type | Description |

样式规范

Style Specifications

  • 表头背景:
    #4472C4
    (深蓝)
  • 表头文字: 白色、粗体、11号
  • 奇数行: 白色
    #FFFFFF
  • 偶数行: 浅灰
    #E7E6E6
  • 数据行文字: 宋体、10号
  • 边框: 黑色单线,4磅
  • Header Background:
    #4472C4
    (Dark Blue)
  • Header Text: White, Bold, Size 11
  • Odd Rows: White
    #FFFFFF
  • Even Rows: Light Gray
    #E7E6E6
  • Data Row Text: SimSun, Size 10
  • Borders: Black single-line, 4 points