Docx

From lightspeedwp/.github · View interactive version

Docx is an AI agent skill from the GitHub repository lightspeedwp/.github. Create, edit, redline, and comment on `.docx` files inside the container, with a strict render-and-verify workflow. Use `render_docx.py` to generate page PNGs (and optional PDF) for visual QA, then iterate until layout is flawless before delivering the final DOCX.

How to use this skill

Skill file

DOCX Skill (Read • Create • Edit • Redline • Comment)

Use this skill when you need to create or modify .docx files in this container environment and verify them visually.

Non-negotiable: render → inspect PNGs → iterate

You do not “know” a DOCX is satisfactory until you’ve rendered it and visually inspected page images.

DOCX text extraction (or reading XML) will miss layout defects: clipping, overlap, missing glyphs, broken tables, spacing drift, and header/footer issues.

Shipping gate: before delivering any DOCX, you must:

If rendering fails, fix rendering first (LibreOffice profile/HOME) rather than guessing.

Deliverable discipline: Rendered artifacts (PNGs and optional PDFs) are for internal QA only. Unless the user explicitly asks for intermediates, return only the requested final deliverable (e.g., when the task asks for a DOCX, deliver the DOCX — not page images or PDFs).

Quick start (common one-liners)

# 1) Render any DOCX to PNGs (visual QA)
python render_docx.py input.docx --output_dir out

# 2) Remove reviewer comments (finalization)
python scripts/comments_strip.py input.docx --out no_comments.docx

# 3) Accept tracked changes (finalization)
python scripts/accept_tracked_changes.py input.docx --mode accept --out accepted.docx

# 4) Accessibility audit (+ optional safe fixes)
python scripts/a11y_audit.py input.docx
python scripts/a11y_audit.py input.docx --out_json a11y_report.json
python scripts/a11y_audit.py input.docx --fix_image_alt from_filename --out a11y_fixed.docx

# 5) Redact sensitive text (layout-preserving by default)
python scripts/redact_docx.py input.docx redacted.docx --emails --phones

Package layout

This skill is organized for progressive discovery: start here, then jump into task- or OOXML-specific docs.

DOCS SKILL PACKAGE

Root:

Tasks:

OOXML:

Troubleshooting:

Scripts:

Core building blocks (importable helpers):

High-leverage utilities (also importable, but commonly invoked as CLIs):

Audits / conversions / niche helpers:

v7 additions (stress-test helpers):

scripts/xlsx_to_docx_table.py also marks header rows as repeating headers (w:tblHeader) to improve a11y and multi-page tables.

Examples:

Note: manifest.txt is machine-readable and is used by download tooling. It must contain only relative file paths (one per line).

Coverage map (scripts ↔ task guides)

This is a quick index so you can jump from a helper script to the right task guide.

Layout & style

Figures / images

Tables / spreadsheets

Fields & references

Review lifecycle (comments / tracked changes)

Privacy / publishing

Navigation & multi-doc assembly

Forms & protection

QA / regression

Skill folder contents

Default workflow (80/20)

Rule of thumb: every meaningful edit batch must end with a render + PNG review. No exceptions.

"80/20" here means: follow the simplest workflow that covers most DOCX tasks reliably.

Golden path (don’t mix-and-match unless debugging):

  1. Author/edit with python-docx (paragraphs, runs, styles, tables, headers/footers).
  2. Render → inspect PNGs immediately (DOCX → PNGs). Treat this as your feedback loop.
  3. Fix and repeat until the PNGs are visually perfect.
  4. Only if needed: use OOXML patching for tracked changes, comments, hyperlinks, or fields.
  5. Re-render and inspect again after any OOXML patch or layout-sensitive change.
  6. Deliver only after the latest PNG review passes (all pages, 100% zoom).

Visual review (recommended)

Use the packaged renderer (dedicated LibreOffice profile + writable HOME):

python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out
# If debugging LibreOffice:
python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out --verbose
# Optional: also write <input_stem>.pdf to --output_dir (for debugging/archival):
python render_docx.py /mnt/data/input.docx --output_dir /mnt/data/out --emit_pdf

Then inspect the generated page-<N>.png files.

Success criteria (render + visual QA):

Note: LibreOffice sometimes prints scary-looking stderr (e.g., error : Unknown IO error) even when output is correct. Treat the render as successful if the PNGs exist and look right (and if you used --emit_pdf, the PDF exists and is non-empty).

What rendering does and doesn’t validate

Quality reminders

Where to go next

_Built by 🧱 LightSpeedWP with ☕, 🚀, and open-source spirit!_

Contributors

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.