AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
feat(pptx-to-svg): reconstruct formulas without silent native loss
hugohe30ea3236d401e
diff --git a/docs/faq.md b/docs/faq.mdindex 2241cc83..8957297e 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -162,7 +162,11 @@ documented Microsoft 365 2606 / Mac 16.110 LaTeX profile and 2605 / 16.109mhchem profile: symbols, structures, environments, macros, chemistry, localformula colors, and the documented native normalizations. Unknown andexplicitly unsupported input fails closed instead of appearing as raw LaTeX.-PPT Master does not implement reverse OMML-to-LaTeX build-down.+For PPTX import, the same closed OMML validator supports a narrow reverse path:+PPT Master-owned block and inline math becomes canonical formula markers with+visible SVG previews. This recovers normalized semantics, not the author's+original LaTeX spelling and not arbitrary third-party OMML. Unknown OMML is+reported and retained as readable/opaque fallback in tolerant mode.The generated OMML retains the PowerPoint 2010+ package target, and theexecutable source profile is pinned to the Microsoft documentation versionsdiff --git a/docs/powerpoint-svg-mapping.md b/docs/powerpoint-svg-mapping.mdindex 51e09876..13d3a712 100644--- a/docs/powerpoint-svg-mapping.md+++ b/docs/powerpoint-svg-mapping.md@@ -214,6 +214,7 @@ The exhaustive chart/table schemas and supported family list intentionally remai| LaTeX input profile | Canonical marker sources omit outer delimiters; one complete `$...$`, `$$...$$`, `\(...\)`, or `\[...\]` pair is also accepted | Every explicitly named input in the pinned Microsoft 365 2606 / Mac 16.110 profile, plus the 2605 / 16.109 mhchem profile, compiles to editable OMML | The profile is pinned to those Microsoft documentation versions; emitted OMML retains the PowerPoint 2010+ package target. Repository verification is compiler/OMML/package-level, not complete Microsoft 365 UI certification | Explicit native normalizations are preserved; unknown or explicitly unsupported input fails closed rather than leaking as literal LaTeX || Editable block equation | One `<g data-pptx-replace-with="formula">` with explicit bounds, source LaTeX in `<metadata type="application/json">`, and visible SVG preview children | PowerPoint text shape containing `a14:m > m:oMathPara > m:oMath` | See the input-profile row | Matrices, multiline derivations, and other standalone high-structure formulas use the registered block contract || Editable inline formula | A leaf `<tspan data-pptx-inline-formula="canonical LaTeX body">preview text</tspan>` among ordinary text runs | The same DrawingML `a:p` retains surrounding runs and inserts `a14:m > m:oMath` | See the input-profile row | Direct non-empty preview text only; no child element, positional `x/y/dx/dy`, structured placeholder/Master/Layout ownership, preserved imported `txBody`, or native-replacement ancestor |+| PPTX formula reverse import | Validator-clean `m:oMathPara` becomes a block marker; validator-clean `m:oMath` remains an inline marker with surrounding runs | Re-export recompiles the canonicalized LaTeX to editable OMML | `Native-normalized` for PPT Master-owned closed OMML vocabulary | The original LaTeX spelling is not recoverable; unknown third-party OMML gets `formula-not-reconstructed`, readable text, and relationship-free opaque `txBody` retention in tolerant mode || Browser / live preview | Ordinary SVG children inside a block marker, or the inline marker's direct text | Only the registered preview is discarded when native math is written | Raw LaTeX does not render in SVG | Preview content must express the same formula; it is not a PPTX fallback || Formula typography | Block payload style, or computed inline text-run style | Math inherits size and visible solid fill, then uses the project text language and Cambria Math; local `\color` / `\textcolor` scopes override the inherited fill on selectable runs and structural controls, while `\boldsymbol` / `\bm` also styles structural control glyphs | PowerPoint 2010+ OMML | High-structure or multiline math remains block-level || Non-PowerPoint formula playback | The same native markers; no picture branch | No compatibility fallback is added | Keynote, WPS, LibreOffice, and other clients are outside the formula contract | Do not claim cross-client rendering or editability |@@ -223,7 +224,9 @@ Formula replacement is always active and does not usePNG, media relationship, or `mc:Fallback` picture. Block JSON and inline`data-pptx-inline-formula` values are the native formula sources; SVG previewcontent exists only so the authored page remains visible before export.-Compilation is forward-only: PPT Master does not build OMML back down to LaTeX.+`pptx_to_svg.py` performs the narrow inverse only for OMML accepted by the same+closed validator, and its output is canonical LaTeX rather than the author's+original spelling. It does not claim arbitrary Office Math conversion.The executable closed vocabulary and pinned Microsoft source revisions live in`formula_profile.py`; Microsoft's open-ended “etc.” does not make undisclosedrelation aliases part of this contract.diff --git a/docs/roadmap.md b/docs/roadmap.mdindex 64d147fa..9d1c2626 100644--- a/docs/roadmap.md+++ b/docs/roadmap.md@@ -45,7 +45,7 @@ A presentation is four layers: what is on the slide, how it is arranged, how it| Charts | Systematized | Dedicated authoring reference; SVG by default, native Chart replacement available as an explicit opt-in || Tables | Systematized | Dedicated authoring reference; six reusable cell-grid references, with custom grids still available; native Table replacement uses the same opt-in || Diagrams | Systematized | Six relationship atoms — `order`, `link`, `parent`, `membership`, `contrast`, `overlap` |-| Formulas | Systematized | Standalone block and same-paragraph inline formulas compile every explicitly documented Microsoft 365 LaTeX / mhchem input to editable OMML, with documented native normalizations and fail-closed handling outside the profile. SVG previews are authoring-only and no image fallback is emitted. The package target remains PowerPoint 2010+; the executable profile is pinned to the stated Microsoft documentation versions, while repository verification is compiler/OMML/package-level rather than complete Microsoft 365 UI certification. Non-PowerPoint clients remain outside the contract |+| Formulas | Systematized | Standalone block and same-paragraph inline formulas compile every explicitly documented Microsoft 365 LaTeX / mhchem input to editable OMML, with documented native normalizations and fail-closed handling outside the profile. PPTX import rebuilds validator-clean, PPT Master-owned OMML into normalized formula markers with visible SVG previews; arbitrary third-party OMML and original LaTeX spelling recovery remain outside the contract. No image fallback is emitted. The package target remains PowerPoint 2010+; the executable profile is pinned to the stated Microsoft documentation versions, while repository verification is compiler/OMML/package-level rather than complete Microsoft 365 UI certification. Non-PowerPoint clients remain outside the contract || Narration & animation audio | Systematized | Per-slide narration audio, plus native transition and object sounds drawn from the bundled CC0 catalog || Arbitrary video & background music | Not planned | A one-off, content-specific insert that is faster to place by hand in PowerPoint, and the AI cannot pick the file for you. Background music additionally pulls in narration-mixing decisions that are out of scope. Media already present in a source deck is preserved unchanged through the Fill and Enhance routes || SmartArt | Asymmetric by design | Source diagram parts are read for their content and structure; generated decks redraw that content through the ordinary shape pipeline. DiagramML is never edited and native SmartArt regeneration is not promised |diff --git a/docs/technical-design.md b/docs/technical-design.mdindex 4b4dfb72..87ee0e64 100644--- a/docs/technical-design.md+++ b/docs/technical-design.md@@ -517,8 +517,12 @@ property. A closed Microsoftstructurally validates the narrow OMML vocabulary used by both block and inlinepaths. The forward compiler covers every explicitly documented input and nativenormalization in the pinned Microsoft 365 LaTeX and mhchem profiles; unknown,-explicitly unsupported, invalid, or resource-overflow input fails closed, and-PPT Master does not build OMML back down to LaTeX. Matrices, multiline+explicitly unsupported, invalid, or resource-overflow input fails closed.+The PPTX importer applies a narrower inverse to that same validator-clean,+project-owned OMML vocabulary: it emits canonical block/inline formula markers+with visible SVG previews, not the author's original LaTeX spelling. Unknown+third-party OMML remains a diagnosed readable/opaque fallback rather than a+native reconstruction claim. Matrices, multilinederivations, and other high-structure expressions remain blocks. Both formskeep ordinary SVG preview content because raw LaTeX does not render in SVG.PowerPoint 2010+ is the package target, with no formula PNG, media relationship,diff --git a/docs/why-ppt-master.md b/docs/why-ppt-master.mdindex 218481d6..5215659a 100644--- a/docs/why-ppt-master.md+++ b/docs/why-ppt-master.md@@ -30,7 +30,7 @@ Editable is already table stakes — exporting each slide as an editable `.pptx`And this depth is a **direction of travel, not a fixed list.** The project's north star is to keep converging with PowerPoint itself — an ongoing effort to build and integrate more of its native capabilities, release after release, narrowing the gap between what an AI can generate for you and what you could build by hand in PowerPoint.-So the boundary is honest, and it moves. Some things are out of scope today — **SmartArt** (a closed, brittle object model, deliberately left out and better rebuilt from ordinary native shapes), a few decorative effects (WordArt, reflection, soft edges), and embedded or legacy objects (OLE, video, macros). Native equations cover standalone blocks and same-paragraph inline math, with an executable input profile pinned to the documented Microsoft 365 versions and a PowerPoint 2010+ package target; repository verification is compiler/OMML/package-level rather than complete Microsoft 365 UI certification. Matrices and multiline derivations remain block-level, reverse OMML-to-LaTeX build-down is not implemented, and cross-client rendering/editability is not promised. What's in and what's out is never hand-waved: the exact, feature-by-feature boundary — native / approximate / bake-required / unsupported — is published in the [PowerPoint ↔ SVG Mapping Guide](./powerpoint-svg-mapping.md).+So the boundary is honest, and it moves. Some things are out of scope today — **SmartArt** (a closed, brittle object model, deliberately left out and better rebuilt from ordinary native shapes), a few decorative effects (WordArt, reflection, soft edges), and embedded or legacy objects (OLE, video, macros). Native equations cover standalone blocks and same-paragraph inline math, with an executable input profile pinned to the documented Microsoft 365 versions and a PowerPoint 2010+ package target; repository verification is compiler/OMML/package-level rather than complete Microsoft 365 UI certification. Matrices and multiline derivations remain block-level. PPTX import can rebuild only PPT Master-owned, validator-clean OMML into normalized formula markers; it does not recover arbitrary third-party Office Math or the author's original LaTeX spelling. Cross-client rendering/editability is not promised. What's in and what's out is never hand-waved: the exact, feature-by-feature boundary — native / approximate / bake-required / unsupported — is published in the [PowerPoint ↔ SVG Mapping Guide](./powerpoint-svg-mapping.md).And out of scope rarely means *can't* — more often it means *not yet* (the timing isn't right) or *not worth it* (for a niche effect, a quick manual tweak in PowerPoint beats the engineering cost). That call is easy to make precisely because PPT Master's output is a high-quality **draft you keep editing, not a sealed final deck** — the last mile is yours by design.diff --git a/docs/zh/faq.md b/docs/zh/faq.mdindex b8078c15..62a142ac 100644--- a/docs/zh/faq.md+++ b/docs/zh/faq.md@@ -160,8 +160,11 @@ marker 都携带普通可见预览;原生导出会替换该预览,不增加前向编译覆盖 Microsoft 文档中 Microsoft 365 2606 / Mac 16.110 LaTeX档位与 2605 / 16.109 mhchem 档位明确点名的全部输入,包括符号、结构、环境、宏、化学式、公式局部颜色及文档规定的原生归一化。未知或明确不支持的输入直接-失败,不会以原始 LaTeX 混进页面。PPT Master 不实现 OMML 到 LaTeX 的反向-build-down。+失败,不会以原始 LaTeX 混进页面。PPTX 导入则复用同一封闭 OMML 校验器提供+窄反向路径:PPT Master 自有的块级与行内数学内容会恢复为带可见 SVG 预览的+规范公式 marker。这里恢复的是归一化语义,不是作者原始 LaTeX 写法,也不是任意+第三方 OMML 转换;未知 OMML 在 tolerant 模式下会被报告,并以可读 / 不透明+fallback 保留。生成的 OMML 仍以 PowerPoint 2010+ 包为目标,可执行输入档位锁定到上述Microsoft 文档版本。仓库验证覆盖编译器行为、OMML 结构与 PPTX 打包,不等同于diff --git a/docs/zh/powerpoint-svg-mapping.md b/docs/zh/powerpoint-svg-mapping.mdindex 3610971e..8943fa06 100644--- a/docs/zh/powerpoint-svg-mapping.md+++ b/docs/zh/powerpoint-svg-mapping.md@@ -208,6 +208,7 @@ PowerPoint 原生 Chart/Table 对象是可选功能。默认导出保留 SVG fal| LaTeX 输入档位 | 规范 marker 源不写外层定界符;也接受一对完整的 `$...$`、`$$...$$`、`\(...\)` 或 `\[...\]` | 锁定的 Microsoft 365 2606 / Mac 16.110 档位中所有明确点名的输入,以及 2605 / 16.109 mhchem 档位,均编译为可编辑 OMML | 档位锁定到这些 Microsoft 文档版本;产出的 OMML 仍保持 PowerPoint 2010+ 包目标。仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 认证 | 保留文档明确规定的原生归一化;未知或明确不支持的输入直接失败,不把 LaTeX 字面量漏进页面 || 可编辑块级公式 | 一个带显式边界、在 `<metadata type="application/json">` 中保存源 LaTeX、并含可见 SVG 预览子元素的 `<g data-pptx-replace-with="formula">` | 含 `a14:m > m:oMathPara > m:oMath` 的 PowerPoint 文本 shape | 见输入档位行 | 矩阵、多行推导等独立高结构公式使用块级合同 || 可编辑行内公式 | 普通文本 run 中的叶子 `<tspan data-pptx-inline-formula="规范 LaTeX body">preview text</tspan>` | 同一 DrawingML `a:p` 保留前后 run,并插入 `a14:m > m:oMath` | 见输入档位行 | 只允许非空直接预览文本;禁止子元素、`x/y/dx/dy`、结构化 placeholder / Master / Layout 归属、保留的导入 `txBody` 或原生替换祖先 |+| PPTX 公式反向导入 | 通过校验的 `m:oMathPara` 变为块级 marker;通过校验的 `m:oMath` 与前后 run 一起保留为行内 marker | 再导出时把规范化 LaTeX 编译回可编辑 OMML | 对 PPT Master 自有封闭 OMML 词汇为 `Native-normalized` | 无法恢复原 LaTeX 写法;未知第三方 OMML 在 tolerant 模式下产生 `formula-not-reconstructed`、可读文本,并在无 relationship 时以不透明 `txBody` 保留 || 浏览器 / 实时预览 | 块级 marker 内的普通 SVG 子元素,或行内 marker 的直接文本 | 写入原生公式时只丢弃已登记预览 | 原始 LaTeX 不能直接在 SVG 中渲染 | 预览必须表达同一公式;它不是 PPTX 兜底 || 公式字体 | 块级 payload 样式,或行内文本 run 的计算样式 | 公式继承字号与可见纯色填充,并使用项目文本语言和 Cambria Math;局部 `\color` / `\textcolor` 作用域会覆盖可选中文字 run 与结构控制符的继承填充,`\boldsymbol` / `\bm` 也会设置结构控制字形的样式 | PowerPoint 2010+ OMML | 高结构或多行数学内容仍使用块级形式 || 非 PowerPoint 客户端播放 | 同一类原生 marker;没有图片分支 | 不附加兼容兜底 | Keynote、WPS、LibreOffice 等客户端不在公式合同内 | 不宣称跨客户端显示或编辑能力 |@@ -216,7 +217,8 @@ PowerPoint 原生 Chart/Table 对象是可选功能。默认导出保留 SVG fal`formula_manifest.json`、公式 PNG、media relationship 或作为图片的`mc:Fallback`。块级 JSON 和行内 `data-pptx-inline-formula` 的值是原生公式源;SVG 预览内容只负责让导出前的作者页面保持可见。-编译仅支持前向生成;PPT Master 不把 OMML 反向 build-down 为 LaTeX。+`pptx_to_svg.py` 只对通过同一封闭校验器的 OMML 执行窄反向导入,产出的是+规范化 LaTeX,而不是作者原始写法;它不宣称任意 Office Math 转换。可执行闭合集与锁定的 Microsoft 来源修订记录在 `formula_profile.py`;Microsoft文档中开放式的 “etc.” 不会把未披露的 relation alias 自动纳入本合同。diff --git a/docs/zh/roadmap.md b/docs/zh/roadmap.mdindex d12b48bc..da73f3f3 100644--- a/docs/zh/roadmap.md+++ b/docs/zh/roadmap.md@@ -45,7 +45,7 @@| 图表 | 系统化 | 有专属创作 reference;默认 SVG,原生 Chart 替换为显式 opt-in || 表格 | 系统化 | 有专属创作 reference;六种可复用的单元格网格参考,仍可自定义网格;原生 Table 替换走同一 opt-in || 关系图 | 系统化 | 六个关系原子——`order`、`link`、`parent`、`membership`、`contrast`、`overlap` |-| 公式 | 系统化 | 独立块级公式与同段行内公式可把 Microsoft 365 LaTeX / mhchem 文档中所有明确点名的输入编译为可编辑 OMML,并遵循文档规定的原生归一化,档位外输入直接失败。SVG 预览仅供创作阶段使用,不生成图片兜底。包目标仍为 PowerPoint 2010+;可执行档位锁定到所述 Microsoft 文档版本,仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 认证。非 PowerPoint 客户端仍不在合同内 |+| 公式 | 系统化 | 独立块级公式与同段行内公式可把 Microsoft 365 LaTeX / mhchem 文档中所有明确点名的输入编译为可编辑 OMML,并遵循文档规定的原生归一化,档位外输入直接失败。PPTX 导入可把通过校验的 PPT Master 自有 OMML 恢复为带可见 SVG 预览的规范公式 marker;任意第三方 OMML 与原始 LaTeX 写法恢复仍不在合同内。不生成图片兜底。包目标仍为 PowerPoint 2010+;可执行档位锁定到所述 Microsoft 文档版本,仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 认证。非 PowerPoint 客户端仍不在合同内 || 旁白与动画音效 | 系统化 | 逐页旁白音频,以及取自内置 CC0 音效库的原生转场与对象音效 || 任意视频与背景音乐 | 暂不考虑 | 属于一次性、内容特定的插入动作,在 PowerPoint 里手动放进去更快,AI 也无法替你挑文件。背景音乐还会牵出旁白混音决策,那在范围之外。来源 deck 中已有的媒体在 Fill 与 Enhance 路线中原样保留 || SmartArt | 有意的不对称 | 读取来源 diagram part 的内容与结构;生成 deck 用普通形状管线把这些内容重画出来。从不编辑 DiagramML,也不承诺原生 SmartArt 再生 |diff --git a/docs/zh/technical-design.md b/docs/zh/technical-design.mdindex 6d0c0488..6560421f 100644--- a/docs/zh/technical-design.md+++ b/docs/zh/technical-design.md@@ -435,8 +435,10 @@ Cambria Math;编译器自己的局部颜色以及 `\boldsymbol` / `\bm` 的控结构控制符,而普通文字粗斜体或数学字母样式只覆盖对应的继承 run 属性。封闭的 Microsoft 365 档位表进入同一个 parser 与共享 AST,再由同一个 emitter生成并按结构校验块级和行内路径共同使用的窄 OMML 词汇。前向编译器覆盖锁定版本的Microsoft 365 LaTeX 与 mhchem 文档中所有明确点名的输入及原生归一化;未知、明确不支持、-非法或超出资源上限的输入都会直接失败,PPT Master 不把 OMML 反向 build-down 为-LaTeX。矩阵、多行推导等高结构表达仍使用块级形式。两种形式都保留普通 SVG 预览,+非法或超出资源上限的输入都会直接失败。PPTX 导入器只对通过同一校验器的项目自有+OMML 词汇执行更窄的反向过程,生成带可见 SVG 预览的规范块级 / 行内公式 marker,+而不恢复作者原始 LaTeX 写法。未知第三方 OMML 保持有诊断的可读 / 不透明 fallback,+不冒充原生重建。矩阵、多行推导等高结构表达仍使用块级形式。两种形式都保留普通 SVG 预览,因为原始 LaTeX 本身不能在 SVG 中显示。生成包仍以 PowerPoint 2010+ 为目标,可执行档位锁定到所述 Microsoft 365 文档版本;仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 显示 / 编辑认证。不生成公式 PNG、media relationship,也不为diff --git a/docs/zh/why-ppt-master.md b/docs/zh/why-ppt-master.mdindex fac2c693..b7e99841 100644--- a/docs/zh/why-ppt-master.md+++ b/docs/zh/why-ppt-master.md@@ -30,7 +30,7 @@而这份深度是**一个前进方向,不是一张固定清单。** 项目的北极星是持续向 PowerPoint 本身靠拢——不断开发、集成更多它的原生能力,一个版本接一个版本,缩小「AI 能替你生成的」和「你在 PowerPoint 里手工能做出的」之间的差距。-所以边界是诚实的,而且它在移动。有些能力今天还不在范围内——**SmartArt**(一个封闭、脆弱的对象模型,被刻意排除,其含义更适合用普通原生形状重建)、少数装饰性效果(艺术字、反射、柔化边缘)、以及嵌入 / 遗留对象(OLE、视频、宏)。原生公式已覆盖独立块级公式和同段行内公式,可执行输入档位锁定到所述 Microsoft 365 文档版本,生成包仍面向 PowerPoint 2010+;仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 认证。矩阵与多行推导继续使用块级形式,不实现 OMML 到 LaTeX 的反向 build-down,也不承诺跨客户端公式显示与编辑。哪些在内、哪些在外从不含糊:逐条的功能对照边界——原生 / 近似 / 需烘焙 / 不支持——都公开在 [PowerPoint ↔ SVG 映射指南](./powerpoint-svg-mapping.md) 里。+所以边界是诚实的,而且它在移动。有些能力今天还不在范围内——**SmartArt**(一个封闭、脆弱的对象模型,被刻意排除,其含义更适合用普通原生形状重建)、少数装饰性效果(艺术字、反射、柔化边缘)、以及嵌入 / 遗留对象(OLE、视频、宏)。原生公式已覆盖独立块级公式和同段行内公式,可执行输入档位锁定到所述 Microsoft 365 文档版本,生成包仍面向 PowerPoint 2010+;仓库验证覆盖编译器、OMML 与包结构,不等同于完整的 Microsoft 365 UI 认证。矩阵与多行推导继续使用块级形式。PPTX 导入只会把 PPT Master 自有且通过校验的 OMML 恢复为规范公式 marker;不恢复任意第三方 Office Math,也不恢复作者原始 LaTeX 写法。跨客户端公式显示与编辑仍不在承诺内。哪些在内、哪些在外从不含糊:逐条的功能对照边界——原生 / 近似 / 需烘焙 / 不支持——都公开在 [PowerPoint ↔ SVG 映射指南](./powerpoint-svg-mapping.md) 里。而且「不在范围内」很少等于「做不到」——更多时候是「时机未到」,或者「性价比不划算」(一个小众效果,去 PowerPoint 里手动改一下,比为它做工程更值)。这个取舍之所以好做,正因为 PPT Master 的产出是一份高质量的**草稿、供你继续修改,而不是封死的成品**——最后一公里本就交给你。diff --git a/skills/ppt-master/references/native-formula.md b/skills/ppt-master/references/native-formula.mdindex 46e37689..55bc33bf 100644--- a/skills/ppt-master/references/native-formula.md+++ b/skills/ppt-master/references/native-formula.md@@ -115,7 +115,22 @@ explicit big-delimiter grades become auto-sizing delimiters; `\mathscr`normalizes to `\mathcal`; `smallmatrix` normalizes to `matrix`; PowerPoint arraycolumns become centered; style/size commands and equation tags are accepted butnot stored. Color is stored in generated formula runs and structural control-properties. No reverse OMML-to-LaTeX build-down is implemented by PPT Master.+properties.++**Narrow reverse import**: `pptx_to_svg.py` rebuilds a block formula marker or+same-paragraph inline marker only when one `a14:m` root passes this compiler's+closed OMML validator and its normalized structure can be serialized back to+LaTeX accepted by the same compiler. The reconstructed LaTeX is canonicalized;+it is not the original spelling. A formula-only `m:oMathPara` text shape becomes+one bounded block marker when its carrier also fits the unstyled rectangular+native-formula contract; carrier grouping, paint, effects, rotation, hyperlink,+or placeholder ownership force fallback instead of being silently discarded.+Supported `m:oMath` zones remain inline among their surrounding text runs. Both+forms receive a dependency-free linear SVG preview. This contract covers PPT+Master-emitted vocabulary, not arbitrary third-party OMML. Tolerant import+reports `formula-not-reconstructed`, renders readable formula text, and retains+a relationship-free unchanged source `txBody` as opaque metadata; strict import+stops instead.**Fail-closed boundary**: Input containing unknown commands or environments,Microsoft's explicitly unsupported commands, unsupported mhchem arrows,diff --git a/skills/ppt-master/scripts/README.md b/skills/ppt-master/scripts/README.mdindex 0fb3c54e..279c268a 100644--- a/skills/ppt-master/scripts/README.md+++ b/skills/ppt-master/scripts/README.md@@ -315,8 +315,12 @@ python3 scripts/analyze_images.py <project_path>/imagesGenerated-deck formulas do not use an image command. Author a native formulamarker in the page SVG; `svg_to_pptx.py` compiles its LaTeX metadata to editablePowerPoint OMML. Forward compilation covers the explicitly documented Microsoft-365 LaTeX and mhchem input profiles and fails closed outside them; it does not-implement OMML-to-LaTeX build-down. The retained `latex_render.py` utility is+365 LaTeX and mhchem input profiles and fails closed outside them.+`pptx_to_svg.py` also reconstructs PPT Master-owned, validator-clean OMML into+canonical block/inline formula markers with visible linear SVG previews. This+is a closed-vocabulary reverse import, not arbitrary third-party+OMML-to-LaTeX conversion; unknown OMML is reported and kept opaque in tolerant+mode. The retained `latex_render.py` utility isstandalone legacy rasterization only and is not connected to either Generateprofile.diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex eaf1ad30..5585289c 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -288,6 +288,37 @@ the native replacement claim or strict mode. Default tolerant deck importretains the usable fallback/object and records the degradation; it does notdiscard unrelated shapes, pages, or the entire deck.+Source `p:transition` and `p:timing` nodes are never silently implied by the+static SVG view. Until their corresponding sidecar read-back stages are+enabled, the importer emits `transition-not-reconstructed` and+`animation-not-reconstructed` diagnostics with the exact source slide. Direct+PPTX Fill/Enhance workflows remain the source-preserving route; `--strict`+stops on the first such unreconstructed node.++### Native formula reverse import++The importer reconstructs formulas only from the closed OMML vocabulary owned+by the native formula compiler. One formula-only `a14:m > m:oMathPara` text+shape becomes a bounded `<g data-pptx-replace-with="formula">` with canonical+LaTeX JSON and a visible linear SVG preview when its carrier is an ungrouped,+unstyled, unrotated rectangular formula shape. Carrier styling, effects,+hyperlinks, or placeholder ownership force diagnosed fallback rather than+silent loss.+Supported `a14:m > m:oMath` zones inside an ordinary paragraph become leaf+`<tspan data-pptx-inline-formula="...">preview</tspan>` markers while retaining+their surrounding text runs. The generated markers pass the same native-object+and inline-formula validators used by SVG-to-PPTX export.++This is normalized semantic read-back, not recovery of the author's original+LaTeX spelling and not a general Office Math converter. Every OMML root must+pass the compiler's namespace, element, attribute, structure, size, and depth+gates, and the reconstructed LaTeX must compile again under the same profile.+If any formula in one text body falls outside that boundary, tolerant import+keeps all formulas in that body as readable linear text and retains the+relationship-free source `txBody` as opaque metadata instead of partially+claiming native reconstruction. It records `formula-not-reconstructed`;+`--strict` stops on the same condition.+### Native table and chart import claimsSupported text-grid tables and conservative classic-chart caches carry adiff --git a/skills/ppt-master/scripts/pptx_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg.pyindex 60340ee4..0a4859c8 100644--- a/skills/ppt-master/scripts/pptx_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg.py@@ -18,8 +18,9 @@ Output structure (default --inheritance-mode both):If -o is omitted, writes alongside the source file as <pptx_stem>_pptx_to_svg/.-This is the reverse of svg_to_pptx.py: it reads OOXML directly and emits-shape-level SVG without going through PowerPoint or PDF rendering.+This is the semantic import counterpart to svg_to_pptx.py: it reads OOXML+directly and emits declared SVG/native-marker subsets without claiming an+arbitrary lossless PPTX round trip."""from __future__ import annotationsdiff --git a/skills/ppt-master/scripts/pptx_to_svg/__init__.py b/skills/ppt-master/scripts/pptx_to_svg/__init__.pyindex 31ed220b..e23cd082 100644--- a/skills/ppt-master/scripts/pptx_to_svg/__init__.py+++ b/skills/ppt-master/scripts/pptx_to_svg/__init__.py@@ -1,7 +1,8 @@-"""PPTX -> SVG semantic converter (reverse of svg_to_pptx).+"""PPTX -> SVG semantic importer for declared reversible subsets.Reads OOXML (DrawingML) directly from a .pptx zip archive and emits SVG with-shape-level fidelity: <p:sp prst="rect"> -> <rect>, <p:txBody> -> <text>, etc.+shape-level fidelity plus explicit native-marker reconstruction where the+source fits a closed project-owned contract.Public entry: convert_pptx_to_svg()."""diff --git a/skills/ppt-master/scripts/pptx_to_svg/converter.py b/skills/ppt-master/scripts/pptx_to_svg/converter.pyindex 370b0dd4..13c5aac2 100644--- a/skills/ppt-master/scripts/pptx_to_svg/converter.py+++ b/skills/ppt-master/scripts/pptx_to_svg/converter.py@@ -325,6 +325,11 @@ def convert_pptx_to_svg(# rendered alongside when needed.primary_mode = "layered" if emit_layered else "flat"for slide in pkg.iter_slides():+ _diagnose_unreconstructed_slide_features(+ slide,+ result.diagnostics,+ strict=options.strict,+ )slide_theme = pkg.resolve_theme(slide.master) or default_themeslide_palette = _make_palette(slide.master,@@ -378,6 +383,40 @@ def convert_pptx_to_svg(return result+def _diagnose_unreconstructed_slide_features(+ slide: SlideRef,+ diagnostics: list[ImportDiagnostic],+ *,+ strict: bool,+) -> None:+ """Report source-owned motion that the SVG workspace cannot yet express."""+ for tag, code, label in (+ ("p:transition", "transition-not-reconstructed", "slide transition"),+ ("p:timing", "animation-not-reconstructed", "object animation timing"),+ ):+ if slide.part.xml.find(tag, NS) is None:+ continue+ message = (+ f"Source slide contains {label} that was not reconstructed "+ "in the SVG workspace"+ )+ if strict:+ raise ValueError(message)+ append_diagnostic(+ diagnostics,+ ImportDiagnostic(+ code=code,+ message=message,+ fallback=(+ "keep the source PPTX for direct native preservation or "+ "author the corresponding animations.json sidecar"+ ),+ part_path=slide.part.path,+ slide_index=slide.index,+ ),+ )++def _convert_slide(pkg: OoxmlPackage,slide: SlideRef,diff --git a/skills/ppt-master/scripts/pptx_to_svg/formula_import.py b/skills/ppt-master/scripts/pptx_to_svg/formula_import.pynew file mode 100644index 00000000..1e3ce79c--- /dev/null+++ b/skills/ppt-master/scripts/pptx_to_svg/formula_import.py@@ -0,0 +1,611 @@+"""Import PPT Master-owned Office Math into canonical SVG formula markers.++The reverse contract is deliberately narrow: accept only the closed OMML+vocabulary already validated by the native formula compiler, serialize that+structure to compiler-accepted LaTeX, and build a plain-text SVG preview.+Unknown third-party OMML remains outside this module's reconstruction claim.+"""++from __future__ import annotations++from collections import Counter+from dataclasses import dataclass+from xml.etree import ElementTree as ET++from svg_to_pptx.native_objects.formula_compiler import (+ FormulaCompileError,+ compile_latex_to_inline_omml,+ compile_latex_to_omml,+ validate_omml_fragment,+)+from svg_to_pptx.native_objects.formula_profile import (+ ACCENT_COMMANDS,+ NARY_COMMANDS,+)+++MATH_NS = "http://schemas.openxmlformats.org/officeDocument/2006/math"+DRAWING_NS = "http://schemas.openxmlformats.org/drawingml/2006/main"+A14_NS = "http://schemas.microsoft.com/office/drawing/2010/main"++_M = f"{{{MATH_NS}}}"+_A = f"{{{DRAWING_NS}}}"+_A14_M = f"{{{A14_NS}}}m"+_PROPERTY_SUFFIX = "Pr"++_NARY_COMMAND_BY_SYMBOL = {+ symbol: command+ for command, (symbol, _category) in NARY_COMMANDS.items()+}+_ACCENT_COMMAND_BY_CHARACTER = {+ character: command+ for command, character in ACCENT_COMMANDS.items()+}+_GROUP_COMMANDS = {+ ("⏞", "top", "bot"): "overbrace",+ ("⏟", "bot", "top"): "underbrace",+ ("→", "bot", "top"): "underrightarrow",+ ("←", "bot", "top"): "underleftarrow",+ ("↔", "bot", "top"): "underleftrightarrow",+ ("→", "top", "bot"): "overrightarrow",+ ("←", "top", "bot"): "overleftarrow",+ ("↔", "top", "bot"): "overleftrightarrow",+}+_DELIMITER_COMMANDS = {+ "{": r"\{",+ "}": r"\}",+ "⟨": r"\langle",+ "⟩": r"\rangle",+ "⌊": r"\lfloor",+ "⌋": r"\rfloor",+ "⌈": r"\lceil",+ "⌉": r"\rceil",+ "‖": r"\Vert",+ "⟦": "⟦",+ "⟧": "⟧",+}+_SPACING_LATEX = {+ "\u200b": r"\!",+ "\u2009": r"\,",+ "\u205f": r"\:",+ "\u2004": r"\;",+ "\u2002": r"\enspace{}",+ "\u2003": r"\quad{}",+ "\u00a0": "~",+}+++class FormulaImportError(ValueError):+ """Raised when source OMML is outside the reversible project contract."""+++@dataclass(frozen=True)+class FormulaImport:+ """Canonical formula source plus a visible SVG-preview representation."""++ latex: str+ preview: str+ font_size_px: float+ color: str+ align: str+ language: str+++def import_formula(math_zone: ET.Element, *, display: bool) -> FormulaImport:+ """Validate and reconstruct one ``a14:m`` formula zone."""+ if math_zone.tag != _A14_M:+ raise FormulaImportError("formula carrier must be one a14:m element")+ children = [child for child in math_zone if isinstance(child.tag, str)]+ if len(children) != 1:+ raise FormulaImportError("a14:m must contain exactly one Office Math root")+ root = children[0]+ expected = f"{_M}{'oMathPara' if display else 'oMath'}"+ if root.tag != expected:+ kind = "block" if display else "inline"+ raise FormulaImportError(+ f"{kind} formula requires m:{expected.rsplit('}', 1)[-1]}"+ )++ try:+ canonical = validate_omml_fragment(+ ET.tostring(root, encoding="unicode", short_empty_elements=True)+ )+ validated_root = ET.fromstring(canonical)+ latex = _serialize_root(validated_root)+ if display:+ compile_latex_to_omml(latex)+ else:+ compile_latex_to_inline_omml(latex)+ except (FormulaCompileError, ET.ParseError, RecursionError) as exc:+ raise FormulaImportError(str(exc)) from exc++ preview = _preview_root(validated_root).strip()+ if not latex.strip() or not preview:+ raise FormulaImportError("formula reconstruction produced empty content")+ font_size_px, color, language = _dominant_run_style(validated_root)+ return FormulaImport(+ latex=latex,+ preview=preview,+ font_size_px=font_size_px,+ color=color,+ align=_formula_alignment(validated_root),+ language=language,+ )+++def opaque_formula_preview(math_zone: ET.Element) -> str:+ """Return readable source text without claiming native reconstruction."""+ text = "".join(+ item.text or ""+ for item in math_zone.iter(f"{_M}t")+ ).strip()+ return text or "[unsupported formula]"+++def _serialize_root(root: ET.Element) -> str:+ if root.tag == f"{_M}oMathPara":+ math = root.find(f"{_M}oMath")+ if math is None:+ raise FormulaImportError("m:oMathPara is missing m:oMath")+ return _serialize_children(math)+ if root.tag == f"{_M}oMath":+ return _serialize_children(root)+ raise FormulaImportError("unsupported Office Math root")+++def _serialize_children(parent: ET.Element, *, alignment: bool = False) -> str:+ return "".join(+ _serialize_node(child, alignment=alignment)+ for child in parent+ if _local_name(child) not in {_PROPERTY_SUFFIX, "ctrlPr"}+ and not _local_name(child).endswith(_PROPERTY_SUFFIX)+ )+++def _serialize_argument(owner: ET.Element, name: str, *, alignment: bool = False) -> str:+ element = owner.find(f"{_M}{name}")+ if element is None:+ raise FormulaImportError(+ f"m:{_local_name(owner)} is missing required m:{name}"+ )+ return _serialize_children(element, alignment=alignment)+++def _serialize_node(element: ET.Element, *, alignment: bool = False) -> str:+ name = _local_name(element)+ if name == "r":+ return _serialize_run(element, alignment=alignment)+ if name == "f":+ kind = _property_value(element, "fPr", "type", "bar")+ command = {"bar": "frac", "skw": "ifrac"}.get(kind)+ numerator = _serialize_argument(element, "num")+ denominator = _serialize_argument(element, "den")+ if command is not None:+ return f"\\{command}{{{numerator}}}{{{denominator}}}"+ if kind == "noBar":+ return (+ r"\genfrac{}{}{0pt}{}"+ f"{{{numerator}}}{{{denominator}}}"+ )+ raise FormulaImportError(f"unsupported reversible fraction type: {kind!r}")+ if name == "rad":+ body = _serialize_argument(element, "e")+ degree = _serialize_argument(element, "deg")+ return f"\\sqrt[{degree}]{{{body}}}" if degree else f"\\sqrt{{{body}}}"+ if name in {"sSub", "sSup", "sSubSup"}:+ base = _serialize_argument(element, "e")+ subscript = _serialize_optional_argument(element, "sub")+ superscript = _serialize_optional_argument(element, "sup")+ return _scripted(f"{{{base}}}", subscript, superscript)+ if name == "sPre":+ base = _serialize_argument(element, "e")+ subscript = _serialize_optional_argument(element, "sub")+ superscript = _serialize_optional_argument(element, "sup")+ return _scripted("", subscript, superscript) + f"{{{base}}}"+ if name == "nary":+ symbol = _property_value(element, "naryPr", "chr", "")+ command = _NARY_COMMAND_BY_SYMBOL.get(symbol)+ if command is None:+ raise FormulaImportError(f"unsupported reversible n-ary symbol: {symbol!r}")+ source = f"\\{command}"+ # Serialize the source location explicitly when it uses under/over+ # limits. ``subSup`` is the neutral default in both formula contexts.+ default_location = "subSup"+ location = _property_value(element, "naryPr", "limLoc", default_location)+ if location != default_location:+ source += r"\limits" if location == "undOvr" else r"\nolimits"+ source = _scripted(+ source,+ _serialize_optional_argument(element, "sub"),+ _serialize_optional_argument(element, "sup"),+ )+ body = _serialize_optional_argument(element, "e")+ return source + (f"{{{body}}}" if body else "")+ if name == "d":+ left = _property_value(element, "dPr", "begChr", "(")+ right = _property_value(element, "dPr", "endChr", ")")+ separator = _property_value(element, "dPr", "sepChr", "")+ segments = [+ _serialize_children(child)+ for child in element.findall(f"{_M}e")+ ]+ middle = f"\\middle{_delimiter(separator, side='middle')}" if separator else ""+ return (+ f"\\left{_delimiter(left, side='left')}"+ + middle.join(segments)+ + f"\\right{_delimiter(right, side='right')}"+ )+ if name == "m":+ rows = []+ for row in element.findall(f"{_M}mr"):+ rows.append("&".join(+ _serialize_children(cell)+ for cell in row.findall(f"{_M}e")+ ))+ return r"\begin{matrix}" + r"\\".join(rows) + r"\end{matrix}"+ if name == "eqArr":+ rows = [+ _serialize_children(row, alignment=True)+ for row in element.findall(f"{_M}e")+ ]+ return r"\begin{aligned}" + r"\\".join(rows) + r"\end{aligned}"+ if name == "acc":+ character = _property_value(element, "accPr", "chr", "")+ command = _ACCENT_COMMAND_BY_CHARACTER.get(character)+ if character == "̸":+ command = "not"+ if command is None:+ raise FormulaImportError(f"unsupported reversible accent: {character!r}")+ return f"\\{command}{{{_serialize_argument(element, 'e')}}}"+ if name == "bar":+ position = _property_value(element, "barPr", "pos", "top")+ command = "overline" if position == "top" else "underline"+ return f"\\{command}{{{_serialize_argument(element, 'e')}}}"+ if name == "groupChr":+ key = (+ _property_value(element, "groupChrPr", "chr", ""),+ _property_value(element, "groupChrPr", "pos", "top"),+ _property_value(element, "groupChrPr", "vertJc", "bot"),+ )+ command = _GROUP_COMMANDS.get(key)+ if command is None:+ raise FormulaImportError(f"unsupported reversible group character: {key!r}")+ return f"\\{command}{{{_serialize_argument(element, 'e')}}}"+ if name == "limLow":+ base = _serialize_argument(element, "e")+ lower = _serialize_argument(element, "lim")+ return f"\\underset{{{lower}}}{{{base}}}"+ if name == "limUpp":+ base = _serialize_argument(element, "e")+ upper = _serialize_argument(element, "lim")+ return f"\\overset{{{upper}}}{{{base}}}"+ if name == "func":+ function_name = _serialize_argument(element, "fName")+ body = _serialize_optional_argument(element, "e")+ source = f"\\mathop{{{function_name}}}"+ return source + (f"{{{body}}}" if body else "")+ if name == "box":+ enabled = _property_value(element, "boxPr", "opEmu", "off")+ if enabled not in {"on", "true", "1"}:+ raise FormulaImportError("only operator-emulator m:box is reversible")+ return f"\\mathrel{{{_serialize_argument(element, 'e')}}}"+ if name == "phant":+ properties = element.find(f"{_M}phantPr")+ zero_width = _on_property(properties, "zeroWid")+ zero_ascent = _on_property(properties, "zeroAsc")+ zero_descent = _on_property(properties, "zeroDesc")+ if zero_width:+ command = "vphantom"+ elif zero_ascent and zero_descent:+ command = "hphantom"+ else:+ command = "phantom"+ return f"\\{command}{{{_serialize_argument(element, 'e')}}}"+ if name == "borderBox":+ properties = element.find(f"{_M}borderBoxPr")+ rising = _on_property(properties, "strikeBLTR")+ falling = _on_property(properties, "strikeTLBR")+ hidden = all(+ _on_property(properties, side)+ for side in ("hideTop", "hideBot", "hideLeft", "hideRight")+ )+ if hidden and rising and falling:+ command = "xcancel"+ elif hidden and rising:+ command = "cancel"+ elif hidden and falling:+ command = "bcancel"+ elif not hidden and not rising and not falling:+ command = "boxed"+ else:+ raise FormulaImportError("unsupported reversible border-box properties")+ return f"\\{command}{{{_serialize_argument(element, 'e')}}}"+ if name in {"e", "deg", "den", "fName", "lim", "num", "sub", "sup"}:+ return _serialize_children(element, alignment=alignment)+ raise FormulaImportError(f"unsupported reversible Office Math element: m:{name}")+++def _serialize_optional_argument(owner: ET.Element, name: str) -> str:+ element = owner.find(f"{_M}{name}")+ return _serialize_children(element) if element is not None else ""+++def _scripted(base: str, subscript: str, superscript: str) -> str:+ if subscript:+ base += f"_{{{subscript}}}"+ if superscript:+ base += f"^{{{superscript}}}"+ return base+++def _serialize_run(run: ET.Element, *, alignment: bool) -> str:+ text_element = run.find(f"{_M}t")+ value = text_element.text or "" if text_element is not None else ""+ properties = run.find(f"{_M}rPr")+ literal = _on_property(properties, "lit")+ normal = _on_property(properties, "nor")+ source = _escape_text(value, alignment=alignment and not literal, text_mode=normal)+ if not source:+ return ""+ drawing = run.find(f"{_A}rPr")+ if normal:+ typeface = ""+ if drawing is not None:+ latin = drawing.find(f"{_A}latin")+ typeface = latin.get("typeface", "") if latin is not None else ""+ text_command = {+ "Arial": "textsf",+ "Courier New": "texttt",+ }.get(typeface, "text")+ source = f"\\{text_command}{{{source}}}"+ if drawing is not None and _drawing_on(drawing, "b"):+ source = f"\\textbf{{{source}}}"+ if drawing is not None and _drawing_on(drawing, "i"):+ source = f"\\textit{{{source}}}"+ else:+ script = _property_child_value(properties, "scr")+ style = _property_child_value(properties, "sty")+ command = {+ "sans-serif": "mathsf",+ "monospace": "mathtt",+ "double-struck": "mathbb",+ "script": "mathcal",+ "fraktur": "mathfrak",+ }.get(script or "")+ if command is None:+ command = {+ "p": "mathrm",+ "b": "mathbf",+ "i": "mathit",+ "bi": "boldsymbol",+ }.get(style or "")+ if command is not None:+ source = f"\\{command}{{{source}}}"+ color = _drawing_color(drawing)+ if color is not None:+ source = f"\\textcolor{{#{color}}}{{{source}}}"+ return source+++def _escape_text(value: str, *, alignment: bool, text_mode: bool) -> str:+ parts: list[str] = []+ for character in value:+ if character in _SPACING_LATEX and not text_mode:+ parts.append(_SPACING_LATEX[character])+ elif character == " " and not text_mode:+ parts.append(r"\ ")+ elif character == "&":+ parts.append("&" if alignment else r"\&")+ elif character in "{}_%#$":+ parts.append("\\" + character)+ elif character == "\\":+ parts.append(r"\backslash{}")+ elif character == "~" and not text_mode:+ parts.append(r"\text{~}")+ elif character == "^" and not text_mode:+ parts.append(r"\text{^}")+ else:+ parts.append(character)+ return "".join(parts)+++def _delimiter(value: str, *, side: str) -> str:+ if not value:+ return "."+ if value == "|":+ return "|"+ command = _DELIMITER_COMMANDS.get(value)+ if command is not None:+ if value == "‖" and side == "left":+ command = r"\lVert"+ if value == "‖" and side == "right":+ command = r"\rVert"+ if command.startswith("\\") and command[1:].isalpha():+ return command + " "+ return command+ if len(value) == 1:+ return value+ raise FormulaImportError(f"unsupported reversible delimiter: {value!r}")+++def _preview_root(root: ET.Element) -> str:+ math = root.find(f"{_M}oMath") if root.tag == f"{_M}oMathPara" else root+ if math is None:+ return ""+ return _preview_children(math)+++def _preview_children(parent: ET.Element) -> str:+ return "".join(+ _preview_node(child)+ for child in parent+ if not _local_name(child).endswith(_PROPERTY_SUFFIX)+ and _local_name(child) != "ctrlPr"+ )+++def _preview_argument(owner: ET.Element, name: str) -> str:+ child = owner.find(f"{_M}{name}")+ return _preview_children(child) if child is not None else ""+++def _preview_node(element: ET.Element) -> str:+ name = _local_name(element)+ if name == "r":+ text = element.find(f"{_M}t")+ return text.text or "" if text is not None else ""+ if name == "f":+ return f"({_preview_argument(element, 'num')})/({_preview_argument(element, 'den')})"+ if name == "rad":+ degree = _preview_argument(element, "deg")+ prefix = f"√[{degree}]" if degree else "√"+ return f"{prefix}({_preview_argument(element, 'e')})"+ if name in {"sSub", "sSup", "sSubSup"}:+ base = _preview_argument(element, "e")+ subscript = _preview_argument(element, "sub")+ superscript = _preview_argument(element, "sup")+ return _preview_script(base, subscript, superscript)+ if name == "sPre":+ prefix = _preview_script(+ "",+ _preview_argument(element, "sub"),+ _preview_argument(element, "sup"),+ )+ return prefix + _preview_argument(element, "e")+ if name == "nary":+ symbol = _property_value(element, "naryPr", "chr", "")+ return _preview_script(+ symbol,+ _preview_argument(element, "sub"),+ _preview_argument(element, "sup"),+ ) + _preview_argument(element, "e")+ if name == "d":+ left = _property_value(element, "dPr", "begChr", "(")+ right = _property_value(element, "dPr", "endChr", ")")+ separator = _property_value(element, "dPr", "sepChr", "")+ segments = [_preview_children(child) for child in element.findall(f"{_M}e")]+ return left + separator.join(segments) + right+ if name == "m":+ rows = [+ ", ".join(_preview_children(cell) for cell in row.findall(f"{_M}e"))+ for row in element.findall(f"{_M}mr")+ ]+ return "[" + "; ".join(rows) + "]"+ if name == "eqArr":+ return " ".join(+ _preview_children(row)+ for row in element.findall(f"{_M}e")+ )+ if name == "acc":+ return _preview_argument(element, "e") + _property_value(element, "accPr", "chr", "")+ if name == "bar":+ marker = "¯" if _property_value(element, "barPr", "pos", "top") == "top" else "_"+ return marker + f"({_preview_argument(element, 'e')})"+ if name == "groupChr":+ marker = _property_value(element, "groupChrPr", "chr", "")+ return marker + f"({_preview_argument(element, 'e')})"+ if name == "limLow":+ return _preview_script(+ _preview_argument(element, "e"),+ _preview_argument(element, "lim"),+ "",+ )+ if name == "limUpp":+ return _preview_script(+ _preview_argument(element, "e"),+ "",+ _preview_argument(element, "lim"),+ )+ if name == "func":+ return _preview_argument(element, "fName") + _preview_argument(element, "e")+ if name in {"box", "phant"}:+ return _preview_argument(element, "e")+ if name == "borderBox":+ return "□(" + _preview_argument(element, "e") + ")"+ if name in {"e", "deg", "den", "fName", "lim", "num", "sub", "sup"}:+ return _preview_children(element)+ return ""+++def _preview_script(base: str, subscript: str, superscript: str) -> str:+ if subscript:+ base += f"_({subscript})"+ if superscript:+ base += f"^({superscript})"+ return base+++def _dominant_run_style(root: ET.Element) -> tuple[float, str, str]:+ sizes: list[str] = []+ colors: list[str] = []+ languages: list[str] = []+ for properties in root.iter(f"{_A}rPr"):+ if properties.get("sz"):+ sizes.append(properties.get("sz") or "")+ if properties.get("lang"):+ languages.append(properties.get("lang") or "")+ color = properties.find(f"{_A}solidFill/{_A}srgbClr")+ if color is not None and color.get("val"):+ colors.append(color.get("val") or "")+ raw_size = _dominant(sizes, "2100")+ try:+ font_size = max(1.0, min(400.0, int(raw_size) / 75.0))+ except ValueError:+ font_size = 28.0+ return (+ font_size,+ f"#{_dominant(colors, '000000').upper()}",+ _dominant(languages, "en-US"),+ )+++def _formula_alignment(root: ET.Element) -> str:+ if root.tag != f"{_M}oMathPara":+ return "left"+ value = _property_value(root, "oMathParaPr", "jc", "center")+ return {"left": "left", "right": "right"}.get(value, "center")+++def _dominant(values: list[str], default: str) -> str:+ return Counter(values).most_common(1)[0][0] if values else default+++def _property_value(owner: ET.Element, properties: str, name: str, default: str) -> str:+ container = owner.find(f"{_M}{properties}")+ value = _property_child_value(container, name)+ return value if value is not None else default+++def _property_child_value(owner: ET.Element | None, name: str) -> str | None:+ if owner is None:+ return None+ child = owner.find(f"{_M}{name}")+ return child.get(f"{_M}val") if child is not None else None+++def _on_property(owner: ET.Element | None, name: str) -> bool:+ return _property_child_value(owner, name) in {"on", "true", "1"}+++def _drawing_on(owner: ET.Element, name: str) -> bool:+ return owner.get(name) in {"on", "true", "1"}+++def _drawing_color(owner: ET.Element | None) -> str | None:+ if owner is None:+ return None+ color = owner.find(f"{_A}solidFill/{_A}srgbClr")+ return color.get("val") if color is not None else None+++def _local_name(element: ET.Element) -> str:+ return element.tag.rsplit("}", 1)[-1]+++__all__ = [+ "A14_NS",+ "FormulaImport",+ "FormulaImportError",+ "import_formula",+ "opaque_formula_preview",+]diff --git a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.pyindex 7517f771..581ebc8f 100644--- a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py@@ -54,6 +54,13 @@ from .effect_to_svg import ()from .emu_units import NS, Xfrm, fmt_num, format_canvas_px_from_emufrom .fill_to_svg import FillResult, resolve_fill+from .formula_import import (+ A14_NS,+ FormulaImport,+ FormulaImportError,+ import_formula,+ opaque_formula_preview,+)from .import_diagnostics import (ImportDiagnostic,append_diagnostic,@@ -524,6 +531,33 @@ def _convert_shape(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->node.inherited_body_properties,)is_vertical = is_vertical_txbody(tx_body, node.xfrm)+ block_formula = _block_formula_zone(tx_body)+ block_formula_failed = False+ if block_formula is not None and not is_vertical:+ try:+ carrier_error = _block_formula_carrier_error(+ node,+ top_level=top_level,+ )+ if carrier_error is not None:+ raise FormulaImportError(carrier_error)+ imported_formula = import_formula(block_formula, display=True)+ except FormulaImportError as exc:+ _diagnose_formula_fallback(ctx, exc)+ block_formula_failed = True+ else:+ return _render_block_formula(+ node,+ ctx,+ imported_formula,+ top_level=top_level,+ )+ inline_formula_resolver = _prepare_inline_formula_resolver(+ tx_body,+ ctx,+ allow_native=not is_vertical,+ force_opaque=block_formula_failed,+ )local_has_run_effects = txbody_has_run_effects(source_tx_body)inherited_has_run_effects = txbody_has_run_effects(*node.inherited_lst_styles@@ -563,6 +597,7 @@ def _convert_shape(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->rid,action,),+ inline_formula_resolver=inline_formula_resolver,)else:text_result = convert_txbody(@@ -579,6 +614,7 @@ def _convert_shape(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->rid,action,),+ inline_formula_resolver=inline_formula_resolver,) if tx_body is not None else TextResult()except ValueError as exc:if ctx.strict:@@ -617,7 +653,11 @@ def _convert_shape(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->inner_parts.append(blip_image)if geom_xml:inner_parts.append(geom_xml)- if source_tx_body is not None and geom is not None:+ if (+ source_tx_body is not None+ and geom is not None+ and not text_result.contains_inline_formula+ ):inner_parts.append(_txbody_metadata(source_tx_body,@@ -681,6 +721,214 @@ def _effective_placeholder_tx_body(return effective+def _block_formula_zone(tx_body: ET.Element | None) -> ET.Element | None:+ """Return the sole block-math zone from a canonical formula text body."""+ if tx_body is None:+ return None+ paragraphs = tx_body.findall("a:p", NS)+ if len(paragraphs) != 1:+ return None+ paragraph = paragraphs[0]+ formula_zones = [+ child+ for child in paragraph+ if child.tag == f"{{{A14_NS}}}m"+ ]+ allowed = {+ f"{{{NS['a']}}}pPr",+ f"{{{NS['a']}}}endParaRPr",+ f"{{{A14_NS}}}m",+ }+ if len(formula_zones) != 1 or any(+ child.tag not in allowed+ for child in paragraph+ if isinstance(child.tag, str)+ ):+ return None+ root_children = [+ child for child in formula_zones[0] if isinstance(child.tag, str)+ ]+ if (+ len(root_children) != 1+ or root_children[0].tag+ != "{http://schemas.openxmlformats.org/officeDocument/2006/math}oMathPara"+ ):+ return None+ return formula_zones[0]+++def _block_formula_carrier_error(+ node: ShapeNode,+ *,+ top_level: bool,+) -> str | None:+ """Reject block carriers whose non-formula state would be discarded."""+ if not top_level:+ return "grouped block formula carrier is not reversible"+ if (+ node.xfrm.rot+ or node.xfrm.flip_h+ or node.xfrm.flip_v+ or node.effective_rotation+ ):+ return "block formula carrier rotation or flip is not reversible"+ if node.placeholder is not None:+ return "block formula carrier cannot retain placeholder ownership"+ if node.hyperlink_rid or node.hyperlink_action:+ return "block formula carrier hyperlink is not reversible"+ if node.xml.find("p:style", NS) is not None:+ return "block formula carrier style reference is not reversible"++ sp_pr = node.xml.find("p:spPr", NS)+ if sp_pr is None:+ return "block formula carrier is missing p:spPr"+ preset = sp_pr.find("a:prstGeom", NS)+ if preset is None or preset.get("prst") != "rect":+ return "block formula carrier must use rectangular geometry"+ if any(+ sp_pr.find(path, NS) is not None+ for path in (+ "a:solidFill",+ "a:gradFill",+ "a:pattFill",+ "a:blipFill",+ "a:grpFill",+ "a:effectLst",+ "a:effectDag",+ "a:scene3d",+ "a:sp3d",+ )+ ):+ return "block formula carrier paint or effect is not reversible"+ line = sp_pr.find("a:ln", NS)+ if line is not None and line.find("a:noFill", NS) is None:+ return "block formula carrier line is not reversible"+ return None+++def _prepare_inline_formula_resolver(+ tx_body: ET.Element | None,+ ctx: AssemblyContext,+ *,+ allow_native: bool,+ force_opaque: bool = False,+):+ """Build one all-or-opaque resolver for formula runs in a text body."""+ if tx_body is None:+ return None+ zones = [+ child+ for paragraph in tx_body.findall("a:p", NS)+ for child in paragraph+ if child.tag == f"{{{A14_NS}}}m"+ ]+ if not zones:+ return None++ imported: dict[int, FormulaImport] = {}+ failed = force_opaque+ if not allow_native:+ failed = True+ _diagnose_formula_fallback(+ ctx,+ FormulaImportError(+ "formula reconstruction is not supported inside vertical text"+ ),+ )+ elif not force_opaque:+ for zone in zones:+ try:+ imported[id(zone)] = import_formula(zone, display=False)+ except FormulaImportError as exc:+ failed = True+ _diagnose_formula_fallback(ctx, exc)++ def _resolve(zone: ET.Element) -> tuple[str | None, str]:+ if failed:+ return None, opaque_formula_preview(zone)+ item = imported.get(id(zone))+ if item is None:+ return None, opaque_formula_preview(zone)+ return item.latex, item.preview++ return _resolve+++def _diagnose_formula_fallback(+ ctx: AssemblyContext,+ error: FormulaImportError,+) -> None:+ message = f"Office Math was not reconstructed: {error}"+ if ctx.strict:+ raise ValueError(message) from error+ ctx.diagnose(+ "formula-not-reconstructed",+ message,+ "render a linear text preview and preserve the relationship-free source txBody",+ )+++def _render_block_formula(+ node: ShapeNode,+ ctx: AssemblyContext,+ formula: FormulaImport,+ *,+ top_level: bool,+) -> str:+ """Emit one canonical block marker and a dependency-free SVG preview."""+ x = fmt_num(node.xfrm.x)+ y = fmt_num(node.xfrm.y)+ width = fmt_num(node.xfrm.w)+ height = fmt_num(node.xfrm.h)+ align = formula.align+ if align == "right":+ preview_x = node.xfrm.x + node.xfrm.w+ anchor = "end"+ elif align == "left":+ preview_x = node.xfrm.x+ anchor = "start"+ else:+ preview_x = node.xfrm.x + node.xfrm.w / 2.0+ anchor = "middle"+ preview_y = node.xfrm.y + node.xfrm.h / 2.0 + formula.font_size_px * 0.35+ payload = {+ "latex": formula.latex,+ "display": "block",+ "font_size": formula.font_size_px,+ "color": formula.color,+ "align": align,+ "language": formula.language,+ "name": node.name or f"Formula {node.spid}",+ }+ metadata = (+ '<metadata type="application/json">'+ + _xml_escape(json.dumps(payload, ensure_ascii=False, separators=(",", ":")))+ + "</metadata>"+ )+ preview = (+ f'<text x="{fmt_num(preview_x)}" y="{fmt_num(preview_y)}" '+ f'text-anchor="{anchor}" font-family="Cambria Math" '+ f'font-size="{fmt_num(formula.font_size_px)}" '+ f'fill="{_xml_escape(formula.color)}">'+ f'{_xml_escape(formula.preview)}</text>'+ )+ return _wrap_shape_group(+ metadata + "\n" + preview,+ node,+ ctx,+ top_level=top_level,+ extra_attrs=[+ 'data-pptx-replace-with="formula"',+ 'data-pptx-import-source="pptx"',+ f'data-pptx-x="{x}"',+ f'data-pptx-y="{y}"',+ f'data-pptx-width="{width}"',+ f'data-pptx-height="{height}"',+ f'data-pptx-bounds="{x} {y} {width} {height}"',+ ],+ )++def _txbody_metadata(tx_body: ET.Element,visible_text_svg: str,diff --git a/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.pyindex 1550a35d..75cf3e4f 100644--- a/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/txbody_to_svg.py@@ -66,9 +66,11 @@ class TextRun:letter_spacing_px: float = 0.0is_break: bool = False # marks an a:br within a paragraphhyperlink_href: str | None = None+ formula_latex: str | None = NoneHyperlinkResolver = Callable[[str, str], str | None]+InlineFormulaResolver = Callable[[ET.Element], tuple[str | None, str]]@dataclass@@ -97,6 +99,7 @@ class TextResult:svg: str = ""defs: list[str] = field(default_factory=list)+ contains_inline_formula: bool = FalseVERTICAL_TEXT_MODES = {"eaVert", "vert", "wordArtVert", "wordArtVertRtl"}@@ -120,6 +123,7 @@ def convert_txbody(id_prefix: str = "txt",id_seq: list[int] | None = None,hyperlink_resolver: HyperlinkResolver | None = None,+ inline_formula_resolver: InlineFormulaResolver | None = None,) -> TextResult:"""Convert <p:txBody> under the given shape geometry to SVG <text>(s)."""if tx_body is None:@@ -133,6 +137,7 @@ def convert_txbody(fallback_run_props=fallback_run_props,slide_number=slide_number, id_prefix=id_prefix, id_seq=id_seq,hyperlink_resolver=hyperlink_resolver,+ inline_formula_resolver=inline_formula_resolver,)if not paragraphs or not _has_visible_text(paragraphs):return TextResult()@@ -204,7 +209,12 @@ def convert_txbody(if cursor_y >= bottom_y:break- return TextResult(svg="\n".join(text_blocks), defs=_collect_text_defs(paragraphs))+ svg = "\n".join(text_blocks)+ return TextResult(+ svg=svg,+ defs=_collect_text_defs(paragraphs),+ contains_inline_formula="data-pptx-inline-formula=" in svg,+ )def is_vertical_txbody(tx_body: ET.Element | None, xfrm: Xfrm | None = None) -> bool:@@ -232,6 +242,7 @@ def convert_vertical_txbody(id_prefix: str = "txt",id_seq: list[int] | None = None,hyperlink_resolver: HyperlinkResolver | None = None,+ inline_formula_resolver: InlineFormulaResolver | None = None,) -> TextResult:"""Render East Asian vertical text as upright stacked glyphs.@@ -250,6 +261,7 @@ def convert_vertical_txbody(fallback_run_props=fallback_run_props,slide_number=slide_number, id_prefix=id_prefix, id_seq=id_seq,hyperlink_resolver=hyperlink_resolver,+ inline_formula_resolver=inline_formula_resolver,)runs = [run@@ -309,6 +321,7 @@ def convert_vertical_txbody(return TextResult(svg=f"<text{attrs}>{''.join(spans)}</text>",defs=_collect_text_defs(paragraphs),+ contains_inline_formula=False,)@@ -387,6 +400,7 @@ def _parse_paragraphs(id_prefix: str = "txt",id_seq: list[int] | None = None,hyperlink_resolver: HyperlinkResolver | None = None,+ inline_formula_resolver: InlineFormulaResolver | None = None,) -> list[TextParagraph]:"""Walk <a:p> children producing TextParagraph objects."""paragraphs: list[TextParagraph] = []@@ -407,6 +421,7 @@ def _parse_paragraphs(slide_number=slide_number,id_prefix=id_prefix, id_seq=id_seq,hyperlink_resolver=hyperlink_resolver,+ inline_formula_resolver=inline_formula_resolver,)paragraphs.append(para)@@ -427,6 +442,7 @@ def _parse_paragraph(id_prefix: str = "txt",id_seq: list[int] | None = None,hyperlink_resolver: HyperlinkResolver | None = None,+ inline_formula_resolver: InlineFormulaResolver | None = None,) -> TextParagraph:para = TextParagraph()@@ -504,6 +520,20 @@ def _parse_paragraph(text = str(slide_number)if text:para.runs.append(resolved_run(text, rpr))+ elif (+ child.tag+ == "{http://schemas.microsoft.com/office/drawing/2010/main}m"+ and inline_formula_resolver is not None+ ):+ latex, preview = inline_formula_resolver(child)+ if preview:+ formula_rpr = next(+ child.iter(f"{{{NS['a']}}}rPr"),+ None,+ )+ run = resolved_run(preview, formula_rpr)+ run.formula_latex = latex+ para.runs.append(run)return para@@ -1082,6 +1112,14 @@ def _wrap_paragraph_into_lines(continueif not run.text:continue+ if run.formula_latex is not None:+ width = _estimate_run_width(run.text, run)+ if lines[-1] and cur_w + width > max_width:+ lines.append([])+ cur_w = 0.0+ lines[-1].append(_copy_run(run, text=run.text))+ cur_w += width+ continuetext = run.texti = 0while i < len(text):@@ -1152,6 +1190,7 @@ def _copy_run(run: TextRun, *, text: str) -> TextRun:strikethrough=run.strikethrough,letter_spacing_px=run.letter_spacing_px,hyperlink_href=run.hyperlink_href,+ formula_latex=run.formula_latex,)@@ -1269,8 +1308,7 @@ def _emit_paragraph(if line_has_hyperlink:run_spans = ''.join(_wrap_run_hyperlink(- f'<tspan{_run_tspan_attrs(run)}>'- f'{_xml_escape(run.text)}</tspan>',+ _run_tspan_markup(run),run,)for run in line@@ -1285,15 +1323,20 @@ def _emit_paragraph(for run_idx, run in enumerate(line):attrs = _run_tspan_attrs(run)if run_idx == 0 and line_advance is not None:- spans.append(- f'<tspan x="{fmt_num(anchor_x)}" '- f'dy="{fmt_num(line_advance)}"'- f'{attrs}>{_xml_escape(run.text)}</tspan>'- )+ if run.formula_latex is not None:+ spans.append(+ f'<tspan x="{fmt_num(anchor_x)}" '+ f'dy="{fmt_num(line_advance)}">'+ f'{_run_tspan_markup(run)}</tspan>'+ )+ else:+ spans.append(+ f'<tspan x="{fmt_num(anchor_x)}" '+ f'dy="{fmt_num(line_advance)}"'+ f'{attrs}>{_xml_escape(run.text)}</tspan>'+ )else:- spans.append(- f"<tspan{attrs}>{_xml_escape(run.text)}</tspan>"- )+ spans.append(_run_tspan_markup(run))base_attrs = _text_base_attrs(first_run, anchor_x, first_baseline, text_anchor)return f"<text{base_attrs}>{''.join(spans)}</text>"@@ -1362,6 +1405,20 @@ def _run_tspan_attrs(run: TextRun) -> str:return " " + " ".join(parts)+def _run_tspan_markup(run: TextRun) -> str:+ formula_attr = ""+ if run.formula_latex is not None:+ formula_attr = (+ ' data-pptx-inline-formula="'+ + _xml_escape(run.formula_latex)+ + '"'+ )+ return (+ f"<tspan{_run_tspan_attrs(run)}{formula_attr}>"+ f"{_xml_escape(run.text)}</tspan>"+ )++def _wrap_run_hyperlink(markup: str, run: TextRun) -> str:"""Wrap one visible SVG run in the canonical hyperlink carrier."""if not run.hyperlink_href:diff --git a/skills/ppt-master/scripts/prompt_audit_manifest.json b/skills/ppt-master/scripts/prompt_audit_manifest.jsonindex ee7ad8c5..abc6ae8b 100644--- a/skills/ppt-master/scripts/prompt_audit_manifest.json+++ b/skills/ppt-master/scripts/prompt_audit_manifest.json@@ -951,7 +951,7 @@"files": ["skills/ppt-master/scripts/docs/conversion.md"],- "max_tokens": 6750+ "max_tokens": 7500},"stage.shared.troubleshooting": {"description": "Conditional troubleshooting reference for generation failures.",@@ -1052,7 +1052,7 @@"files": ["skills/ppt-master/references/native-formula.md"],- "max_tokens": 2000+ "max_tokens": 2250},"stage.generate.executor.hyperlink": {"description": "Conditional direct authoring contract for PowerPoint-native external and same-deck click hyperlinks.",