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(svg_to_pptx): skip join space at CJK soft-break boundary

hugohe3eb99640e80ea
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 28a55572..c006523c 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_elements.py
@@ -1083,12 +1083,21 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
)
soft_break = child.get('data-paragraph-soft-break') == '1'
if soft_break and paragraph_runs:
- # Append to the previous paragraph. Ensure a space joins the
- # two segments (SVG used a dy line-break, not punctuation).
+ # Append to the previous paragraph. A Latin line-wrap needs a
+ # space to keep two words apart (SVG used a dy break, not
+ # punctuation); CJK wraps mid-sentence with no inter-character
+ # space, so a joining space there is a spurious artifact.
prev = paragraph_runs[-1]
- if prev and not prev[-1]['text'].endswith(' ') \
- and not line_runs[0]['text'].startswith(' '):
- prev[-1] = {**prev[-1], 'text': prev[-1]['text'] + ' '}
+ prev_text = prev[-1]['text'] if prev else ''
+ next_text = line_runs[0]['text']
+ boundary_is_cjk = (
+ (prev_text and is_cjk_char(prev_text[-1]))
+ or (next_text and is_cjk_char(next_text[0]))
+ )
+ if prev and not prev_text.endswith(' ') \
+ and not next_text.startswith(' ') \
+ and not boundary_is_cjk:
+ prev[-1] = {**prev[-1], 'text': prev_text + ' '}
prev.extend(line_runs)
else:
paragraph_runs.append(line_runs)