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): recognize single-quoted viewBox attributes

hugohe30edfe9e0ad9b
diff --git a/skills/ppt-master/scripts/project_utils.py b/skills/ppt-master/scripts/project_utils.py
index e514abf0..d8bba432 100644
--- a/skills/ppt-master/scripts/project_utils.py
+++ b/skills/ppt-master/scripts/project_utils.py
@@ -323,7 +323,7 @@ def validate_svg_viewbox(svg_files: List[Path], expected_format: Optional[str] =
List of warnings
"""
warnings = []
- viewbox_pattern = re.compile(r'viewBox="([^"]+)"')
+ viewbox_pattern = re.compile(r'viewBox\s*=\s*["\']([^"\']+)["\']')
viewboxes = set()
# Determine expected viewBox
diff --git a/skills/ppt-master/scripts/svg_position_calculator.py b/skills/ppt-master/scripts/svg_position_calculator.py
index 4caacc89..7278d60c 100644
--- a/skills/ppt-master/scripts/svg_position_calculator.py
+++ b/skills/ppt-master/scripts/svg_position_calculator.py
@@ -1007,7 +1007,7 @@ def analyze_svg_file(svg_file: str) -> None:
print(f"{'='*70}")
# Extract viewBox
- viewbox_match = re.search(r'viewBox="([^"]+)"', content)
+ viewbox_match = re.search(r'viewBox\s*=\s*["\']([^"\']+)["\']', content)
if viewbox_match:
print(f"Canvas viewBox: {viewbox_match.group(1)}")
diff --git a/skills/ppt-master/scripts/svg_quality_checker.py b/skills/ppt-master/scripts/svg_quality_checker.py
index 8d174eb9..fa65a231 100644
--- a/skills/ppt-master/scripts/svg_quality_checker.py
+++ b/skills/ppt-master/scripts/svg_quality_checker.py
@@ -376,7 +376,7 @@ class SVGQualityChecker:
def _check_viewbox(self, content: str, result: Dict, expected_format: str = None):
"""Check viewBox attribute"""
- viewbox_match = re.search(r'viewBox="([^"]+)"', content)
+ viewbox_match = re.search(r'viewBox\s*=\s*["\']([^"\']+)["\']', content)
if not viewbox_match:
result['errors'].append("Missing viewBox attribute")
@@ -1563,11 +1563,14 @@ class SVGQualityChecker:
@staticmethod
def _parse_svg_viewbox(content: str) -> Tuple[float, float] | None:
"""Return viewBox width/height from SVG content."""
- match = re.search(r'viewBox="[^"]*?\s+([0-9.]+)\s+([0-9.]+)"', content)
+ match = re.search(r'viewBox\s*=\s*["\']([^"\']+)["\']', content)
if not match:
return None
+ parts = re.split(r'[\s,]+', match.group(1).strip())
+ if len(parts) < 4:
+ return None
try:
- return float(match.group(1)), float(match.group(2))
+ return float(parts[2]), float(parts[3])
except ValueError:
return None
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_dimensions.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_dimensions.py
index 75f9ac18..7fe0f989 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_dimensions.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_dimensions.py
@@ -106,7 +106,7 @@ def get_viewbox_dimensions(svg_path: Path) -> tuple[int, int] | None:
with open(svg_path, 'r', encoding='utf-8') as f:
content = f.read(2000)
- match = re.search(r'viewBox="([^"]+)"', content)
+ match = re.search(r'viewBox\s*=\s*["\']([^"\']+)["\']', content)
if not match:
return None
@@ -137,7 +137,7 @@ def detect_format_from_svg(svg_path: Path) -> str | None:
with open(svg_path, 'r', encoding='utf-8') as f:
content = f.read(2000)
- match = re.search(r'viewBox="([^"]+)"', content)
+ match = re.search(r'viewBox\s*=\s*["\']([^"\']+)["\']', content)
if match:
viewbox = match.group(1)
for fmt_key, fmt_info in CANVAS_FORMATS.items():