zcode-app-cli 3.3.5-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +642 -0
- package/bin/zcode.js +848 -0
- package/config.example.json +110 -0
- package/package.json +81 -0
- package/vendor/.node-bundle-meta.json +6 -0
- package/vendor/extraction.json +11 -0
- package/vendor/node_modules/@zcode/tui/dist/index.js +161875 -0
- package/vendor/node_modules/@zcode/tui/package.json +14 -0
- package/vendor/packages/android-emulator-plugin/.mcp.json +19 -0
- package/vendor/packages/android-emulator-plugin/.zcode-plugin/plugin.json +63 -0
- package/vendor/packages/android-emulator-plugin/README.md +134 -0
- package/vendor/packages/android-emulator-plugin/commands/android-dev.md +11 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/path.d.ts +4 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/path.js +17 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/result.d.ts +5 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/result.js +22 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/run.d.ts +18 -0
- package/vendor/packages/android-emulator-plugin/dist/lib/run.js +99 -0
- package/vendor/packages/android-emulator-plugin/dist/mcp/server.d.ts +3 -0
- package/vendor/packages/android-emulator-plugin/dist/mcp/server.js +47607 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/app.d.ts +39 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/app.js +50 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/avd.d.ts +37 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/avd.js +185 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/build.d.ts +68 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/build.js +131 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/config.d.ts +7 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/config.js +29 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/device.d.ts +20 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/device.js +91 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/logs.d.ts +15 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/logs.js +31 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/preflight.d.ts +15 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/preflight.js +123 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project-template.d.ts +13 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project-template.js +211 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project.d.ts +33 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/project.js +195 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.d.ts +14 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/screenshot.js +73 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/sdk.d.ts +14 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/sdk.js +185 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/ui.d.ts +92 -0
- package/vendor/packages/android-emulator-plugin/dist/providers/ui.js +146 -0
- package/vendor/packages/android-emulator-plugin/hooks/hooks.json +3 -0
- package/vendor/packages/android-emulator-plugin/package.json +35 -0
- package/vendor/packages/android-emulator-plugin/skills/android-dev/INSTALL_ENVIRONMENT.md +357 -0
- package/vendor/packages/android-emulator-plugin/skills/android-dev/SKILL.md +73 -0
- package/vendor/packages/android-emulator-plugin/templates/compose-app/README.md +5 -0
- package/vendor/packages/document-skills-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/document-skills-plugin/package.json +8 -0
- package/vendor/packages/document-skills-plugin/skills/docx/LICENSE.txt +13 -0
- package/vendor/packages/document-skills-plugin/skills/docx/SKILL.md +201 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/chart-templates.md +386 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/common-rules.md +419 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/decorations.md +537 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/design-system.md +1797 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-advanced.md +257 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/docx-js-core.md +332 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/faq.md +323 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/math-formulas.md +276 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/ooxml.md +222 -0
- package/vendor/packages/document-skills-plugin/skills/docx/references/toc.md +264 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/comment.md +88 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/create.md +207 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/edit.md +115 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/format.md +120 -0
- package/vendor/packages/document-skills-plugin/skills/docx/routes/read.md +114 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/academic.md +783 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/contract.md +463 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/copywriting.md +139 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/exam.md +698 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/official-doc.md +411 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/report.md +340 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scenes/resume.md +534 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/__init__.py +1 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/add_toc_placeholders.py +749 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/document.py +1333 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/postcheck.py +807 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/comments.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/templates/people.xml +3 -0
- package/vendor/packages/document-skills-plugin/skills/docx/scripts/utilities.py +374 -0
- package/vendor/packages/document-skills-plugin/skills/docx/setup.sh +177 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/LICENSE.txt +13 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/SKILL.md +919 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/academic.md +1058 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/creative.md +770 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/poster.md +702 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process-advanced.md +284 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/process.md +319 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/briefs/report.md +1659 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/components.md +153 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/fonts.md +93 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/configs/visual_framework.md +263 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-academic.tex +130 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/references/resume-altacv.tex +190 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/cover_validate.js +367 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/design_engine.py +2816 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2pdf-next.js +754 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/html2poster.js +256 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf.py +2959 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/pdf_qa.py +901 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/poster_validate.py +1337 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/setup.sh +269 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/scripts/toc_validate.py +2075 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/charts.md +320 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover-backgrounds.md +384 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/cover.md +1442 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/fill-engine.md +527 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/geometry.md +142 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/overflow.md +630 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/pagination.md +367 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/palette.md +217 -0
- package/vendor/packages/document-skills-plugin/skills/pdf/typesetting/typography.md +20 -0
- package/vendor/packages/ios-simulator-plugin/.mcp.json +15 -0
- package/vendor/packages/ios-simulator-plugin/.zcode-plugin/plugin.json +34 -0
- package/vendor/packages/ios-simulator-plugin/README.md +111 -0
- package/vendor/packages/ios-simulator-plugin/commands/ios-dev.md +11 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/path.d.ts +4 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/path.js +18 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/result.d.ts +5 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/result.js +20 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/run.d.ts +17 -0
- package/vendor/packages/ios-simulator-plugin/dist/lib/run.js +83 -0
- package/vendor/packages/ios-simulator-plugin/dist/mcp/server.d.ts +3 -0
- package/vendor/packages/ios-simulator-plugin/dist/mcp/server.js +46833 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/build.d.ts +112 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/build.js +99 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/logs.d.ts +21 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/logs.js +26 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.d.ts +12 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/preflight.js +62 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/project.d.ts +35 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/project.js +288 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.d.ts +22 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/screenshot.js +30 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/sim.d.ts +60 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/sim.js +116 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/ui.d.ts +57 -0
- package/vendor/packages/ios-simulator-plugin/dist/providers/ui.js +67 -0
- package/vendor/packages/ios-simulator-plugin/hooks/hooks.json +3 -0
- package/vendor/packages/ios-simulator-plugin/package.json +35 -0
- package/vendor/packages/ios-simulator-plugin/skills/ios-dev/SKILL.md +45 -0
- package/vendor/packages/ios-simulator-plugin/templates/swiftui-app/README.md +5 -0
- package/vendor/packages/restore-legacy-sessions-plugin/.zcode-plugin/plugin.json +9 -0
- package/vendor/packages/restore-legacy-sessions-plugin/README.md +35 -0
- package/vendor/packages/restore-legacy-sessions-plugin/commands/restore-legacy-sessions.md +11 -0
- package/vendor/packages/restore-legacy-sessions-plugin/package.json +8 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/SKILL.md +92 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/restore-conversation.mjs +648 -0
- package/vendor/packages/restore-legacy-sessions-plugin/skills/restore-legacy-sessions/scripts/scan-legacy-sessions.mjs +422 -0
- package/vendor/packages/skill-creator-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/skill-creator-plugin/package.json +8 -0
- package/vendor/packages/skill-creator-plugin/skills/skill-creator/SKILL.md +159 -0
- package/vendor/packages/zcode-guide-plugin/.zcode-plugin/plugin.json +8 -0
- package/vendor/packages/zcode-guide-plugin/README.md +22 -0
- package/vendor/packages/zcode-guide-plugin/package.json +8 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-commands/SKILL.md +66 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-hooks/SKILL.md +66 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-mcp/SKILL.md +97 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-plugins/SKILL.md +59 -0
- package/vendor/packages/zcode-guide-plugin/skills/diagnosing-skills/SKILL.md +61 -0
- package/vendor/packages/zcode-guide-plugin/skills/zcode-configuration-guide/SKILL.md +99 -0
- package/vendor/zcode.cjs +2926 -0
- package/zcode-runtime.lock.json +8 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Route: Create New Document
|
|
2
|
+
|
|
3
|
+
## Workflow
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
0. Check if user provided a reference template (PDF/docx) → if yes, use Template-Following Mode below
|
|
7
|
+
1. Load `references/design-system.md` → select palette and cover recipe
|
|
8
|
+
2. Load `references/common-rules.md` → shared layout, font, placeholder rules
|
|
9
|
+
3. Check user keywords → load scene file if applicable
|
|
10
|
+
4. Load `references/docx-js-core.md`
|
|
11
|
+
5. If complex → also load `references/docx-js-advanced.md`
|
|
12
|
+
6. Plan document structure (outline)
|
|
13
|
+
7. Write JS/TS using docx library
|
|
14
|
+
⚠️ **BEFORE writing any string**: scan ALL Chinese text for curly quotes `""''` and replace with `\u201c \u201d \u2018 \u2019` — bare curly quotes break JS syntax (see docx-js-advanced.md § Quotes Escaping)
|
|
15
|
+
8. Run with `bun run generate.js` (or `node generate.js`)
|
|
16
|
+
9. If TOC → run `python3 "$DOCX_SCRIPTS/add_toc_placeholders.py" output.docx --auto`
|
|
17
|
+
10. Run post-generation checklist (see SKILL.md)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Template-Following Mode
|
|
21
|
+
|
|
22
|
+
When the user provides a reference document (PDF/docx) as a **formatting template** (e.g., "generate following this template format", "refer to this sample"), switch to template-following mode instead of the standard recipe-based workflow:
|
|
23
|
+
|
|
24
|
+
1. **Extract the template's structure** — cover layout, section order, heading hierarchy, page breaks, special pages (e.g., advisor comments page, approval form)
|
|
25
|
+
2. **Replicate structure exactly** — every major structural unit becomes a **separate section** (cover, body, appendix/form pages) with appropriate margins and page breaks
|
|
26
|
+
3. **Fill content** from the user's content source, or generate per user instructions
|
|
27
|
+
4. **Preserve template-specific elements** — school-specific forms, signature areas, stamp placeholders, advisor comment blocks → reproduce as-is with placeholder text (e.g., "Advisor (signature):")
|
|
28
|
+
5. **Maintain formatting fidelity** — font choices, table layouts, spacing, and alignment should match the template, not the standard design-system palettes
|
|
29
|
+
|
|
30
|
+
⚠️ **Do NOT apply standard cover recipes (R1–R7) when a user-provided template defines its own cover format.** Follow the template's cover layout instead. Standard `common-rules.md` constraints (e.g., `WidthType.PERCENTAGE`, `allNoBorders` for cover wrapper, `Rule 8` line spacing) still apply for cross-engine compatibility.
|
|
31
|
+
|
|
32
|
+
⚠️ **Each distinct page type = separate section.** Cover section (margin: 0), body section (standard margins), appendix/form pages (may need different margins or orientation). Never place cover + body + appendix in a single section.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Decision Tree
|
|
37
|
+
|
|
38
|
+
### Cover Page?
|
|
39
|
+
- **YES**: Reports, theses, proposals, plans, or 3+ page docs with clear title/author
|
|
40
|
+
- **NO**: Resumes, contracts, official documents, exam papers, short memos
|
|
41
|
+
|
|
42
|
+
### Cover Style Selector — Recipe Router
|
|
43
|
+
|
|
44
|
+
Covers use **7 validated layout recipes (R1–R7)**, auto-selected by `selectCoverRecipe()` in `references/design-system.md` (the **authoritative source** — do NOT duplicate the function).
|
|
45
|
+
|
|
46
|
+
**Quick Reference:**
|
|
47
|
+
|
|
48
|
+
| docType | Recipe | Default Palette |
|
|
49
|
+
|---------|--------|-----------------|
|
|
50
|
+
| contract / official / exam / resume | null (no cover) | — |
|
|
51
|
+
| academic | R5 (Clean White) | ACADEMIC |
|
|
52
|
+
| proposal_report (thesis proposal) | R5 (Clean White) | ACADEMIC |
|
|
53
|
+
| lesson_plan (STEM) | R4 (Top Color Block) | DM-1 |
|
|
54
|
+
| lesson_plan (arts/general) | R6 (Editorial Warm) | ED-1 |
|
|
55
|
+
| creative / branding / design | R3 (Centered Card Frame) | SN-2 |
|
|
56
|
+
| cultural / newsletter / internal | R6 (Editorial Warm) | ED-1 |
|
|
57
|
+
| activity / event | R6 (Editorial Warm) | ED-1 |
|
|
58
|
+
| trend/research (cultural/creative/brand) | R7 (Swiss Tech) | ST-1 |
|
|
59
|
+
| whitepaper | R2 (Double-Rule Frame) | IG-1 / CM-2 |
|
|
60
|
+
| consulting | R2 (Double-Rule Frame) | MIN-1 |
|
|
61
|
+
| proposal / plan | R4 (Top Color Block) | GO-1 |
|
|
62
|
+
| report | R1 (Pure Paragraph Left) | by industry |
|
|
63
|
+
| default | R1 (Pure Paragraph Left) | DS-1 |
|
|
64
|
+
|
|
65
|
+
⚠️ **Long title routing:** After selecting recipe, apply `applyLongTitleOverride(result, titleLength)`. Titles >20 chars on R3/R4/R6 → fall back to R1. Titles >30 chars on R2 → fall back to R1. R5 is never overridden.
|
|
66
|
+
|
|
67
|
+
⚠️ **Academic thesis cover:** Use `buildAcademicCover()` from `scenes/academic.md`.
|
|
68
|
+
|
|
69
|
+
⚠️ **Thesis proposal report (开题报告):** Use `buildProposalCover()` from `scenes/academic.md`. Cover MUST be an independent section. Keywords: "开题报告" (Chinese), "thesis proposal", "research proposal" — NOT the same as business proposals (which use R4).
|
|
70
|
+
|
|
71
|
+
### Table of Contents?
|
|
72
|
+
- **YES**: 3+ major sections (H1 headings)
|
|
73
|
+
- **NO**: Resumes, exam papers, short docs, contracts (<20 clauses)
|
|
74
|
+
|
|
75
|
+
→ See `references/toc.md` for the complete TOC reference (3-step process, code examples, common bugs).
|
|
76
|
+
|
|
77
|
+
### Headers/Footers?
|
|
78
|
+
- **YES** by default (page numbers minimum)
|
|
79
|
+
- **NO**: cover page section, official docs (special format)
|
|
80
|
+
|
|
81
|
+
### Load Math Formulas?
|
|
82
|
+
When: exam papers, academic papers, physics/math/chemistry → load `references/math-formulas.md`
|
|
83
|
+
|
|
84
|
+
### Load Chart Templates?
|
|
85
|
+
When: data visualization, reports with charts → load `references/chart-templates.md`
|
|
86
|
+
|
|
87
|
+
## Outline Rules
|
|
88
|
+
|
|
89
|
+
**User provides outline** → Follow EXACTLY. No additions, deletions, or reordering.
|
|
90
|
+
|
|
91
|
+
**No outline** → Create from scene template:
|
|
92
|
+
- **Academic:** Abstract → TOC → Body → References
|
|
93
|
+
- **Report:** Use `selectReportType()` to determine type, then follow template A–F:
|
|
94
|
+
- analysis → Template A (Executive Summary → Background → Scope & Method → Findings → Diagnosis → Conclusions)
|
|
95
|
+
- experiment → Template B (Abstract → Objective & Hypothesis → Environment → Procedure → Results → Error Analysis → Conclusions)
|
|
96
|
+
- testing → Template C (Overview → Scope & Environment → Test Plan → Results → Defects → Risks → Conclusions)
|
|
97
|
+
- research → Template D (Summary → Background → Subjects & Method → Sample → Findings → Synthesis → Recommendations)
|
|
98
|
+
- review → Template E (Overview → Goals → Review → Results → Issues → Lessons → Action Plan)
|
|
99
|
+
- proposal → Template F (Summary → Status → Goals → Solution → Roadmap → Resources → Risks → Benefits)
|
|
100
|
+
- **Contract:** Use `selectContractType()` then follow template A–E:
|
|
101
|
+
- bilateral → Template A (Header → Parties → Recitals → Definitions → Subject → Price → Rights → Delivery → Tax → IP → Breach → Force Majeure → Termination → Notices → Dispute → Miscellaneous → Signature)
|
|
102
|
+
- transfer → Template B (Header → Recitals → Definitions → Subject → Consideration → Closing → Representations → Tax → Breach → Dispute → Signature)
|
|
103
|
+
- nda → Template C (Header → Recitals → Definition → Obligations → Use Restrictions → Return/Destroy → Exceptions → Duration → Breach → Dispute → Signature)
|
|
104
|
+
- framework → Template D (Header → Recitals → Purpose → Scope → Division → Mechanism → Commercial → Confidentiality → Term → Breach → Dispute → Signature)
|
|
105
|
+
- terms → Template E (Title → Definitions → Services → Rights → Liability → Fees → IP → Termination → Notices → Dispute → Miscellaneous)
|
|
106
|
+
- **Official:** Use `selectOfficialType()` + `needsRedHeader()`:
|
|
107
|
+
- notice → Template A ([Red header] → [Doc number] → Title → Addressee → Reason → Items → Requirements → [Attachments] → [Signature] → [Date] → [Colophon])
|
|
108
|
+
- letter → Template B ([Red header] → [Doc number] → Title → Addressee → Reason → Negotiation/Reply → Closing → [Signature] → [Date])
|
|
109
|
+
- reply → Template C ([Red header] → [Doc number] → Title → Addressee → Reference → Reply → "This is the reply." → Signature → Date)
|
|
110
|
+
- minutes → Template D (Title → Meeting Overview → Agreed Items → Responsibilities → [Distribution]) — typically no red header
|
|
111
|
+
- Present outline to user before generating when possible
|
|
112
|
+
|
|
113
|
+
## Scene Completeness
|
|
114
|
+
|
|
115
|
+
Include ALL elements a scene specifies:
|
|
116
|
+
- **Academic thesis:** Cover (`buildAcademicCover()` in its own section), abstract, TOC, references
|
|
117
|
+
- **Thesis proposal report (thesis proposal / 开题报告):** Cover (`buildProposalCover()` in its own section), body sections per proposal template. Cover MUST be a separate section.
|
|
118
|
+
- **Report:** Cover, executive summary, conclusions
|
|
119
|
+
- **Contract:** Party info, recitals, complete clause closure, signature block, uniform `【】` placeholders
|
|
120
|
+
- **Official:** Correct document type, specific title, closing phrase matching type, proper numbering hierarchy, red header only when requested
|
|
121
|
+
- **Exam:** Student info area, scoring criteria
|
|
122
|
+
|
|
123
|
+
Generate complete, substantive content — not skeletons.
|
|
124
|
+
|
|
125
|
+
## Content Guidelines
|
|
126
|
+
|
|
127
|
+
- **Length**: "detailed report" = 3000+ words. "brief summary" = 500–1000.
|
|
128
|
+
- **Data**: Use user's data, or generate realistic placeholders
|
|
129
|
+
- **Charts**: Use `references/chart-templates.md` matplotlib templates → PNG → embed
|
|
130
|
+
- **Math**: Use `references/math-formulas.md` LaTeX → docx-js Math mapping
|
|
131
|
+
- **Tables**: For structured data, not layout
|
|
132
|
+
- **Numbering**: Figures, tables numbered sequentially with cross-references
|
|
133
|
+
|
|
134
|
+
## Code Architecture
|
|
135
|
+
|
|
136
|
+
### Heading Style Rule (Mandatory)
|
|
137
|
+
|
|
138
|
+
**All body chapter headings MUST use `heading: HeadingLevel.HEADING_X`** — never simulate with bold + large font (TOC cannot detect simulated headings).
|
|
139
|
+
|
|
140
|
+
**Exception:** Cover title and TOC title ("目录") heading MUST NOT use Heading style.
|
|
141
|
+
|
|
142
|
+
### Blank Page Prevention
|
|
143
|
+
|
|
144
|
+
→ See SKILL.md § Post-Generation checklist for the full set of rules.
|
|
145
|
+
|
|
146
|
+
Key rules:
|
|
147
|
+
1. No double page breaks (SectionType.NEXT_PAGE + PageBreak = blank page)
|
|
148
|
+
2. PageBreak paragraphs should have visible text content
|
|
149
|
+
3. No more than 3 consecutive empty paragraphs
|
|
150
|
+
4. Cover section: ≤2 trailing empty paragraphs, no trailing PageBreak
|
|
151
|
+
|
|
152
|
+
### Builder Pattern Example
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
const { Document, Packer, Paragraph, TextRun, Header, Footer,
|
|
156
|
+
AlignmentType, HeadingLevel, PageNumber } = require("docx");
|
|
157
|
+
const fs = require("fs");
|
|
158
|
+
|
|
159
|
+
// 1. Palette
|
|
160
|
+
const P = { primary: "#101820", body: "#182030", secondary: "#506070", accent: "#8090A0" };
|
|
161
|
+
const c = (hex) => hex.replace("#", "");
|
|
162
|
+
|
|
163
|
+
// 2. Component builders
|
|
164
|
+
function heading(text, level = HeadingLevel.HEADING_1) {
|
|
165
|
+
return new Paragraph({
|
|
166
|
+
heading: level,
|
|
167
|
+
spacing: { before: level === HeadingLevel.HEADING_1 ? 360 : 240, after: 120 },
|
|
168
|
+
children: [new TextRun({ text, bold: true, color: c(P.primary), font: { ascii: "Calibri", eastAsia: "SimHei" } })]
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function body(text) {
|
|
173
|
+
return new Paragraph({
|
|
174
|
+
alignment: AlignmentType.JUSTIFIED,
|
|
175
|
+
indent: { firstLine: 480 },
|
|
176
|
+
spacing: { line: 312 },
|
|
177
|
+
children: [new TextRun({ text, size: 24, color: c(P.body) })],
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 3. Assembly — cover + body in separate sections
|
|
182
|
+
const doc = new Document({
|
|
183
|
+
styles: { default: { document: {
|
|
184
|
+
run: { font: { ascii: "Calibri", eastAsia: "Microsoft YaHei" }, size: 24, color: c(P.body) },
|
|
185
|
+
paragraph: { spacing: { line: 312 } },
|
|
186
|
+
}}},
|
|
187
|
+
sections: [
|
|
188
|
+
{ properties: { page: { margin: { top: 0, bottom: 0, left: 0, right: 0 } } },
|
|
189
|
+
children: buildCoverR1(config) }, // ← use recipe from design-system.md
|
|
190
|
+
{ properties: { page: { margin: { top: 1440, bottom: 1440, left: 1701, right: 1417 } } },
|
|
191
|
+
footers: { default: new Footer({ children: [new Paragraph({ alignment: AlignmentType.CENTER,
|
|
192
|
+
children: [new TextRun({ children: [PageNumber.CURRENT], size: 18 })] })] }) },
|
|
193
|
+
children: [heading("Chapter 1"), body("Content...")] },
|
|
194
|
+
],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
Packer.toBuffer(doc).then(buf => { fs.writeFileSync("output.docx", buf); });
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Post-Generation
|
|
201
|
+
|
|
202
|
+
→ See SKILL.md § Post-Generation for the complete two-layer verification checklist.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
python3 "$DOCX_SCRIPTS/postcheck.py" output.docx
|
|
206
|
+
```
|
|
207
|
+
⚠️ **Running postcheck.py is MANDATORY.** Fix all ❌ errors before delivering.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Route: Edit Existing Document
|
|
2
|
+
|
|
3
|
+
## Workflow Overview
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
1. Receive .docx (or .doc → convert)
|
|
7
|
+
2. Unpack → working directory
|
|
8
|
+
3. Analyze structure (document.xml, styles.xml)
|
|
9
|
+
4. Plan changes → batch by type
|
|
10
|
+
5. Implement via Document library (Python)
|
|
11
|
+
6. Pack → output.docx
|
|
12
|
+
7. Verify (pandoc or visual)
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Step 0: Format Conversion
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# .doc → .docx
|
|
19
|
+
libreoffice --headless --convert-to docx input.doc
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Step 1: Unpack
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
mkdir -p work_dir && cd work_dir && unzip ../input.docx
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Key files: `word/document.xml` (content), `word/styles.xml` (styles), `word/numbering.xml` (lists), `word/media/` (images), `[Content_Types].xml`, `word/_rels/document.xml.rels`
|
|
29
|
+
|
|
30
|
+
## Step 2: Plan Changes
|
|
31
|
+
|
|
32
|
+
Group changes into batches, process in order:
|
|
33
|
+
|
|
34
|
+
1. **Structural** — Add/remove sections, reorder paragraphs
|
|
35
|
+
2. **Style** — Font, size, color modifications
|
|
36
|
+
3. **Text** — Find/replace, fix typos
|
|
37
|
+
4. **Table** — Add/remove rows/columns, update data
|
|
38
|
+
5. **Image** — Replace/add images
|
|
39
|
+
|
|
40
|
+
## Step 3: Implement
|
|
41
|
+
|
|
42
|
+
Load `references/ooxml.md` for the full Document library API. Key patterns:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from scripts.document import Document
|
|
46
|
+
|
|
47
|
+
doc = Document('work_dir')
|
|
48
|
+
|
|
49
|
+
# Text replacement with tracked changes
|
|
50
|
+
node = doc["word/document.xml"].get_node(tag="w:r", contains="old text")
|
|
51
|
+
rpr = tags[0].toxml() if (tags := node.getElementsByTagName("w:rPr")) else ""
|
|
52
|
+
replacement = f'<w:del><w:r>{rpr}<w:delText>old text</w:delText></w:r></w:del><w:ins><w:r>{rpr}<w:t>new text</w:t></w:r></w:ins>'
|
|
53
|
+
doc["word/document.xml"].replace_node(node, replacement)
|
|
54
|
+
|
|
55
|
+
doc.save()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Step 4: Pack
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cd work_dir && zip -r ../output.docx . -x ".*"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Step 5: Verify
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pandoc output.docx -t plain -o /dev/stdout | head -50
|
|
68
|
+
# or visual
|
|
69
|
+
libreoffice --headless --convert-to pdf output.docx
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Template Matching Workflow
|
|
75
|
+
|
|
76
|
+
When user says "use this format" or provides a template:
|
|
77
|
+
|
|
78
|
+
1. Unpack template, extract `styles.xml`, `numbering.xml`
|
|
79
|
+
2. Analyze font/size/spacing/margins
|
|
80
|
+
3. Copy `styles.xml` into target document
|
|
81
|
+
4. Match heading hierarchy and spacing
|
|
82
|
+
|
|
83
|
+
## Multi-File Merge
|
|
84
|
+
|
|
85
|
+
1. Use first document as base
|
|
86
|
+
2. Extract content from additional documents
|
|
87
|
+
3. Insert with page breaks between sections
|
|
88
|
+
4. Merge styles (prefer base document's)
|
|
89
|
+
5. Re-number figures/tables sequentially
|
|
90
|
+
|
|
91
|
+
## Redlining (Tracked Changes) — Default for Revisions
|
|
92
|
+
|
|
93
|
+
When user asks for revisions, **default to tracked changes** so they can review:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
doc = Document('work_dir', track_revisions=True)
|
|
97
|
+
# ... make changes using replace_node with <w:del>/<w:ins>
|
|
98
|
+
doc.save()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Ask user if they want clean output or tracked changes only if ambiguous.
|
|
102
|
+
|
|
103
|
+
## Common Operations Quick Reference
|
|
104
|
+
|
|
105
|
+
| Operation | Approach |
|
|
106
|
+
|-----------|----------|
|
|
107
|
+
| Replace text | `get_node` + `replace_node` with tracked changes |
|
|
108
|
+
| Change font | Modify `<w:rFonts>` in run properties |
|
|
109
|
+
| Add paragraph | `insert_after` with `<w:p>` element |
|
|
110
|
+
| Delete paragraph | `suggest_deletion` on `<w:p>` |
|
|
111
|
+
| Add table row | Clone `<w:tr>`, modify cells |
|
|
112
|
+
| Update header | Edit `word/headerN.xml` |
|
|
113
|
+
| Change margins | Edit `<w:pgMar>` in `<w:sectPr>` |
|
|
114
|
+
| Add image | See `references/ooxml.md` image insertion pattern |
|
|
115
|
+
| Add comment | `doc.add_comment(start, end, text)` |
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Route: Format / Layout
|
|
2
|
+
|
|
3
|
+
## Workflow
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
1. Read current document (pandoc for content, unpack for structure)
|
|
7
|
+
2. Identify format requirements from user
|
|
8
|
+
3. Use unit conversion table (see SKILL.md)
|
|
9
|
+
4. Apply formatting via OOXML manipulation or python-docx
|
|
10
|
+
5. Pack and verify
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Formatting via python-docx
|
|
14
|
+
|
|
15
|
+
For simple formatting tasks, python-docx is often faster than raw XML:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from docx import Document as PythonDocument
|
|
19
|
+
from docx.shared import Pt, Cm, Twips
|
|
20
|
+
from docx.enum.text import WD_ALIGN_PARAGRAPH
|
|
21
|
+
|
|
22
|
+
doc = PythonDocument("input.docx")
|
|
23
|
+
|
|
24
|
+
# Change all body paragraph formatting
|
|
25
|
+
for para in doc.paragraphs:
|
|
26
|
+
if para.style.name.startswith("Heading"):
|
|
27
|
+
continue
|
|
28
|
+
para.paragraph_format.first_line_indent = Twips(420)
|
|
29
|
+
para.paragraph_format.line_spacing = 1.5
|
|
30
|
+
para.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY
|
|
31
|
+
for run in para.runs:
|
|
32
|
+
run.font.name = "宋体"
|
|
33
|
+
run.font.size = Pt(12) # Xiao Si 小四
|
|
34
|
+
|
|
35
|
+
doc.save("output.docx")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Common Format Request Patterns
|
|
39
|
+
|
|
40
|
+
### University Thesis Formatting
|
|
41
|
+
|
|
42
|
+
Typical Chinese university thesis requirements:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from docx.shared import Cm, Pt, Twips
|
|
46
|
+
|
|
47
|
+
# Margins
|
|
48
|
+
for section in doc.sections:
|
|
49
|
+
section.top_margin = Cm(2.5)
|
|
50
|
+
section.bottom_margin = Cm(2.5)
|
|
51
|
+
section.left_margin = Cm(3.0)
|
|
52
|
+
section.right_margin = Cm(2.5)
|
|
53
|
+
|
|
54
|
+
# Fonts
|
|
55
|
+
# Body: SimSun 宋体 Xiao Si 小四 (12pt)
|
|
56
|
+
# H1: SimHei 黑体 San Hao 三号 (16pt) centered
|
|
57
|
+
# H2: SimHei 黑体 Si Hao 四号 (14pt)
|
|
58
|
+
# H3: SimHei 黑体 Xiao Si 小四 (12pt)
|
|
59
|
+
# English: Times New Roman, same sizes
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Page Numbers Starting from Specific Page
|
|
63
|
+
|
|
64
|
+
Use multi-section approach:
|
|
65
|
+
```python
|
|
66
|
+
# Section 1: Front matter (Roman numerals)
|
|
67
|
+
# Section 2: Main content (Arabic, starting from 1)
|
|
68
|
+
# This requires OOXML manipulation — see routes/edit.md for unpack/pack workflow
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
In raw XML (`word/document.xml`):
|
|
72
|
+
```xml
|
|
73
|
+
<w:sectPr>
|
|
74
|
+
<w:pgNumType w:fmt="upperRoman" w:start="1"/>
|
|
75
|
+
</w:sectPr>
|
|
76
|
+
<!-- New section -->
|
|
77
|
+
<w:sectPr>
|
|
78
|
+
<w:pgNumType w:fmt="decimal" w:start="1"/>
|
|
79
|
+
</w:sectPr>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Different Headers Per Section
|
|
83
|
+
|
|
84
|
+
Each section in a .docx can have its own header/footer. See `references/docx-js-advanced.md` for the multi-section approach.
|
|
85
|
+
|
|
86
|
+
For existing documents, modify `word/document.xml` to split `<w:sectPr>` and create separate `headerN.xml` files.
|
|
87
|
+
|
|
88
|
+
### Font Size Conversion
|
|
89
|
+
|
|
90
|
+
When user requests a Chinese font size name:
|
|
91
|
+
|
|
92
|
+
| Request | Action |
|
|
93
|
+
|---------|--------|
|
|
94
|
+
| "Change to Wu Hao (5th) size" | `font.size = Pt(10.5)` or `size: 21` in docx-js |
|
|
95
|
+
| "Title in San Hao SimHei" | `font.size = Pt(16)`, `font.name = "SimHei"` |
|
|
96
|
+
| "Body in Xiao Si SimSun" | `font.size = Pt(12)`, `font.name = "SimSun"` |
|
|
97
|
+
|
|
98
|
+
### Line Spacing Adjustment
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from docx.shared import Twips
|
|
102
|
+
|
|
103
|
+
# 1.0x spacing
|
|
104
|
+
para.paragraph_format.line_spacing_rule = WD_LINE_SPACING.MULTIPLE
|
|
105
|
+
para.paragraph_format.line_spacing = 1.0
|
|
106
|
+
|
|
107
|
+
# 1.3x spacing (our default)
|
|
108
|
+
para.paragraph_format.line_spacing = 1.5
|
|
109
|
+
|
|
110
|
+
# Fixed spacing (e.g., 28pt)
|
|
111
|
+
para.paragraph_format.line_spacing_rule = WD_LINE_SPACING.EXACTLY
|
|
112
|
+
para.paragraph_format.line_spacing = Pt(28)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Verification
|
|
116
|
+
|
|
117
|
+
After formatting changes:
|
|
118
|
+
1. Open in LibreOffice or convert to PDF for visual check
|
|
119
|
+
2. Extract text with pandoc to ensure content unchanged
|
|
120
|
+
3. Compare file sizes (formatting-only changes shouldn't dramatically change size)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Route: Read / Analyze / Extract
|
|
2
|
+
|
|
3
|
+
## Method 1: Text Extraction via pandoc (Fastest)
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# Plain text
|
|
7
|
+
pandoc input.docx -t plain -o output.txt
|
|
8
|
+
|
|
9
|
+
# Markdown (preserves structure)
|
|
10
|
+
pandoc input.docx -t markdown -o output.md
|
|
11
|
+
|
|
12
|
+
# Extract with metadata
|
|
13
|
+
pandoc input.docx -t markdown --standalone -o output.md
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Best for**: Quick content reading, text analysis, word count, searching.
|
|
17
|
+
|
|
18
|
+
## Method 2: Raw XML Access (Detailed)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
mkdir work && cd work && unzip ../input.docx
|
|
22
|
+
|
|
23
|
+
# Read main content
|
|
24
|
+
cat word/document.xml
|
|
25
|
+
|
|
26
|
+
# Read styles
|
|
27
|
+
cat word/styles.xml
|
|
28
|
+
|
|
29
|
+
# List embedded media
|
|
30
|
+
ls word/media/
|
|
31
|
+
|
|
32
|
+
# Read headers/footers
|
|
33
|
+
cat word/header1.xml
|
|
34
|
+
cat word/footer1.xml
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Best for**: Analyzing formatting, extracting styles, inspecting document structure, debugging layout issues.
|
|
38
|
+
|
|
39
|
+
### Quick XML Parsing
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import defusedxml.ElementTree as ET
|
|
43
|
+
|
|
44
|
+
tree = ET.parse("word/document.xml")
|
|
45
|
+
ns = {"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"}
|
|
46
|
+
|
|
47
|
+
# Extract all text
|
|
48
|
+
texts = []
|
|
49
|
+
for t in tree.iter("{http://schemas.openxmlformats.org/wordprocessingml/2006/main}t"):
|
|
50
|
+
if t.text:
|
|
51
|
+
texts.append(t.text)
|
|
52
|
+
full_text = "".join(texts)
|
|
53
|
+
|
|
54
|
+
# Count paragraphs
|
|
55
|
+
paras = tree.findall(".//w:p", ns)
|
|
56
|
+
print(f"Paragraphs: {len(paras)}")
|
|
57
|
+
|
|
58
|
+
# Find headings
|
|
59
|
+
for para in paras:
|
|
60
|
+
pPr = para.find("w:pPr", ns)
|
|
61
|
+
if pPr is not None:
|
|
62
|
+
pStyle = pPr.find("w:pStyle", ns)
|
|
63
|
+
if pStyle is not None and "Heading" in pStyle.get(f"{{{ns['w']}}}val", ""):
|
|
64
|
+
text = "".join(t.text for t in para.iter(f"{{{ns['w']}}}t") if t.text)
|
|
65
|
+
print(f" {pStyle.get(f'{{{ns[\"w\"]}}}val')}: {text}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Method 3: Convert to Images (Visual Analysis)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Convert to PDF first
|
|
72
|
+
libreoffice --headless --convert-to pdf input.docx
|
|
73
|
+
|
|
74
|
+
# Then to images
|
|
75
|
+
pdftoppm -png -r 200 input.pdf page
|
|
76
|
+
|
|
77
|
+
# Generates page-1.png, page-2.png, etc.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Best for**: Visual layout analysis, comparing formatting, generating previews, when user asks "what does it look like".
|
|
81
|
+
|
|
82
|
+
## Method 4: python-docx Reading
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from docx import Document
|
|
86
|
+
|
|
87
|
+
doc = Document("input.docx")
|
|
88
|
+
|
|
89
|
+
# Read paragraphs
|
|
90
|
+
for para in doc.paragraphs:
|
|
91
|
+
print(f"[{para.style.name}] {para.text}")
|
|
92
|
+
|
|
93
|
+
# Read tables
|
|
94
|
+
for table in doc.tables:
|
|
95
|
+
for row in table.rows:
|
|
96
|
+
print([cell.text for cell in row.cells])
|
|
97
|
+
|
|
98
|
+
# Document properties
|
|
99
|
+
print(f"Sections: {len(doc.sections)}")
|
|
100
|
+
print(f"Paragraphs: {len(doc.paragraphs)}")
|
|
101
|
+
print(f"Tables: {len(doc.tables)}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Choosing the Right Method
|
|
105
|
+
|
|
106
|
+
| Need | Method |
|
|
107
|
+
|------|--------|
|
|
108
|
+
| Quick text content | pandoc |
|
|
109
|
+
| Document structure/outline | pandoc → markdown |
|
|
110
|
+
| Formatting details | Raw XML |
|
|
111
|
+
| Table data extraction | python-docx |
|
|
112
|
+
| Visual appearance | Convert to images |
|
|
113
|
+
| Style analysis | Raw XML (styles.xml) |
|
|
114
|
+
| Word/character count | pandoc → plain → wc |
|