1
0
Files
PPTX/openspec/changes/archive/2026-03-04-fix-multiline-text-font-size/tasks.md
lanyuanxiaoyao 5b367f7ef3 fix: 修复多行文本渲染时字号只应用于第一段的bug
当使用 YAML 多行字符串语法定义文本内容时,python-pptx 会自动
将包含换行符的文本分割成多个段落。修改 _render_text 方法使其
遍历所有段落并应用相同的字体样式(大小、粗体、斜体、颜色、对齐)。

主要变更:
- renderers/pptx_renderer.py: 将 p = tf.paragraphs[0] 改为 for p in tf.paragraphs
- tests/unit/test_renderers/test_pptx_renderer.py: 新增多行文本测试用例
- openspec/specs/element-rendering/spec.md: 更新 spec 文档
- openspec/changes/archive/: 归档完成的变更
2026-03-04 12:18:23 +08:00

31 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. 代码修改
- [x] 1.1 修改 `_render_text` 方法,将 `p = tf.paragraphs[0]` 改为 `for p in tf.paragraphs:`
- [x] 1.2 确保所有字体样式属性size, bold, italic, color, align应用到每个段落
- [x] 1.3 验证修改后代码语法正确,无逻辑错误
## 2. 单元测试
- [x] 2.1 添加多行文本字体大小测试用例
- [x] 2.2 添加多行文本完整样式测试用例size, bold, italic, color, align
- [x] 2.3 添加单行文本回归测试用例(确保行为不变)
- [x] 2.4 更新测试辅助函数 `_setup_mock_slide` 以支持多段落 Mock
## 3. 集成测试
- [x] 3.1 创建测试 YAML 文件包含多行文本示例
- [x] 3.2 生成测试 PPTX 文件并验证所有段落样式一致
- [x] 3.3 手动打开生成的 PPTX 文件确认视觉效果正确
## 4. 验证与清理
- [x] 4.1 运行所有单元测试确保通过
- [x] 4.2 运行完整测试套件确保无回归
- [x] 4.3 使用 `temp/complex_presentation.yaml` 验证幻灯片2渲染正确
- [x] 4.4 删除临时测试文件 `temp/test_multiline_behavior.py`(如需要)
## 5. 文档更新
- [x] 5.1 更新 README.md如有需要
- [x] 5.2 更新 README_DEV.md如有需要