Skip to content
Back to search

document-format-skills

公文格式处理Skill: Professional Word document formatting toolkit for Chinese official documents

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/kagurananaga--document-format-skills/badge.svg)](/listings/kagurananaga--document-format-skills)

HTML

<a href="/listings/kagurananaga--document-format-skills"><img src="/api/listings/kagurananaga--document-format-skills/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Smart cleanup:

uv run --with python-docx python scripts/process.py smart input.docx output.docx --preset official

Analyze only:

uv run --with python-docx python scripts/process.py analyze input.docx
uv run --with python-docx python scripts/process.py analyze input.docx --json

Punctuation and spacing only:

uv run --with python-docx python scripts/process.py punctuation input.docx output.docx --space-mode keep_en_boundary

Formatting only:

uv run --with python-docx python scripts/process.py format input.docx output.docx --preset official

Create a formatted DOCX from Markdown or text:

uv run --with python-docx python scripts/from_text.py input.md output.docx --title "Work Plan"

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 107 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: document-format-skills
  3. description: Chinese Word document formatting toolkit for .docx/.doc/.wps workflows. Use when Codex needs to diagnose document formatting, fix mixed Chinese/English punctuation and spacing, apply official/academic/legal/custom presets, normalize tables and page numbers, preserve or output Word revision marks, convert plain text or Markdown into formatted DOCX, or batch/script document cleanup for Chinese official documents.
  4. ---
  5. # Document Format Skills
  6. Use these scripts to clean and format Chinese Word documents from the command line. Prefer `scripts/process.py` for normal work because it mirrors the desktop app's core pipeline without the GUI.
  7. ## Quick Workflow
  8. Run one smart pass when the user wants the document cleaned end to end:
  9. ```bash
  10. uv run --with python-docx python scripts/process.py smart input.docx output.docx --preset official
  11. ```
  12. Run diagnostics only:
  13. ```bash
  14. uv run --with python-docx python scripts/process.py analyze input.docx
  15. uv run --with python-docx python scripts/process.py analyze input.docx --json
  16. ```
  17. Run only punctuation/spacing cleanup:
  18. ```bash
  19. uv run --with python-docx python scripts/process.py punctuation input.docx output.docx --space-mode keep_en_boundary
  20. ```
  21. Run only formatting:
  22. ```bash
  23. uv run --with python-docx python scripts/process.py format input.docx output.docx --preset official
  24. ```
  25. On Windows, `.doc` and `.wps` input/output are supported through WPS or Microsoft Word COM automation:
  26. ```bash
  27. uv run --with python-docx --with pywin32 python scripts/process.py smart input.wps output.wps
  28. ```
  29. ## Scripts
  30. | Script | Use |
  31. | --- | --- |
  32. | `scripts/process.py` | One-shot CLI for `smart`, `analyze`, `punctuation`, and `format`; handles `.doc/.wps` conversion on Windows. |
  33. | `scripts/formatter.py` | Apply formatting presets, custom JSON settings, page numbers, table cleanup, revision marks, macOS font fallback. |
  34. | `scripts/punctuation.py` | Fix punctuation while preserving run formatting; supports spacing strategies. |
  35. | `scripts/from_text.py` | Create a DOCX from `.txt` or Markdown, then optionally run smart formatting. |
  36. | `scripts/analyzer.py` | Lower-level diagnostic script. |
  37. | `scripts/converter.py` | Windows-only `.doc/.wps` conversion helpers. |
  38. ## Formatting Options
  39. Built-in presets:
  40. - `official`: GB/T 9704-2012 style official document formatting.
  41. - `academic`: academic paper formatting.
  42. - `legal`: legal document formatting.
  43. - `custom`: read the active desktop custom preset when available.
  44. Useful flags:
  45. ```bash
  46. --custom-settings path.json
  47. --revision
  48. --deep-clean
  49. --smart-table-align
  50. --no-page-number
  51. --page-number-style dash|plain|page_text|page_total
  52. --page-number-position outside|left|center|right
  53. --page-number-offset-mm 7
  54. --no-bold-serial
  55. ```
  56. `--custom-settings` accepts desktop schema v2 config files, exported preset files shaped as `{"preset": {...}}`, or plain preset/override JSON. For non-custom presets, the JSON is merged over the selected preset.
  57. ## Punctuation And Spacing
  58. Punctuation cleanup protects URLs, email addresses, Windows paths, time values like `9:30`, and standards like `ISO 9001:2015`. It fixes brackets, colons, semicolons, question/exclamation marks, Chinese comma/period contexts, ellipses, dashes, and paired quotes.
  59. Spacing modes:
  60. - `remove_all`: delete half-width and full-width spaces.
  61. - `keep_en_boundary`: remove Chinese-to-Chinese spaces but keep exactly one space between Chinese and English/digits.
  62. - `keep_all`: leave spaces unchanged.
  63. ## Text Or Markdown To DOCX
  64. Generate and format a document from text:
  65. ```bash
  66. uv run --with python-docx python scripts/from_text.py input.md output.docx --title "工作方案"
  67. ```
  68. Markdown mode detects headings, bold spans, ordered/unordered lists, quotes, and fenced code blocks. `#` becomes the main title, `##` becomes `一、`, `###` becomes `(一)`, and deeper headings become numbered lower-level headings.
  69. Use `--no-process` to only create the raw DOCX.
  70. ## Implementation Notes
  71. - `.docx` processing needs only `python-docx`.
  72. - `.doc/.wps` conversion needs Windows plus WPS Office or Microsoft Word and `pywin32`.
  73. - Page number handling avoids overwriting non-page footer content and can replace existing page-number footers when requested.
  74. - Default table formatting preserves original alignment; use `--smart-table-align` for numeric/right and short-text/center alignment.
  75. - macOS font handling keeps installed official fonts when present and falls back to compatible system fonts only when detection confirms the original is missing.
