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: web fetch keeps the declared charset under a lossy decode and warns on a sliver body; single-input -o prints its file naming; carrier receipt counts relationship pages; unresolved-geometry warning names the tspan rule

hugohe395e3c41b1c12
diff --git a/skills/ppt-master/scripts/source_to_md.py b/skills/ppt-master/scripts/source_to_md.py
index e8012746..0eb081fc 100644
--- a/skills/ppt-master/scripts/source_to_md.py
+++ b/skills/ppt-master/scripts/source_to_md.py
@@ -108,6 +108,11 @@ def _dispatch_output_arg(
# directory: `-o sources_cf` writes `sources_cf.md` (a directory is
# spelled with a trailing separator or already exists).
if not Path(output_arg).suffix:
+ _print_status(
+ f"[INFO] -o names the Markdown file for a single input: writing "
+ f"{output_arg}.md (spell a directory with a trailing separator, "
+ "or create it first)"
+ )
return f"{output_arg}.md"
return output_arg
return None
diff --git a/skills/ppt-master/scripts/source_to_md/web_to_md.py b/skills/ppt-master/scripts/source_to_md/web_to_md.py
index 200c1c21..3d685a2f 100644
--- a/skills/ppt-master/scripts/source_to_md/web_to_md.py
+++ b/skills/ppt-master/scripts/source_to_md/web_to_md.py
@@ -258,6 +258,37 @@ def _charset_from_html(raw: bytes) -> str:
return ""
+BODY_SHORTFALL_MIN_CHARS = 200
+BODY_SHORTFALL_RATIO = 0.25
+
+
+def _page_visible_text(soup) -> str:
+ """Return the page's rendered text with scripts, styles, and noscript removed."""
+ for node in soup(["script", "style", "noscript", "template"]):
+ node.decompose()
+ return re.sub(r"\s+", " ", soup.get_text(" ")).strip()
+
+
+def _body_shortfall_warning(markdown_text: str, page_text: str) -> str | None:
+ """Warn when the extracted body is a sliver of the text the page shows.
+
+ A content container that the extractor did not recognise yields a short,
+ plausible-looking Markdown file; comparing it against the page's visible
+ text turns that silent loss into a warning the caller can act on.
+ """
+ body_chars = len(re.sub(r"\s+", "", markdown_text))
+ page_chars = len(re.sub(r"\s+", "", page_text))
+ if body_chars >= BODY_SHORTFALL_MIN_CHARS or page_chars < BODY_SHORTFALL_MIN_CHARS * 2:
+ return None
+ if body_chars > page_chars * BODY_SHORTFALL_RATIO:
+ return None
+ return (
+ f"body extraction kept {body_chars} characters while the page shows "
+ f"{page_chars}; the content container was not recognised, so verify "
+ "the Markdown against the page before using it as a source"
+ )
+
+
def _decode_quality_score(text: str) -> int:
"""Score obvious decode artifacts; lower is better."""
mojibake_markers = [
@@ -311,6 +342,19 @@ def _decode_response_text(response) -> str:
decoded.sort(key=lambda item: item[0])
return decoded[0][2]
+ # Every strict decode failed: the page carries a few bad bytes. Keep the
+ # declared charset in the running instead of dropping to UTF-8, and let
+ # the artifact score pick the lossy decode that damages the least text.
+ lossy = []
+ for enc in declared + [enc for enc in candidates if enc not in declared]:
+ try:
+ text = raw.decode(enc, errors="replace")
+ except LookupError:
+ continue
+ lossy.append((_decode_quality_score(text), enc, text))
+ if lossy:
+ lossy.sort(key=lambda item: item[0])
+ return lossy[0][2]
return raw.decode("utf-8", errors="replace")
try:
@@ -1255,6 +1299,11 @@ def process_url(
"no readable body text extracted; the page may render its "
"content with scripts or link to it elsewhere")
print(f" [WARN] {warnings[0]}")
+ else:
+ shortfall = _body_shortfall_warning(markdown_text, _page_visible_text(soup))
+ if shortfall:
+ warnings.append(shortfall)
+ print(f" [WARN] {shortfall}")
# Construct content
final_output = []
diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.py
index 5c9cad32..24701051 100644
--- a/skills/ppt-master/scripts/svg_quality/checker.py
+++ b/skills/ppt-master/scripts/svg_quality/checker.py
@@ -393,6 +393,24 @@ HEX_VALUE_RE = re.compile(
# fail closed; Create Template must author a new current-contract workspace.
_CHECK_PPTX_STRUCTURED_PROJECT = True
+_SPEC_RELATIONSHIPS_LINE_RE = re.compile(
+ r'^\s*-\s*\*\*Relationships(?:\s*\([^)]*\))?\*\*\s*[::]\s*(?P<value>.*)$'
+)
+_CARRIED_RELATION_WORD_RE = re.compile(
+ r'\b(?:order|link|parent|membership)\b', re.IGNORECASE
+)
+
+
+def count_carried_relationship_pages(design_spec_text: str) -> int:
+ """Count §IX ``Relationships`` lines naming order, link, parent, or membership."""
+ count = 0
+ for line in design_spec_text.splitlines():
+ match = _SPEC_RELATIONSHIPS_LINE_RE.match(line)
+ if match and _CARRIED_RELATION_WORD_RE.search(match.group('value')):
+ count += 1
+ return count
+
+
_BARE_HEX_VALUE_RE = re.compile(
r"(?:[0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})"
)
@@ -4520,7 +4538,9 @@ class SVGQualityChecker:
result['warnings'].append(
'Cannot verify root viewBox bounds for visible text with '
f'unsupported or unresolved geometry: {sample}{suffix}; use '
- 'supported explicit text positioning when page fit matters'
+ 'supported explicit text positioning when page fit matters '
+ '(continuation <tspan> lines repeat the parent x; a hanging '
+ 'indent needs its own <text>)'
)
root_groups = [
@@ -9253,12 +9273,38 @@ class SVGQualityChecker:
'pages': len(receipts),
'totals': dict(totals),
'pages_with': dict(pages_with),
+ 'relationship_pages': self._relationship_page_count(),
'geometry_elements': dict(sorted(geometry_counts.items())),
'preset_names': dict(sorted(preset_names.items())),
'native_objects': dict(sorted(native_objects.items())),
'image_page_max_frame_share_range': frame_share_range,
}
+ def _relationship_page_count(self) -> int | None:
+ """Count design_spec §IX pages whose Relationships line names a carried relation.
+
+ The executor's receipt review compares pages carrying a preset or
+ connector against pages whose ``Relationships`` line names ``order``,
+ ``link``, ``parent``, or ``membership``; this reads that count from the
+ project's ``design_spec.md`` so the comparison is on the receipt. None
+ when no exact ``design_spec.md`` is present (Quick, templates).
+ """
+ paths = [
+ Path(result['path'])
+ for result in self.results
+ if result.get('path') and result.get('info', {}).get('carrier_receipt')
+ ]
+ if not paths:
+ return None
+ spec_path = self._resolve_project_path(paths[0]) / 'design_spec.md'
+ if not spec_path.is_file():
+ return None
+ try:
+ text = spec_path.read_text(encoding='utf-8')
+ except OSError:
+ return None
+ return count_carried_relationship_pages(text)
+
def _print_carrier_receipt_summary(self) -> None:
"""Print a compact actual-use receipt without a score or threshold."""
if self.template_mode:
@@ -9302,6 +9348,16 @@ class SVGQualityChecker:
else '(none)'
)
print(f" Presets: {preset_text}")
+ relationship_pages = receipt.get('relationship_pages')
+ preset_pages = pages_with['presets']
+ if relationship_pages is None:
+ print(f" Pages carrying a preset or connector: {preset_pages}")
+ else:
+ print(
+ f" Relationship pages: {relationship_pages} "
+ "(§IX names order / link / parent / membership) | "
+ f"pages carrying a preset or connector: {preset_pages}"
+ )
image_range = receipt['image_page_max_frame_share_range']
if image_range:
print(
diff --git a/skills/ppt-master/scripts/tests/test_dogfood_sparse_fixes.py b/skills/ppt-master/scripts/tests/test_dogfood_sparse_fixes.py
new file mode 100644
index 00000000..d7f9bb6e
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_dogfood_sparse_fixes.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+"""Regression tests for the 2026-09-12 sparse-input dogfood fixes.
+
+Web pages that declare a charset but carry a few bad bytes keep that charset
+under a lossy decode; a body extraction that keeps a sliver of the page warns;
+and the carrier receipt counts design_spec §IX pages naming carried relations.
+"""
+
+from __future__ import annotations
+
+import sys
+import unittest
+from pathlib import Path
+from types import SimpleNamespace
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+BACKEND_DIR = SCRIPTS_DIR / "source_to_md"
+if str(BACKEND_DIR) not in sys.path:
+ sys.path.insert(0, str(BACKEND_DIR))
+
+import web_to_md # noqa: E402
+from svg_quality.checker import count_carried_relationship_pages # noqa: E402
+
+
+def _response(raw: bytes, content_type: str = "text/html") -> SimpleNamespace:
+ return SimpleNamespace(
+ content=raw,
+ headers={"Content-Type": content_type},
+ encoding=None,
+ apparent_encoding=None,
+ )
+
+
+class DeclaredCharsetLossyDecodeTests(unittest.TestCase):
+ def test_declared_gb2312_survives_a_bad_byte(self) -> None:
+ html = (
+ '<html><head><meta charset="gb2312"><title>都江堰水利工程</title></head>'
+ "<body><p>秦昭襄王五十一年,李冰主持修建都江堰。</p></body></html>"
+ )
+ raw = html.encode("gb2312") + b"\x81\x00" + "<p>尾声</p>".encode("gb2312")
+ with self.assertRaises(UnicodeDecodeError):
+ raw.decode("gb18030")
+ text = web_to_md._decode_response_text(_response(raw))
+ self.assertIn("都江堰水利工程", text)
+ self.assertIn("李冰主持修建都江堰", text)
+ self.assertIn("尾声", text)
+ self.assertLess(text.count("�"), 3)
+
+ def test_clean_declared_charset_is_still_strict(self) -> None:
+ raw = "<meta charset=\"utf-8\"><p>Café</p>".encode("utf-8")
+ self.assertEqual(web_to_md._decode_response_text(_response(raw)), raw.decode("utf-8"))
+
+
+class BodyShortfallWarningTests(unittest.TestCase):
+ def test_sliver_of_a_long_page_warns(self) -> None:
+ page = "正文" * 1200
+ warning = web_to_md._body_shortfall_warning("> 官方栏目", page)
+ self.assertIsNotNone(warning)
+ self.assertIn("content container was not recognised", warning)
+
+ def test_short_pages_and_full_extractions_stay_quiet(self) -> None:
+ self.assertIsNone(web_to_md._body_shortfall_warning("> 官方栏目", "栏目" * 50))
+ page = "正文" * 1200
+ self.assertIsNone(web_to_md._body_shortfall_warning(page[: len(page) // 2], page))
+
+
+class RelationshipPageCountTests(unittest.TestCase):
+ def test_counts_only_carried_relations(self) -> None:
+ spec = "\n".join([
+ "- **Relationships**: 六个年度值之间是 order(时间顺序)",
+ "- **Relationships**: none",
+ "- **Relationships**: 两条曲线之间是 contrast",
+ "- **Relationships (binding)**: 国家铁路与其他铁路是 membership",
+ "- **Relationships**:照片与数字之间是 link",
+ "- **Audience move**: order of appearance is not a relationship line",
+ ])
+ self.assertEqual(count_carried_relationship_pages(spec), 3)
+
+ def test_no_lines_means_zero(self) -> None:
+ self.assertEqual(count_carried_relationship_pages("# nothing here\n"), 0)