修复svg2pptx转换器多项bug + 新增管线兼容性文档

svg2pptx.py:
- 修复image opacity不生效(通过OOXML alphaModFix)
- 修复环形图stroke渐变url(#id)引用不支持(fallback第一个stop颜色)
- 修复viewBox内缩放不传递(g组scale累积到所有子元素)
- 修复text baseline偏移(区分text-after-edge和auto)
- 修复text-anchor:middle/end的x坐标偏移
- 添加--html-dir参数支持

html2svg.py:
- 修复图片相对路径解析(以HTML文件所在目录为基准)
- 新增3种CSS兜底预处理(background-clip:text、text-fill-color、mask-image)

新增 references/pipeline-compat.md:
- HTML->SVG->PPTX管线兼容性规则文档
- CSS禁止清单、防偏移写法指南、防偏移checklist
- 已整合到SKILL.md和prompts.md中引用

prompts.md:
- 新增内联SVG防偏移约束(禁SVG text、用HTML叠加)

示例产物:
- ppt-output/ 包含SU7示例的完整HTML/SVG/PPTX产物
This commit is contained in:
sunbigfly
2026-03-21 03:57:23 +08:00
parent 7dcfe25603
commit e860485ec8
27 changed files with 7914 additions and 56 deletions

View File

@@ -0,0 +1,258 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<style>
:root {
--bg-primary: #1A1A1A;
--bg-secondary: #111111;
--card-bg-from: #2A2A2A;
--card-bg-to: #1A1A1A;
--card-border: rgba(255,105,0,0.15);
--card-radius: 16px;
--text-primary: #FFFFFF;
--text-secondary: rgba(255,255,255,0.65);
--accent-1: #FF6900;
--accent-2: #FF8C00;
--accent-3: #FFFFFF;
--accent-4: #E0E0E0;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
width: 1280px; height: 720px; overflow: hidden;
background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
font-family: 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
color: var(--text-primary);
position: relative;
}
.page-title {
position: absolute; left: 40px; top: 20px;
width: 1200px; height: 50px;
display: flex; align-items: center; gap: 16px;
}
.title-accent {
width: 4px; height: 28px;
background: linear-gradient(180deg, var(--accent-1), var(--accent-2));
border-radius: 2px;
}
.page-title h2 { font-size: 26px; font-weight: 700; }
.page-title .subtitle {
font-size: 14px; color: var(--text-secondary); margin-left: auto;
}
/* 内容区 -- 主次结合(大+两小) */
.content-area {
position: absolute;
left: 40px; top: 80px;
width: 1200px; height: 580px;
display: grid;
grid-template: 1fr 1fr / 2fr 1fr;
gap: 20px;
}
.card {
border-radius: var(--card-radius);
background: linear-gradient(180deg, var(--card-bg-from), var(--card-bg-to));
border: 1px solid var(--card-border);
padding: 28px;
position: relative;
overflow: hidden;
}
/* 主卡片氛围底图极低透明度无需遮罩SVG/PPTX安全 */
.main-card .card-bg-img {
position: absolute;
bottom: 0; right: 0;
width: 40%; height: 45%;
object-fit: cover;
opacity: 0.06;
pointer-events: none;
z-index: 0;
border-radius: 0 0 var(--card-radius) 0;
}
.main-card > *:not(.card-bg-img) { position: relative; z-index: 1; }
/* 主卡片 -- 跨两行 */
.main-card {
grid-row: 1 / -1;
}
.main-card h3 {
font-size: 20px; font-weight: 700; margin-bottom: 20px;
}
.main-card h3 svg {
width: 20px; height: 20px; vertical-align: middle;
margin-right: 8px; fill: var(--accent-1);
}
/* 续航对比图 -- SVG柱形图 */
.range-chart {
width: 100%; height: 340px;
margin-top: 12px;
}
.range-chart svg { width: 100%; height: 100%; }
.chart-bar { rx: 6; }
.chart-label { font-size: 13px; fill: var(--text-secondary); font-family: inherit; }
.chart-value { font-size: 16px; fill: var(--text-primary); font-weight: 700; font-family: inherit; }
.chart-model { font-size: 14px; fill: var(--text-secondary); font-family: inherit; }
/* 对比说明 */
.compare-note {
margin-top: 20px;
padding: 14px 18px;
border-radius: 10px;
background: rgba(255,105,0,0.06);
border-left: 3px solid var(--accent-1);
}
.compare-note p {
font-size: 13px; color: var(--text-secondary); line-height: 1.7;
}
.compare-note strong { color: var(--accent-1); font-weight: 600; }
/* 辅助卡片 */
.side-card h3 {
font-size: 18px; font-weight: 700; margin-bottom: 16px;
}
.kpi-row {
display: flex; align-items: baseline; gap: 4px;
}
.kpi-number {
font-size: 48px; font-weight: 800;
color: var(--accent-1);
line-height: 1;
}
.kpi-unit {
font-size: 18px; color: var(--accent-2);
font-weight: 600;
}
.kpi-desc {
font-size: 13px; color: var(--text-secondary);
margin-top: 10px; line-height: 1.6;
}
/* 快充进度环 -- 纯CSS+内联SVG兼容管线 */
.charge-ring {
width: 120px; height: 120px; margin: 12px auto;
position: relative;
}
.charge-ring svg { width: 100%; height: 100%; }
.charge-ring-text {
position: absolute; top: 50%; left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.charge-ring-text .ring-val {
font-size: 22px; font-weight: 700; color: var(--text-primary);
display: block;
}
.charge-ring-text .ring-lbl {
font-size: 10px; color: var(--text-secondary);
display: block;
}
.footer {
position: absolute; bottom: 16px; left: 40px; right: 40px;
display: flex; justify-content: space-between;
font-size: 12px; color: rgba(255,255,255,0.3);
}
</style>
</head>
<body>
<div class="page-title">
<div class="title-accent"></div>
<h2>动力与续航全面升级</h2>
<span class="subtitle">V6s Plus超级电机 / 高压快充平台</span>
</div>
<div class="content-area">
<!-- 主卡片: 续航对比柱形图 -->
<div class="card main-card">
<img class="card-bg-img" src="../images/su7_power.png" alt="">
<h3>
<svg viewBox="0 0 24 24"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/></svg>
CLTC续航里程对比 (km)
</h3>
<div class="range-chart">
<svg viewBox="0 0 660 340">
<!-- 初代 vs 新款 对比柱 -->
<!-- 标准版 -->
<text class="chart-model" x="70" y="330" text-anchor="middle">标准版</text>
<rect class="chart-bar" x="30" y="102" width="35" height="210" fill="rgba(255,255,255,0.1)"/>
<text class="chart-label" x="47" y="95" text-anchor="middle">700</text>
<rect class="chart-bar" x="70" y="96" width="35" height="216" fill="url(#barGrad)"/>
<text class="chart-value" x="87" y="89" text-anchor="middle">720</text>
<!-- Pro版 -->
<text class="chart-model" x="250" y="330" text-anchor="middle">Pro</text>
<rect class="chart-bar" x="210" y="63" width="35" height="249" fill="rgba(255,255,255,0.1)"/>
<text class="chart-label" x="227" y="56" text-anchor="middle">830</text>
<rect class="chart-bar" x="250" y="41" width="35" height="271" fill="url(#barGrad)"/>
<text class="chart-value" x="267" y="34" text-anchor="middle">902</text>
<!-- Max版 -->
<text class="chart-model" x="430" y="330" text-anchor="middle">Max</text>
<rect class="chart-bar" x="390" y="72" width="35" height="240" fill="rgba(255,255,255,0.1)"/>
<text class="chart-label" x="407" y="65" text-anchor="middle">800</text>
<rect class="chart-bar" x="430" y="62" width="35" height="250" fill="url(#barGrad)"/>
<text class="chart-value" x="447" y="55" text-anchor="middle">835</text>
<!-- 图例 -->
<rect x="520" y="20" width="14" height="14" rx="3" fill="rgba(255,255,255,0.1)"/>
<text class="chart-label" x="540" y="31">初代SU7</text>
<rect x="520" y="44" width="14" height="14" rx="3" fill="var(--accent-1)"/>
<text class="chart-label" x="540" y="55">新一代SU7</text>
<defs>
<linearGradient id="barGrad" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#FF6900"/>
<stop offset="100%" stop-color="#FF8C00"/>
</linearGradient>
</defs>
</svg>
</div>
<div class="compare-note">
<p>Pro版续航从830km跃升至<strong>902km</strong>提升幅度达8.7%;全系搭载<strong>V6s Plus超级电机</strong>,标准版/Pro版功率提升至320hp。</p>
</div>
</div>
<!-- 辅助卡片1: 0-100加速 -->
<div class="card side-card">
<h3>Max版零百加速</h3>
<div class="kpi-row">
<span class="kpi-number">3.08</span>
<span class="kpi-unit">s</span>
</div>
<p class="kpi-desc">双电机四驱系统897V高压架构最大功率690hp。前双叉臂+后多连杆悬挂,配备闭式双腔空气弹簧。</p>
</div>
<!-- 辅助卡片2: 快充能力 -->
<div class="card side-card">
<h3>超级快充补能</h3>
<div class="charge-ring">
<svg viewBox="0 0 120 120">
<defs>
<linearGradient id="ringGrad" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#FF6900"/>
<stop offset="100%" stop-color="#FF8C00"/>
</linearGradient>
</defs>
<circle cx="60" cy="60" r="50" fill="none" stroke="rgba(255,255,255,0.06)" stroke-width="8"/>
<circle cx="60" cy="60" r="50" fill="none" stroke="url(#ringGrad)" stroke-width="8"
stroke-linecap="round" stroke-dasharray="235 314"
transform="rotate(-90 60 60)"/>
</svg>
<div class="charge-ring-text">
<span class="ring-val">15</span>
<span class="ring-lbl">分钟</span>
</div>
</div>
<p class="kpi-desc" style="text-align:center">Max版15分钟快充即可补充<strong style="color:var(--accent-1)">670km</strong>续航里程,补能效率行业领先。</p>
</div>
</div>
<div class="footer">
<span>新一代小米SU7 | 动力与续航</span>
<span>03 / 05</span>
</div>
</body>
</html>