Loading...
Loading...
Compare original and translation side by side
bash scripts/setup.shpowershell scripts/setup.ps1--minimalscripts/env_check.shNOT READYbash scripts/setup.shpowershell scripts/setup.ps1--minimalscripts/env_check.shNOT READY// File: scripts/dotnet/task.csx (or a new .cs in a Console project)
// dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli -- run-script task.csx
#r "nuget: DocumentFormat.OpenXml, 3.2.0"
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using var doc = WordprocessingDocument.Create("output.docx", WordprocessingDocumentType.Document);
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(new Body());
// --- Your logic here ---
// Read the relevant Samples/*.cs file FIRST for tested patterns.
// See Samples/ table in References section below.Samples/*.cs// 文件路径:scripts/dotnet/task.csx (或在控制台项目中新建.cs文件)
// 执行命令:dotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli -- run-script task.csx
#r "nuget: DocumentFormat.OpenXml, 3.2.0"
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using var doc = WordprocessingDocument.Create("output.docx", WordprocessingDocumentType.Document);
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document(new Body());
// --- 在此处编写你的逻辑 ---
// 请先阅读相关Samples/*.cs文件,参考经过验证的实现模式。
// 可参考下方参考资料中的Samples表格。Samples/*.cs$CLIdotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli --$CLIdotnet run --project scripts/dotnet/MiniMaxAIDocx.Cli --User task
├─ No input file → Pipeline A: CREATE
│ signals: "write", "create", "draft", "generate", "new", "make a report/proposal/memo"
│ → Read references/scenario_a_create.md
│
└─ Has input .docx
├─ Replace/fill/modify content → Pipeline B: FILL-EDIT
│ signals: "fill in", "replace", "update", "change text", "add section", "edit"
│ → Read references/scenario_b_edit_content.md
│
└─ Reformat/apply style/template → Pipeline C: FORMAT-APPLY
signals: "reformat", "apply template", "restyle", "match this format", "套模板", "排版"
├─ Template is pure style (no content) → C-1: OVERLAY (apply styles to source)
└─ Template has structure (cover/TOC/example sections) → C-2: BASE-REPLACE
(use template as base, replace example content with user content)
→ Read references/scenario_c_apply_template.md用户任务
├─ 无输入文件 → 流程A:创建文档
│ 触发关键词:"撰写"、"创建"、"起草"、"生成"、"新建"、"制作报告/提案/备忘录"
│ → 阅读参考文档references/scenario_a_create.md
│
└─ 有输入.docx文件
├─ 替换/填充/修改内容 → 流程B:填充与编辑
│ 触发关键词:"填写"、"替换"、"更新"、"修改文本"、"添加章节"、"编辑"
│ → 阅读参考文档references/scenario_b_edit_content.md
│
└─ 重新格式化/应用样式/模板 → 流程C:格式应用
触发关键词:"重新排版"、"应用模板"、"修改样式"、"匹配此格式"、"套模板"、"排版"
├─ 模板仅包含样式(无内容) → C-1:覆盖模式(将样式应用到源文档)
└─ 模板包含结构(封面/目录/示例章节) → C-2:基础替换模式
(以模板为基础,将示例内容替换为用户提供的内容)
→ 阅读参考文档references/scenario_c_apply_template.md.doc.docxscripts/doc_to_docx.sh input.doc output_dir/scripts/docx_preview.sh document.docx$CLI analyze --input document.docx.doc.docxscripts/doc_to_docx.sh input.doc output_dir/scripts/docx_preview.sh document.docx$CLI analyze --input document.docxreferences/scenario_a_create.mdreferences/typography_guide.mdreferences/design_principles.mdSamples/AestheticRecipeSamples.csreferences/cjk_typography.md$CLI create --type report --output out.docx --config content.jsonSamples/*.cs--type--title--author--page-size--margins--header--footer--page-numbers--toc--content-jsonreferences/scenario_a_create.mdreferences/typography_guide.mdreferences/design_principles.mdSamples/AestheticRecipeSamples.csreferences/cjk_typography.md$CLI create --type report --output out.docx --config content.jsonSamples/*.cs--type--title--author--page-size--margins--header--footer--page-numbers--toc--content-jsonreferences/scenario_b_edit_content.mdreferences/openxml_element_order.mdSamples/*.csreplace-text --find "X" --replace "Y"fill-placeholders --data '{"key":"value"}'fill-table --data table.jsoninsert-sectionremove-sectionupdate-header-footer$CLI edit replace-text --input in.docx --output out.docx --find "OLD" --replace "NEW"
$CLI edit fill-placeholders --input in.docx --output out.docx --data '{"name":"John"}'$CLI diff --before in.docx --after out.docxreferences/scenario_b_edit_content.mdreferences/openxml_element_order.mdSamples/*.csreplace-text --find "X" --replace "Y"fill-placeholders --data '{"key":"value"}'fill-table --data table.jsoninsert-sectionremove-sectionupdate-header-footer$CLI edit replace-text --input in.docx --output out.docx --find "OLD" --replace "NEW"
$CLI edit fill-placeholders --input in.docx --output out.docx --data '{"name":"John"}'$CLI diff --before in.docx --after out.docxreferences/scenario_c_apply_template.md$CLI apply-template --input source.docx --template template.docx --output out.docx$CLI validate --input out.docx --gate-check assets/xsd/business-rules.xsd$CLI diff --before source.docx --after out.docxreferences/scenario_c_apply_template.md$CLI apply-template --input source.docx --template template.docx --output out.docx$CLI validate --input out.docx --gate-check assets/xsd/business-rules.xsd$CLI diff --before source.docx --after out.docx$CLI merge-runs --input doc.docx # 1. consolidate runs
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd # 2. XSD structure
$CLI validate --input doc.docx --business # 3. business rules$CLI fix-order --input doc.docx
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd$CLI validate --input doc.docx --business
scripts/docx_preview.sh doc.docx$CLI merge-runs --input doc.docx # 1. 合并连续文本段
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd # 2. XSD结构校验
$CLI validate --input doc.docx --business # 3. 业务规则校验$CLI fix-order --input doc.docx
$CLI validate --input doc.docx --xsd assets/xsd/wml-subset.xsd$CLI validate --input doc.docx --business
scripts/docx_preview.sh doc.docx
Final preview: `scripts/docx_preview.sh doc.docx`
最终预览:执行`scripts/docx_preview.sh doc.docx`| Parent | Order |
|---|---|
| |
| |
| |
| |
| |
| block content → |
rPrpPrpStyletpPr/rPr<w:del><w:delText><w:t><w:ins><w:t><w:delText>w:szsz="24"new OutlineLevel { Val = N }StyleParagraphPropertiesreferences/scenario_c_apply_template.mdw:sectPrw:pPrw:spacingtitlePgtitlePg=truereferences/scenario_c_apply_template.md| 父元素 | 顺序 |
|---|---|
| |
| |
| |
| |
| |
| 块级内容 → |
rPrpPrpStyletpPr/rPr<w:del><w:delText><w:t><w:ins><w:t><w:delText>w:szsz="24"StyleParagraphPropertiesnew OutlineLevel { Val = N }references/scenario_c_apply_template.mdw:pPrw:sectPrw:spacingtitlePgtitlePg=truereferences/scenario_c_apply_template.md| File | When |
|---|---|
| Pipeline A: creating from scratch |
| Pipeline B: editing existing content |
| Pipeline C: applying template formatting |
| 文件 | 适用场景 |
|---|---|
| 流程A:从零创建文档 |
| 流程B:编辑现有内容 |
| 流程C:应用模板格式 |
| File | Topic |
|---|---|
| Document lifecycle: create, open, save, streams, doc defaults, settings, properties, page setup, multi-section |
| Styles: Normal/Heading chain, character/table/list styles, DocDefaults, latentStyles, CJK 公文, APA 7th, import, resolve inheritance |
| RunProperties: fonts, size, bold/italic, all underlines, color, highlight, strike, sub/super, caps, spacing, shading, border, emphasis marks |
| ParagraphProperties: justification, indentation, line/paragraph spacing, keep/widow, outline level, borders, tabs, numbering, bidi, frame |
| Tables: borders, grid, cell props, margins, row height, header repeat, merge (H+V), nested, floating, three-line 三线表, zebra striping |
| Headers/footers: page numbers, "Page X of Y", first/even/odd, logo image, table layout, 公文 "-X-", per-section |
| Images: inline, floating, text wrapping, border, alt text, in header/table, replace, SVG fallback, dimension calc |
| Numbering: bullets, multi-level decimal, custom symbols, outline→headings, legal, Chinese 一/(一)/1./(1), restart/continue |
| Fields: TOC, SimpleField vs complex field, DATE/PAGE/REF/SEQ/MERGEFIELD/IF/STYLEREF, TOC styles |
| Footnotes, endnotes, comments (4-file system), bookmarks, hyperlinks (internal + external) |
| Revisions: insertions (w:t), deletions (w:delText!), formatting changes, accept/reject all, move tracking |
| 13 aesthetic recipes from authoritative sources: ModernCorporate, AcademicThesis, ExecutiveBrief, ChineseGovernment (GB/T 9704), MinimalModern, IEEE Conference, ACM sigconf, APA 7th, MLA 9th, Chicago/Turabian, Springer LNCS, Nature, HBR — each with exact values from official style guides |
Samples/scripts/dotnet/MiniMaxAIDocx.Core/| 文件 | 主题 |
|---|---|
| 文档生命周期:创建、打开、保存、流操作、文档默认设置、属性、页面布局、多章节 |
| 样式系统:Normal/Heading样式链、字符/表格/列表样式、DocDefaults、latentStyles、CJK公文样式、APA第7版、样式导入、继承解析 |
| 字符格式:字体、字号、粗体/斜体、所有下划线类型、颜色、高亮、删除线、下标/上标、大小写、字符间距、底纹、边框、着重号 |
| 段落格式:对齐方式、缩进、行/段落间距、孤行控制、大纲级别、边框、制表位、编号、双向文本、框架 |
| 表格:边框、网格、单元格属性、边距、行高、表头重复、合并(水平+垂直)、嵌套表格、浮动表格、三线表、斑马纹 |
| 页眉/页脚:页码、“第X页,共Y页”、首页/偶数页/奇数页设置、Logo图片、表格布局、公文“-X-”格式、按章节设置 |
| 图片:嵌入式、浮动式、文字环绕、边框、替代文本、页眉/表格中插入、图片替换、SVG降级、尺寸计算 |
| 编号列表:项目符号、多级十进制编号、自定义符号、大纲→标题、法律文书编号、中文一/(一)/1./(1)格式、编号重启/延续 |
| 域:目录、SimpleField与复杂域、DATE/PAGE/REF/SEQ/MERGEFIELD/IF/STYLEREF、目录样式 |
| 脚注、尾注、批注(4文件系统)、书签、超链接(内部+外部) |
| 修订跟踪:插入(w:t)、删除(w:delText!)、格式修改、接受/拒绝所有修订、移动跟踪 |
| 13种来自权威机构的排版方案:ModernCorporate、AcademicThesis、ExecutiveBrief、ChineseGovernment(GB/T 9704)、MinimalModern、IEEE Conference、ACM sigconf、APA 7th、MLA 9th、Chicago/Turabian、Springer LNCS、Nature、HBR——每种方案均包含官方样式指南中的精确参数值 |
Samples/scripts/dotnet/MiniMaxAIDocx.Core/| File | When |
|---|---|
| XML element ordering rules (prevents corruption) |
| Unit conversion: DXA, EMU, half-points, eighth-points |
| Detailed C# encyclopedia: document creation, styles, character & paragraph formatting |
| Detailed C# encyclopedia: page setup, tables, headers/footers, sections, doc properties |
| Detailed C# encyclopedia: TOC, footnotes, fields, track changes, comments, images, math, numbering, protection |
| Font pairing, sizes, spacing, page layout, table design, color schemes |
| CJK fonts, 字号 sizes, RunFonts mapping, GB/T 9704 公文 standard |
| Chinese university thesis templates: numeric styleIds (1/2/3 vs Heading1), document zone structure (cover→abstract→TOC→body→references), font expectations, common mistakes |
| Aesthetic foundations: 6 design principles (white space, contrast/scale, proximity, alignment, repetition, hierarchy) — teaches WHY, not just WHAT |
| Good vs Bad comparisons: 10 categories of typography mistakes with OpenXML values, ASCII mockups, and fixes |
| Revision marks deep dive |
| Symptom-driven fixes: 13 common problems indexed by what you SEE (headings wrong, images missing, TOC broken, etc.) — search by symptom, find the fix |
| 文件 | 适用场景 |
|---|---|
| XML元素顺序规则(避免文件损坏) |
| 单位转换:DXA、EMU、半磅、八分之一磅 |
| 详细C#百科:文档创建、样式、字符与段落格式 |
| 详细C#百科:页面布局、表格、页眉/页脚、章节、文档属性 |
| 详细C#百科:目录、脚注、域、修订跟踪、批注、图片、公式、编号、文档保护 |
| 字体搭配、字号、间距、页面布局、表格设计、配色方案 |
| CJK字体、字号、RunFonts映射、GB/T 9704公文标准 |
| 中文高校毕业论文模板:数字样式ID(1/2/3 vs Heading1)、文档区域结构(封面→摘要→目录→正文→参考文献)、字体要求、常见错误 |
| 排版美学基础:6大设计原则(留白、对比/比例、 proximity、对齐、重复、层级)——解释“为什么”而非仅“怎么做” |
| 正反案例对比:10类排版错误的OpenXML值、ASCII模拟图及修复方案 |
| 修订标记深度解析 |
| 症状驱动的故障排除:13类常见问题(标题异常、图片丢失、目录失效等)——按症状搜索即可找到修复方案 |