README.md · README · 120 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # 📄 document-format-skills 公文格式助手
  2. > **[中文版本 README / Chinese Version](./README_CN.md)**
  3. >
  4. > 看不懂英文也没关系,请点击上面的链接查看中文版说明。
  5. > 💡 **想要无需联网、一键运行修复格式的桌面应用版本?**
  6. >
  7. > 现已推出 **[Document Format GUI 公文格式助手](https://github.com/KaguraNanaga/docformat-gui)** —— 无需联网、一键修复公文格式的桌面应用,小白也能轻松上手!
  8. > 🌐 **不想安装,也不需要 Agent?**
  9. >
  10. > 直接打开 **[公文格式处理工具网页版](https://web.gongwengeshizhushou.com)**,选择 `.docx` 文档即可开始处理。无需登录,文档只在当前浏览器中处理,不会上传到服务器。
  11. A Word document formatting toolkit for Chinese official documents for the government, CCP (China Communist Party), and the state-owned enterprises. Diagnose formatting issues, fix punctuation, and apply standardized styles with one command. Available for Claude Code, Codex, and OpenCode.
  12. 公文格式助手是一个面向中文公文排版的 Skill 工具包,用于诊断 Word 文档格式问题、修复中英文标点和空格混用、统一公文/论文/法律文书格式、处理页码和表格,并支持从纯文本或 Markdown 生成规范 DOCX。
  13. ## Features
  14. - 中文用户如果不熟悉命令行,可以优先使用 [Document Format GUI 公文格式助手](https://github.com/KaguraNanaga/docformat-gui):无需联网、一键修复公文格式。
  15. - Smart one-shot processing: punctuation/spacing cleanup plus formatting.
  16. - Format diagnosis for punctuation, numbering, paragraph, and font issues.
  17. - Official, academic, legal, and custom presets.
  18. - GB/T 9704-2012 style page margins, fonts, line spacing, headings, signatures, dates, and page numbers.
  19. - Safer page-number handling with styles, positions, offsets, replacement control, and non-page footer protection.
  20. - Table normalization with optional smart alignment.
  21. - Custom settings compatible with the desktop app schema v2 and exported preset JSON.
  22. - Word revision marks for supported formatting changes.
  23. - macOS font fallback for common Chinese official-document fonts.
  24. - `.doc` / `.wps` conversion on Windows when WPS Office or Microsoft Word is installed.
  25. - Plain text or Markdown to formatted DOCX.
  26. ## Requirements
  27. - Python 3.8+
  28. - `python-docx`
  29. - `pywin32` only for `.doc/.wps` conversion on Windows
  30. Use `uv` for ad-hoc runs:
  31. ```bash
  32. uv run --with python-docx python scripts/process.py --help
  33. ```
  34. For Windows `.doc/.wps` conversion:
  35. ```bash
  36. uv run --with python-docx --with pywin32 python scripts/process.py --help
  37. ```
  38. ## Quick Start
  39. Smart cleanup:
  40. ```bash
  41. uv run --with python-docx python scripts/process.py smart input.docx output.docx --preset official
  42. ```
  43. Analyze only:
  44. ```bash
  45. uv run --with python-docx python scripts/process.py analyze input.docx
  46. uv run --with python-docx python scripts/process.py analyze input.docx --json
  47. ```
  48. Punctuation and spacing only:
  49. ```bash
  50. uv run --with python-docx python scripts/process.py punctuation input.docx output.docx --space-mode keep_en_boundary
  51. ```
  52. Formatting only:
  53. ```bash
  54. uv run --with python-docx python scripts/process.py format input.docx output.docx --preset official
  55. ```
  56. Create a formatted DOCX from Markdown or text:
  57. ```bash
  58. uv run --with python-docx python scripts/from_text.py input.md output.docx --title "Work Plan"
  59. ```
  60. ## Useful Options
  61. ```bash
  62. --preset official|academic|legal|custom
  63. --custom-settings path.json
  64. --revision
  65. --deep-clean
  66. --smart-table-align
  67. --no-page-number
  68. --page-number-style dash|plain|page_text|page_total
  69. --page-number-position outside|left|center|right
  70. --space-mode remove_all|keep_en_boundary|keep_all
  71. ```
  72. `--custom-settings` accepts desktop schema v2 config files, exported preset files like `{"preset": {...}}`, or plain preset/override JSON.
  73. ## Scripts
  74. | Script | Purpose |
  75. | --- | --- |
  76. | `scripts/process.py` | Main CLI pipeline: `smart`, `analyze`, `punctuation`, `format`. |
  77. | `scripts/formatter.py` | Formatting engine and preset handling. |
  78. | `scripts/punctuation.py` | Punctuation and spacing fixer. |
  79. | `scripts/from_text.py` | Text/Markdown to DOCX generator. |
  80. | `scripts/analyzer.py` | Diagnostic helpers. |
  81. | `scripts/converter.py` | Windows `.doc/.wps` conversion helpers. |
  82. ## Notes
  83. - `.docx` is the most reliable format.
  84. - `.doc/.wps` requires Windows plus WPS Office or Microsoft Word.
  85. - Keep a backup of important documents before running automated formatting.
  86. ## License
  87. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.