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(import-sources): decode .txt sources instead of forcing UTF-8
hugohe339b470fe6e80
diff --git a/skills/ppt-master/scripts/project_management/cli.py b/skills/ppt-master/scripts/project_management/cli.pyindex 9f2ac918..f2682141 100644--- a/skills/ppt-master/scripts/project_management/cli.py+++ b/skills/ppt-master/scripts/project_management/cli.py@@ -553,8 +553,25 @@ class ProjectManager:return file_pathdef _normalize_text_source(self, source_path: Path, sources_dir: Path) -> Path:+ from bs4 import UnicodeDammit+target = self._ensure_unique_path(sources_dir / f"{source_path.stem}.md")- content = source_path.read_text(encoding="utf-8", errors="replace")+ # UTF-8 first; a GB18030 / Shift-JIS note used to become U+FFFD silently.+ raw = source_path.read_bytes()+ dammit = UnicodeDammit(raw, user_encodings=["utf-8"])+ content = dammit.unicode_markup+ if content is None:+ content = raw.decode("utf-8", errors="replace")+ if (+ dammit.unicode_markup is None+ or dammit.contains_replacement_characters+ or dammit.original_encoding not in ("utf-8", "ascii")+ ):+ print(+ f"note: {source_path.name} decoded as {dammit.original_encoding or 'utf-8 (lossy)'}; "+ "check the converted text",+ file=sys.stderr,+ )target.write_text(content, encoding="utf-8")return targetdiff --git a/skills/ppt-master/scripts/tests/test_audit_r3_sources.py b/skills/ppt-master/scripts/tests/test_audit_r3_sources.pyindex 1c02319c..1daf8eb5 100644--- a/skills/ppt-master/scripts/tests/test_audit_r3_sources.py+++ b/skills/ppt-master/scripts/tests/test_audit_r3_sources.py@@ -633,6 +633,21 @@ class SameStemProjectImportTests(unittest.TestCase):self.assertIn("22500", Path(summary["markdown"][0]).read_text(encoding="utf-8"))+class TextSourceEncodingTests(unittest.TestCase):+ def test_gb18030_text_source_is_decoded_not_replaced(self) -> None:+ with tempfile.TemporaryDirectory() as tmp:+ root = Path(tmp)+ manager = project_cli.ProjectManager(base_dir=root / "projects")+ with contextlib.redirect_stdout(io.StringIO()):+ project = Path(manager.init_project("target", quick_generate=True))+ source = root / "report.txt"+ source.write_bytes("收入增长和利润说明".encode("gb18030"))+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):+ result = manager.import_sources(str(project), [str(source)], copy=True)+ text = Path(result["markdown"][0]).read_text(encoding="utf-8")+ self.assertIn("收入增长和利润说明", text)++class _CurlHeaders(dict):"""Represent repeated curl headers without importing optional curl_cffi."""