Skip to content

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

fix(pptx-to-svg): import b="true" and i="true" as bold and italic

hugohe38bdf440cc1c7
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.py
index 686b3d0c..734eb9a7 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
@@ -34,7 +34,7 @@ from svg_to_pptx.drawingml.utils import detect_text_lang, is_cjk_char
from .color_resolver import ColorPalette, find_color_elem, resolve_color
from .emu_units import (
NS, Xfrm, fmt_num, emu_to_px, format_ooxml_alpha,
- hundredths_pt_to_px,
+ hundredths_pt_to_px, ooxml_bool,
)
from .fill_to_svg import resolve_fill
@@ -860,8 +860,8 @@ def _build_run(
# font-size: rPr > pPr/defRPr > lstStyle/lvlNpPr/defRPr > endParaRPr > default
font_size_px = _font_size_px(style_chain, default_font_size_px)
# Bold / italic
- bold = _attr_chain(style_chain, "b") == "1"
- italic = _attr_chain(style_chain, "i") == "1"
+ bold = ooxml_bool(_attr_chain(style_chain, "b"))
+ italic = ooxml_bool(_attr_chain(style_chain, "i"))
# Underline / strike
u_val = _attr_chain(style_chain, "u")
underline = u_val not in (None, "", "none")
diff --git a/skills/ppt-master/scripts/tests/test_text_overflow_import.py b/skills/ppt-master/scripts/tests/test_text_overflow_import.py
index 4eb1fd74..5e9f43fa 100644
--- a/skills/ppt-master/scripts/tests/test_text_overflow_import.py
+++ b/skills/ppt-master/scripts/tests/test_text_overflow_import.py
@@ -197,3 +197,17 @@ class TextOverflowImportTests(unittest.TestCase):
table.find('a:tr/a:tc', NS).insert(0, body)
result = convert_tbl(table, Xfrm(x=80, y=100, w=600, h=32), None)
self.assertEqual(_visible_text(_svg_root(result.svg)), expected)
+
+
+class RunEmphasisImportTests(unittest.TestCase):
+ def test_true_and_one_both_import_bold_and_italic(self) -> None:
+ for value in ('1', 'true'):
+ with self.subTest(value=value):
+ body = ET.fromstring(
+ f'<p:txBody xmlns:p="{P}" xmlns:a="{A}"><a:bodyPr/><a:lstStyle/>'
+ f'<a:p><a:r><a:rPr b="{value}" i="{value}"/><a:t>Key</a:t></a:r></a:p>'
+ '</p:txBody>'
+ )
+ svg = convert_txbody(body, Xfrm(x=0, y=0, w=300, h=100), None).svg
+ self.assertIn('font-weight="bold"', svg)
+ self.assertIn('font-style="italic"', svg)