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): preserve inherited layout and text fidelity

hugohe3aa9a01b59ef1
diff --git a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
index 0890c5aa..758b7e25 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py
@@ -43,6 +43,7 @@ def resolve_fill(
*,
id_prefix: str = "g",
id_seq: list[int] | None = None,
+ placeholder_hex: str | None = None,
) -> FillResult:
"""Inspect <p:spPr>'s fill children and emit an SVG fill descriptor.
@@ -62,16 +63,23 @@ def resolve_fill(
return FillResult.inherit()
# Direct child fill (in priority order: explicit -> derived).
- for tag, handler in (
+ handlers = (
("noFill", _resolve_no_fill),
("solidFill", _resolve_solid_fill),
("gradFill", _resolve_grad_fill),
("blipFill", _resolve_blip_fill),
("pattFill", _resolve_patt_fill),
- ):
+ )
+
+ local_name = sp_pr.tag.split("}", 1)[-1] if isinstance(sp_pr.tag, str) else ""
+ for tag, handler in handlers:
+ if local_name == tag:
+ return handler(sp_pr, palette, id_prefix, id_seq, placeholder_hex)
+
+ for tag, handler in handlers:
elem = sp_pr.find(f"a:{tag}", NS)
if elem is not None:
- return handler(elem, palette, id_prefix, id_seq)
+ return handler(elem, palette, id_prefix, id_seq, placeholder_hex)
return FillResult.inherit()
@@ -80,14 +88,14 @@ def resolve_fill(
# Per-fill handlers
# ---------------------------------------------------------------------------
-def _resolve_no_fill(_elem, _palette, _prefix, _seq) -> FillResult:
+def _resolve_no_fill(_elem, _palette, _prefix, _seq, _placeholder_hex) -> FillResult:
return FillResult.none_fill()
def _resolve_solid_fill(elem: ET.Element, palette: ColorPalette | None,
- _prefix: str, _seq) -> FillResult:
+ _prefix: str, _seq, placeholder_hex: str | None) -> FillResult:
color_elem = find_color_elem(elem)
- hex_, alpha = resolve_color(color_elem, palette)
+ hex_, alpha = resolve_color(color_elem, palette, placeholder_hex=placeholder_hex)
if hex_ is None:
return FillResult.inherit()
attrs: dict[str, str] = {"fill": hex_}
@@ -97,7 +105,7 @@ def _resolve_solid_fill(elem: ET.Element, palette: ColorPalette | None,
def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
- prefix: str, seq) -> FillResult:
+ prefix: str, seq, placeholder_hex: str | None) -> FillResult:
"""Convert <a:gradFill> to an SVG linearGradient or radialGradient."""
if seq is None:
seq = [0]
@@ -112,7 +120,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
for gs in gs_lst.findall("a:gs", NS):
pos_pct = percent_to_ratio(gs.attrib.get("pos"), default=0.0)
color_elem = find_color_elem(gs)
- hex_, alpha = resolve_color(color_elem, palette)
+ hex_, alpha = resolve_color(color_elem, palette, placeholder_hex=placeholder_hex)
if hex_ is None:
continue
opacity_attr = f' stop-opacity="{fmt_num(alpha, 4)}"' if alpha < 1.0 else ""
@@ -162,7 +170,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,
)
-def _resolve_blip_fill(_elem, _palette, _prefix, _seq) -> FillResult:
+def _resolve_blip_fill(_elem, _palette, _prefix, _seq, _placeholder_hex) -> FillResult:
"""blipFill on <p:spPr> means a shape filled with an image — handled at
pic_to_svg level. For now mark as transparent so the shape's outline
still draws and pic_to_svg can layer the image on top.
@@ -171,14 +179,14 @@ def _resolve_blip_fill(_elem, _palette, _prefix, _seq) -> FillResult:
def _resolve_patt_fill(elem: ET.Element, palette: ColorPalette | None,
- _prefix, _seq) -> FillResult:
+ _prefix, _seq, placeholder_hex: str | None) -> FillResult:
"""Pattern fills (<a:pattFill prst="..."/> with fg/bg colors). Approximate
with the foreground color so the shape isn't transparent. Future work:
emit a real <pattern> in defs.
"""
fg = elem.find("a:fgClr", NS)
color_elem = find_color_elem(fg)
- hex_, alpha = resolve_color(color_elem, palette)
+ hex_, alpha = resolve_color(color_elem, palette, placeholder_hex=placeholder_hex)
if hex_ is None:
return FillResult.inherit()
attrs: dict[str, str] = {"fill": hex_}
diff --git a/skills/ppt-master/scripts/pptx_to_svg/prstgeom_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/prstgeom_to_svg.py
index 81a3878b..44fe7deb 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/prstgeom_to_svg.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/prstgeom_to_svg.py
@@ -83,6 +83,10 @@ def convert_prst_geom(
Returns None if the preset has no v1 mapping; the caller can then choose
to render a fallback rect.
"""
+ if prst == "line":
+ if xfrm.w == 0 and xfrm.h == 0:
+ return None
+ return _line(xfrm, sp_pr)
if xfrm.w <= 0 or xfrm.h <= 0:
return None
handler = _PRESET_HANDLERS.get(prst)
diff --git a/skills/ppt-master/scripts/pptx_to_svg/shape_walker.py b/skills/ppt-master/scripts/pptx_to_svg/shape_walker.py
index 2fa22423..c8c2462b 100644
--- a/skills/ppt-master/scripts/pptx_to_svg/shape_walker.py
+++ b/skills/ppt-master/scripts/pptx_to_svg/shape_walker.py
@@ -80,9 +80,9 @@ def _read_nv_sp_pr(parent: ET.Element, nv_tag: str) -> tuple[str, str, bool, Pla
if cnv.attrib.get("hidden") == "1":
hidden = True
- nv_sp_pr = container.find("p:nvSpPr", NS)
- if nv_sp_pr is not None:
- ph_elem = nv_sp_pr.find("p:ph", NS)
+ nv_pr = container.find("p:nvPr", NS)
+ if nv_pr is not None:
+ ph_elem = nv_pr.find("p:ph", NS)
if ph_elem is not None:
ph = PlaceholderInfo(
type=ph_elem.attrib.get("type"),
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.py
index d0fb58fb..66cc7442 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
@@ -25,7 +25,7 @@ from __future__ import annotations
from dataclasses import dataclass, field
from xml.etree import ElementTree as ET
-from .color_resolver import ColorPalette
+from .color_resolver import ColorPalette, find_color_elem, resolve_color
from .custgeom_to_svg import convert_custom_geom
from .effect_to_svg import convert_effects
from .emu_units import NS, fmt_num
@@ -38,7 +38,12 @@ from .shape_walker import (
CONNECTOR, GRAPHIC, GROUP, PICTURE, SHAPE,
ShapeNode, get_background, walk_sp_tree,
)
-from .txbody_to_svg import TextResult, convert_txbody
+from .txbody_to_svg import (
+ TextResult,
+ convert_txbody,
+ convert_vertical_txbody,
+ is_vertical_txbody,
+)
# ---------------------------------------------------------------------------
@@ -56,6 +61,7 @@ class AssemblyContext:
media_subdir: str = "assets"
embed_images: bool = False
keep_hidden: bool = False
+ group_id_prefix: str = ""
# Sequence counters (single-element lists so handlers can mutate)
grad_seq: list[int] = field(default_factory=lambda: [0])
@@ -101,6 +107,10 @@ def assemble_slide(
if bg_xml:
body_parts.append(bg_xml)
+ # Inherited layout/master shapes render behind slide-local shapes. Skip
+ # placeholders; they define editable regions, not visible background.
+ body_parts.extend(_emit_inherited_shapes(slide, ctx))
+
# Walk shapes
nodes = walk_sp_tree(slide.part.xml)
for node in nodes:
@@ -156,10 +166,28 @@ def _convert_shape(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->
# Text body (a:txBody)
tx_body = node.xml.find("p:txBody", NS)
- text_result = convert_txbody(
- tx_body, node.xfrm, ctx.palette,
- theme_fonts=ctx.theme_fonts,
- ) if tx_body is not None else TextResult()
+ is_vertical = is_vertical_txbody(tx_body)
+ if tx_body is not None and is_vertical:
+ text_result = convert_vertical_txbody(
+ tx_body, node.xfrm, ctx.palette,
+ theme_fonts=ctx.theme_fonts,
+ )
+ else:
+ text_result = convert_txbody(
+ tx_body, node.xfrm, ctx.palette,
+ theme_fonts=ctx.theme_fonts,
+ ) if tx_body is not None else TextResult()
+
+ if is_vertical:
+ shape_xml = _wrap_shape_group(geom_xml, node, ctx, top_level=top_level)
+ if not text_result.svg:
+ return shape_xml
+ text_group = (
+ f'<g id="{ctx.group_id_prefix}shape-{node.spid or ctx.shape_seq[0]}-text"'
+ f' data-name="{_xml_escape(node.name)} text">\n'
+ f"{text_result.svg}\n</g>"
+ )
+ return f"{shape_xml}\n{text_group}"
inner = (geom_xml + ("\n" + text_result.svg if text_result.svg else ""))
return _wrap_shape_group(inner, node, ctx, top_level=top_level)
@@ -187,7 +215,9 @@ def _build_geometry_xml(node: ShapeNode, sp_pr: ET.Element | None,
# No geometry hint at all — render bounding rect
geom = convert_prst_geom("rect", node.xfrm, None)
- if geom is None or node.xfrm.w <= 0 or node.xfrm.h <= 0:
+ if geom is None:
+ return ""
+ if geom.tag != "line" and (node.xfrm.w <= 0 or node.xfrm.h <= 0):
return ""
# Fill / stroke / effect
@@ -309,10 +339,21 @@ def _emit_background(slide: SlideRef, ctx: AssemblyContext,
if bg is None:
continue
bg_pr = bg.find("p:bgPr", NS)
+ bg_ref = bg.find("p:bgRef", NS)
+ placeholder_hex = None
+
+ if bg_pr is None and bg_ref is not None:
+ bg_pr = _theme_background_fill(slide, ctx, bg_ref)
+ color_elem = find_color_elem(bg_ref)
+ placeholder_hex, _ = resolve_color(color_elem, ctx.palette)
if bg_pr is None:
continue
- fill = resolve_fill(bg_pr, ctx.palette,
- id_prefix="bg", id_seq=ctx.grad_seq)
+
+ fill = resolve_fill(
+ bg_pr, ctx.palette,
+ id_prefix="bg", id_seq=ctx.grad_seq,
+ placeholder_hex=placeholder_hex,
+ )
ctx.defs.extend(fill.defs)
if not fill.attrs:
return ""
@@ -323,6 +364,66 @@ def _emit_background(slide: SlideRef, ctx: AssemblyContext,
return ""
+def _theme_background_fill(
+ slide: SlideRef,
+ ctx: AssemblyContext,
+ bg_ref: ET.Element,
+) -> ET.Element | None:
+ """Resolve p:bgRef idx into the theme background fill style list."""
+ idx_raw = bg_ref.attrib.get("idx")
+ if not idx_raw:
+ return None
+ try:
+ idx = int(idx_raw)
+ except ValueError:
+ return None
+ # ECMA style matrix background fill references are 1001-based.
+ bg_fill_index = idx - 1001
+ if bg_fill_index < 0:
+ return None
+
+ theme = ctx.pkg.resolve_theme(slide.master)
+ if theme is None:
+ return None
+ fill_list = theme.xml.find(".//a:fmtScheme/a:bgFillStyleLst", NS)
+ if fill_list is None:
+ return None
+ fills = [child for child in list(fill_list) if isinstance(child.tag, str)]
+ if bg_fill_index >= len(fills):
+ return None
+ return fills[bg_fill_index]
+
+
+def _emit_inherited_shapes(slide: SlideRef, ctx: AssemblyContext) -> list[str]:
+ parts: list[str] = []
+ for prefix, part in (("master-", slide.master), ("layout-", slide.layout)):
+ if part is None:
+ continue
+ original_part = ctx.slide_part
+ original_prefix = ctx.group_id_prefix
+ ctx.slide_part = part
+ ctx.group_id_prefix = prefix
+ try:
+ for node in walk_sp_tree(part.xml):
+ if _is_placeholder_node(node):
+ continue
+ chunk = _convert_node(node, ctx, top_level=True)
+ if chunk:
+ parts.append(chunk)
+ finally:
+ ctx.slide_part = original_part
+ ctx.group_id_prefix = original_prefix
+ return parts
+
+
+def _is_placeholder_node(node: ShapeNode) -> bool:
+ if node.placeholder is not None:
+ return True
+ if node.kind == GROUP:
+ return all(_is_placeholder_node(child) for child in node.children)
+ return False
+
+
# ---------------------------------------------------------------------------
# Wrap / utilities
# ---------------------------------------------------------------------------
@@ -338,7 +439,7 @@ def _wrap_shape_group(inner: str, node: ShapeNode, ctx: AssemblyContext,
ctx.shape_seq[0] += 1
seq = ctx.shape_seq[0]
sid = node.spid or str(seq)
- g_id = f"shape-{sid}"
+ g_id = f"{ctx.group_id_prefix}shape-{sid}"
attrs: list[str] = [f'id="{g_id}"']
if node.name:
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 bdc229fa..bcb2f10e 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
@@ -88,6 +88,9 @@ class TextResult:
defs: list[str] = field(default_factory=list)
+VERTICAL_TEXT_MODES = {"eaVert", "vert", "wordArtVert", "wordArtVertRtl"}
+
+
# ---------------------------------------------------------------------------
# Public API
# ---------------------------------------------------------------------------
@@ -149,6 +152,84 @@ def convert_txbody(
return TextResult(svg="\n".join(text_blocks))
+def is_vertical_txbody(tx_body: ET.Element | None) -> bool:
+ if tx_body is None:
+ return False
+ body_pr = tx_body.find("a:bodyPr", NS)
+ if body_pr is None:
+ return False
+ return body_pr.attrib.get("vert") in VERTICAL_TEXT_MODES
+
+
+def convert_vertical_txbody(
+ tx_body: ET.Element | None,
+ xfrm: Xfrm,
+ palette: ColorPalette | None,
+ *,
+ theme_fonts: dict[str, str] | None = None,
+) -> TextResult:
+ """Render East Asian vertical text as upright stacked glyphs.
+
+ PowerPoint often combines ``bodyPr@vert=eaVert`` with a rotated text box.
+ Rendering the text inside the rotated shape group makes Chinese glyphs lie
+ sideways. This helper computes the final rotated box and places glyphs
+ upright in slide coordinates.
+ """
+ if tx_body is None:
+ return TextResult()
+
+ paragraphs = _parse_paragraphs(tx_body, palette, theme_fonts or {})
+ runs = [
+ run
+ for para in paragraphs
+ for run in para.runs
+ if not run.is_break and run.text
+ ]
+ if not runs:
+ return TextResult()
+
+ box_x, box_y, box_w, box_h = _rotated_bbox(xfrm)
+ center_x = box_x + box_w / 2.0
+
+ glyphs: list[tuple[str, TextRun]] = []
+ for run in runs:
+ for char in run.text:
+ if char in "\r\n":
+ continue
+ if char == " ":
+ continue
+ glyphs.append((char, run))
+
+ if not glyphs:
+ return TextResult()
+
+ advances = [glyph_run.font_size_px * 1.05 for _, glyph_run in glyphs]
+ total_h = sum(advances)
+ top_y = box_y + max(0.0, (box_h - total_h) / 2.0)
+
+ text_blocks: list[str] = []
+ cursor_y = top_y
+ for (char, run), advance in zip(glyphs, advances):
+ baseline_y = cursor_y + run.font_size_px * 0.85
+ attrs = _text_base_attrs(run, center_x, baseline_y, "middle")
+ tspan_attrs = _run_tspan_attrs(run)
+ text_blocks.append(
+ f"<text{attrs}><tspan{tspan_attrs}>{_xml_escape(char)}</tspan></text>"
+ )
+ cursor_y += advance
+
+ return TextResult(svg="\n".join(text_blocks))
+
+
+def _rotated_bbox(xfrm: Xfrm) -> tuple[float, float, float, float]:
+ rot = round(xfrm.rot) % 360
+ cx = xfrm.x + xfrm.w / 2.0
+ cy = xfrm.y + xfrm.h / 2.0
+ if rot in (90, 270):
+ return cx - xfrm.h / 2.0, cy - xfrm.w / 2.0, xfrm.h, xfrm.w
+ return xfrm.x, xfrm.y, xfrm.w, xfrm.h
+
+
# ---------------------------------------------------------------------------
# Parsing helpers
# ---------------------------------------------------------------------------
@@ -453,7 +534,11 @@ def _char_width(ch: str, font_size: float, bold: bool) -> float:
w = font_size * 0.3
else:
w = font_size * 0.55
- if bold:
+ # Bold Latin generally expands a little. CJK glyphs keep their em advance
+ # in common PPT fonts; applying the bold multiplier causes short Chinese
+ # titles such as "少年强国说" to wrap even though PowerPoint keeps them on
+ # one line.
+ if bold and not _is_cjk(ch):
w *= 1.05
return w
@@ -506,6 +591,9 @@ def _wrap_paragraph_into_lines(
lines: list[list[TextRun]] = [[]]
cur_w = 0.0
+ if _should_keep_single_line(para, max_width):
+ return [[_copy_run(run, text=run.text) for run in para.runs if not run.is_break and run.text]]
+
if para.bullet_prefix and para.runs:
first_run = next((r for r in para.runs if not r.is_break), None)
if first_run is not None:
@@ -555,6 +643,28 @@ def _wrap_paragraph_into_lines(
return lines
+def _should_keep_single_line(para: TextParagraph, max_width: float) -> bool:
+ if max_width == float("inf") or para.bullet_prefix:
+ return False
+ if any(run.is_break for run in para.runs):
+ return False
+
+ text_runs = [run for run in para.runs if run.text]
+ if not text_runs:
+ return False
+ text = "".join(run.text for run in text_runs)
+ non_space_count = sum(1 for ch in text if not ch.isspace())
+
+ # Short labels/titles are usually intentionally single-line in PPT. Let
+ # them overflow slightly rather than inventing a line break from imperfect
+ # font metrics or alignment spaces.
+ if non_space_count <= 18:
+ return True
+
+ estimated = sum(_estimate_run_width(run.text, run) for run in text_runs)
+ return estimated <= max_width * 1.12
+
+
def _copy_run(run: TextRun, *, text: str) -> TextRun:
return TextRun(
text=text,
@@ -663,6 +773,7 @@ def _text_base_attrs(run: TextRun | None, x: float, y: float,
f'x="{fmt_num(x)}"',
f'y="{fmt_num(y)}"',
f'text-anchor="{text_anchor}"',
+ 'xml:space="preserve"',
]
if run is None:
return " " + " ".join(parts)
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
index de7f611e..58a18c03 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
@@ -772,7 +772,7 @@ def convert_polyline(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | Non
# text
# ---------------------------------------------------------------------------
-def _normalize_text(text: str) -> str:
+def _normalize_text(text: str, *, preserve_space: bool = False) -> str:
"""Collapse runs of whitespace into a single space; do NOT strip the ends.
Stripping at this layer would silently delete the inline boundary
@@ -786,9 +786,16 @@ def _normalize_text(text: str) -> str:
"""
if not text:
return ''
+ if preserve_space:
+ return text
return re.sub(r'\s+', ' ', text)
+def _preserves_space(elem: ET.Element) -> bool:
+ xml_space = elem.get('{http://www.w3.org/XML/1998/namespace}space') or elem.get('xml:space')
+ return xml_space == 'preserve'
+
+
def _override_run_attrs(
parent_attrs: dict[str, Any],
tspan: ET.Element,
@@ -817,6 +824,7 @@ def _override_run_attrs(
def _collect_tspan_runs(
tspan: ET.Element,
inherited_attrs: dict[str, Any],
+ preserve_space: bool = False,
) -> list[dict[str, Any]]:
"""Recursively turn a tspan subtree into runs, propagating styling through nested tspans.
@@ -824,18 +832,19 @@ def _collect_tspan_runs(
"""
runs: list[dict[str, Any]] = []
own_attrs = _override_run_attrs(inherited_attrs, tspan)
+ child_preserve_space = preserve_space or _preserves_space(tspan)
if tspan.text:
- t = _normalize_text(tspan.text)
+ t = _normalize_text(tspan.text, preserve_space=child_preserve_space)
if t:
runs.append({**own_attrs, 'text': t})
for child in tspan:
child_tag = child.tag.replace(f'{{{SVG_NS}}}', '')
if child_tag == 'tspan':
- runs.extend(_collect_tspan_runs(child, own_attrs))
+ runs.extend(_collect_tspan_runs(child, own_attrs, child_preserve_space))
if child.tail:
- t = _normalize_text(child.tail)
+ t = _normalize_text(child.tail, preserve_space=child_preserve_space)
if t:
runs.append({**own_attrs, 'text': t})
@@ -853,25 +862,25 @@ def _build_text_runs(
inline format changes inside a tspan still produce distinct runs.
"""
runs: list[dict[str, Any]] = []
+ preserve_space = _preserves_space(elem)
if elem.text:
- t = _normalize_text(elem.text)
+ t = _normalize_text(elem.text, preserve_space=preserve_space)
if t:
runs.append({**parent_attrs, 'text': t})
for child in elem:
child_tag = child.tag.replace(f'{{{SVG_NS}}}', '')
if child_tag == 'tspan':
- runs.extend(_collect_tspan_runs(child, parent_attrs))
+ runs.extend(_collect_tspan_runs(child, parent_attrs, preserve_space))
if child.tail:
- t = _normalize_text(child.tail)
+ t = _normalize_text(child.tail, preserve_space=preserve_space)
if t:
runs.append({**parent_attrs, 'text': t})
- # Strip the paragraph's overall leading / trailing whitespace once,
- # while keeping every inline boundary space intact. Per-run normalize
- # deliberately leaves boundary spaces (see `_normalize_text`).
- if runs:
+ # Strip the paragraph's overall leading / trailing whitespace once unless
+ # xml:space="preserve" asks us to keep source indentation.
+ if runs and not preserve_space:
runs[0]['text'] = runs[0]['text'].lstrip(' ')
runs[-1]['text'] = runs[-1]['text'].rstrip(' ')
runs = [r for r in runs if r['text']]
@@ -915,6 +924,8 @@ def _build_run_xml(
alpha_xml = f'<a:alpha val="{int(opacity * 100000)}"/>'
fill_xml = f'<a:solidFill><a:srgbClr val="{fill}">{alpha_xml}</a:srgbClr></a:solidFill>'
+ space_attr = ' xml:space="preserve"' if text != text.strip() or ' ' in text else ''
+
return f'''<a:r>
<a:rPr lang="zh-CN" sz="{sz}"{b_attr}{i_attr}{u_attr}{strike_attr} dirty="0">
{fill_xml}
@@ -923,7 +934,7 @@ def _build_run_xml(
<a:ea typeface="{_xml_escape(fonts['ea'])}"/>
<a:cs typeface="{_xml_escape(fonts['latin'])}"/>
</a:rPr>
-<a:t>{_xml_escape(text)}</a:t>
+<a:t{space_attr}>{_xml_escape(text)}</a:t>
</a:r>'''