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: warn on scanned PDFs; keep clause numbers as text; init honours a pinned name; calibrate notes match CJK behaviour

hugohe36c372a292f1d
diff --git a/skills/ppt-master/scripts/docs/native-data.md b/skills/ppt-master/scripts/docs/native-data.md
index 1b02c88a..b50b9393 100644
--- a/skills/ppt-master/scripts/docs/native-data.md
+++ b/skills/ppt-master/scripts/docs/native-data.md
@@ -21,7 +21,7 @@ one child `<metadata type="application/json">` (attribute `data-pptx-json` is re
Every payload carries that exact `schema`. Native tables are rectangular grids: `columns` for the optional header row, `rows` for body rows (shorter rows padded unless `strict_grid: true`; at most 1000 resolved rows and columns); `column_widths` / `row_heights` are finite non-negative relative weights matching the grid with one positive value (`row_heights` counts the header row when `columns` is present) (a row's top and bottom padding shrink to what its resolved height can hold beside the text line, since PowerPoint would otherwise grow the row past the drawn one); `header_rows` is an integer in range; `strict_grid`, `style.band_row`, and `bold` are JSON booleans. Exact repetition may be factored into `defaults.cell` / `defaults.paragraph` / `defaults.run` and kebab-case `cell_styles` selected by `cell_style` (precedence: cell defaults → named style → cell fields; object-valued `padding` merges, everything else replaces; `<style>` and `class` remain forbidden).
-Cells accept `text`, `fill`, `fill_opacity`, `color`, `align`. (SVG-first parity compares a cell against the fallback `<text>` with its `<tspan>` lines concatenated, so a wrapped cell keeps a trailing space inside every non-final `<tspan>` or the joined words never match.) Cells also take (`l` / `ctr` / `r`; header cells export centred unless `align` is set, so SVG-first parity reports a left- or right-anchored fallback header whose payload leaves `align` unset), `valign` (`top` / `middle` / `bottom`), `bold`, `font_size`, `padding` and side-specific `padding_*`, `border_color`, `border_width`, `borders`, `lang`, `anchor_center`, `horizontal_overflow`. Multi-paragraph text replaces `text` with a non-empty `paragraphs` list of strings or objects — empty paragraph strings are preserved as blank lines — (`align` plus exactly one of `text` or non-empty `runs`; runs carry required `text` and optional `bold`, `italic`, `underline`, `strike`, `color`, `font_size`, one-typeface `font_family`, `lang`, `alt_lang`); unknown fields, wrong types, empty runs, multi-typeface families, and unsupported colors fail. Per-side borders use `borders.left|right|top|bottom|diagonal_down|diagonal_up` as `{ "style": "none" }` or `{ "style": "solid", "color": "#RRGGBB", "width": <positive-px> }`, overriding a uniform `border_color` / `border_width` on style or cell. A missing `lang` derives `zh-CN` for CJK and `en-US` otherwise. `style.band_row: false` disables banding and materialized alternating fills. Typography mirrors the fallback: `style.font_family` and `style.font_size` from the drawn table text, `style.header_font_size` or per-cell `font_size` only where the fallback differs; with no explicit table font, Default uses the deck body family and anchor, Quick its active-context values.
+Cells accept `text`, `fill`, `fill_opacity`, `color`, `align`; no cell-level `font_family` — the face is table-wide through `style.font_family`, so a column set in another face in the fallback falls back to the table face when replaced. (SVG-first parity compares a cell against the fallback `<text>` with its `<tspan>` lines concatenated, so a wrapped cell keeps a trailing space inside every non-final `<tspan>` or the joined words never match.) Cells also take (`l` / `ctr` / `r`; header cells export centred unless `align` is set, so SVG-first parity reports a left- or right-anchored fallback header whose payload leaves `align` unset), `valign` (`top` / `middle` / `bottom`), `bold`, `font_size`, `padding` and side-specific `padding_*`, `border_color`, `border_width`, `borders`, `lang`, `anchor_center`, `horizontal_overflow`. Multi-paragraph text replaces `text` with a non-empty `paragraphs` list of strings or objects — empty paragraph strings are preserved as blank lines — (`align` plus exactly one of `text` or non-empty `runs`; runs carry required `text` and optional `bold`, `italic`, `underline`, `strike`, `color`, `font_size`, one-typeface `font_family`, `lang`, `alt_lang`); unknown fields, wrong types, empty runs, multi-typeface families, and unsupported colors fail. Per-side borders use `borders.left|right|top|bottom|diagonal_down|diagonal_up` as `{ "style": "none" }` or `{ "style": "solid", "color": "#RRGGBB", "width": <positive-px> }`, overriding a uniform `border_color` / `border_width` on style or cell. A missing `lang` derives `zh-CN` for CJK and `en-US` otherwise. `style.band_row: false` disables banding and materialized alternating fills. Typography mirrors the fallback: `style.font_family` and `style.font_size` from the drawn table text, `style.header_font_size` or per-cell `font_size` only where the fallback differs; with no explicit table font, Default uses the deck body family and anchor, Quick its active-context values.
`style` accepts `font_family`, `font_size`, `header_font_size`, `band_row`, `padding`, `valign`, `border_color`, `border_width`, `lang`, `table_style_id`, and the table-wide colours `header_fill`, `header_text`, `body_fill`, `body_text`, `band_fill`. SVG-first parity reads a header band drawn as one rect spanning the header rows as `style.header_fill` unless every header cell carries that same `fill` (and the dominant header text colour as `style.header_text` unless every header cell carries it), so a drawn band is projected at table level rather than repeated per cell. Fills are only what the payload resolves: a cell with no `fill` takes `style.header_fill` (header rows) or `style.band_fill` / `style.body_fill` (body rows), and when none of those is set it exports as `noFill` so the slide background shows through — the same as a fallback that draws no cell rect. Text colour never falls to nothing: a cell without `color` takes `defaults.run.color` (plain text is one run, and a `paragraphs` cell whose paragraphs are strings or `text` objects inherits the same way at cell level, so `defaults.run` `bold` / `color` / `font_size` reach both when the cell and `defaults.cell` leave them unset; `paragraphs[].runs` take the run defaults directly), then `style.body_text` / `style.header_text`, then `#1F2937` (`header_text` defaults to `#FFFFFF` only when `header_fill` is set). SVG-first parity reports a body text colour drawn in the fallback that none of those layers would carry, and a first-column colour that neither the cell nor `style.body_text` resolves to.
diff --git a/skills/ppt-master/scripts/project_management/cli.py b/skills/ppt-master/scripts/project_management/cli.py
index 51e3225c..be7e285d 100644
--- a/skills/ppt-master/scripts/project_management/cli.py
+++ b/skills/ppt-master/scripts/project_management/cli.py
@@ -105,6 +105,25 @@ DEFERRED_CANVAS_MESSAGE = (
)
+def _is_project_tree(source_path: Path) -> bool:
+ """Return whether a file under projects/ sits inside an initialized project.
+
+ A sibling directory such as ``projects/<slug>_web_sources/`` (topic-research
+ output) is scratch material, not another project's tree.
+ """
+ try:
+ relative = source_path.resolve().relative_to(PROJECTS_ROOT.resolve())
+ except ValueError:
+ return False
+ if not relative.parts:
+ return False
+ root = PROJECTS_ROOT.resolve() / relative.parts[0]
+ return any(
+ (root / marker).exists()
+ for marker in ("svg_output", "design_spec.md", "spec_lock.md", "README.md")
+ )
+
+
def _validate_image_manifest(
payload: object,
path: Path,
@@ -281,7 +300,9 @@ class ProjectManager:
# full project dir name pasted back into init) is used as-is —
# re-appending would produce
# `name_ppt169_20260101_ppt169_20260102`.
- if re.search(rf"_{re.escape(normalized_format)}_\d{{8}}$", project_name):
+ if re.search(r"_\d{8}$", project_name):
+ # `_<format>_<YYYYMMDD>` or a plain `_<YYYYMMDD>`: the caller
+ # pinned the directory name; --format still sets the canvas.
project_dir_name = project_name
else:
project_dir_name = f"{project_name}_{normalized_format}_{date_str}"
@@ -865,6 +886,7 @@ class ProjectManager:
inside_projects
and not is_within_path(source_path, project_dir.resolve())
and source_path.resolve().parent != PROJECTS_ROOT.resolve()
+ and _is_project_tree(source_path)
)
if copy:
effective_move = False
@@ -1125,7 +1147,12 @@ def build_parser() -> argparse.ArgumentParser:
subparsers = parser.add_subparsers(dest="command", required=True)
init = subparsers.add_parser("init", help="Create a project directory")
- init.add_argument("project_name", help="Project name")
+ init.add_argument(
+ "project_name",
+ help="Project name; the directory becomes <name>_<YYYYMMDD>, or "
+ "<name>_<format>_<YYYYMMDD> with --format. A name already ending "
+ "in _<YYYYMMDD> is used as-is.",
+ )
init.add_argument(
"--format",
default=None,
diff --git a/skills/ppt-master/scripts/source_to_md/pdf_to_md.py b/skills/ppt-master/scripts/source_to_md/pdf_to_md.py
index 5a705e13..4ce7b74a 100644
--- a/skills/ppt-master/scripts/source_to_md/pdf_to_md.py
+++ b/skills/ppt-master/scripts/source_to_md/pdf_to_md.py
@@ -199,6 +199,37 @@ def is_bullet_glyph_span(text: str) -> bool:
return len(stripped) == 1 and stripped in _BULLET_GLYPHS
+# Below this many extracted text characters per page the PDF has no usable
+# text layer; a scan renders as one image per page and nothing else.
+SCANNED_PDF_TEXT_CHARS_PER_PAGE = 40
+
+
+def scanned_pdf_warnings(markdown: str, page_count: int, image_count: int) -> list[str]:
+ """Return a warning when the Markdown holds page images but almost no text.
+
+ ``[Done] Success`` with an empty Markdown body is worse than a failure:
+ a downstream reader takes the file as the converted source and concludes
+ the document has no usable content. The check counts text outside image
+ references and page comments against the page count.
+ """
+ if page_count <= 0:
+ return []
+ text_lines = [
+ line for line in markdown.splitlines()
+ if line.strip() and not line.lstrip().startswith(("![", "<!--"))
+ ]
+ text_chars = sum(len(line.strip()) for line in text_lines)
+ if text_chars >= SCANNED_PDF_TEXT_CHARS_PER_PAGE * page_count:
+ return []
+ if image_count < max(1, page_count // 2):
+ return []
+ return [
+ f"scanned PDF: {text_chars} text characters over {page_count} pages, "
+ f"{image_count} page images; no text layer was extracted, so the "
+ "clauses exist only inside the images (OCR or a text-layer copy is needed)"
+ ]
+
+
def detect_list_item(text: str) -> tuple:
"""Detect if the text is a list item. Returns (is_list, list_type, content)."""
text = text.strip()
@@ -214,8 +245,11 @@ def detect_list_item(text: str) -> tuple:
return (True, 'ul', marker + ' ' + text[match.end():])
# ``83.2%`` at the start of a line is a decimal, not item 83: after a
- # dot the marker must not be followed by another digit.
- ol_pattern = r'^(\d+)(?:[、)]|\.(?!\d))\s*'
+ # dot the marker must not be followed by another digit. ``1. 1 职业名称``
+ # (a clause number set with a space, as Chinese standards do) is a
+ # heading path, not item 1 with the text "1 职业名称": a short digit group
+ # right after the marker, followed by a space or CJK, keeps the line as is.
+ ol_pattern = r'^(\d+)(?:[、)]|\.(?!\d)(?!\s*\d{1,2}(?:\.\s*\d+)*[\s\u4e00-\u9fff]))\s*'
match = re.match(ol_pattern, text)
if match:
num = match.group(1)
@@ -1747,6 +1781,7 @@ def extract_pdf_to_markdown(
if prev_was_code:
flush_code_block()
+ page_count = len(doc)
doc.close()
markdown_content = merge_markdown_continuation_tables(markdown_content)
@@ -1763,12 +1798,16 @@ def extract_pdf_to_markdown(
json.dumps(image_manifest, ensure_ascii=False, indent=2) + "\n",
encoding="utf-8",
)
+ warnings = scanned_pdf_warnings(markdown_content, page_count, img_count)
+ for warning in warnings:
+ print(f"[WARN] {warning}")
profile_path = write_conversion_profile_best_effort(
input_path=pdf_path,
markdown_path=output_path,
converter="pdf_to_md.py",
conversion_type="pdf",
asset_dir=img_dir,
+ warnings=warnings,
)
print(f"[OK] Saved Markdown to: {output_path}")
if profile_path:
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 2c85e5b8..5577dccc 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
@@ -317,8 +317,8 @@ def sanitize_filename(name: str) -> str:
"""Sanitize a string for filesystem-safe filenames."""
# Replace whitespace with underscore first
clean = re.sub(r'\s+', '_', name)
- # Remove all except Chinese, English, Numbers, Underscore
- clean = re.sub(r'[^\u4e00-\u9fa5a-zA-Z0-9_]', '', clean)
+ # Remove all except Chinese, English, Numbers, Underscore, Hyphen
+ clean = re.sub(r'[^\u4e00-\u9fa5a-zA-Z0-9_-]', '', clean)
# Collapse repeating underscores
clean = re.sub(r'_+', '_', clean)
return clean[:80] # Truncate
diff --git a/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py b/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py
index 3fa2c7fd..c1a45882 100644
--- a/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py
+++ b/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python3
-"""Regression tests for the fixes reported by the Why Leaves Turn dogfood run.
+"""Regression tests for fixes reported by the September 2026 dogfood runs.
Document URLs route to their own converter, bullet glyphs never promote a PDF
-line to a heading, ``<polygon>`` carries a filter, and the exported slide size
-type token follows the canvas.
+line to a heading, clause numbers stay text, a scanned PDF warns, ``<polygon>``
+carries a filter, the exported slide size type token follows the canvas, and
+``init`` keeps a pinned directory name.
"""
from __future__ import annotations
@@ -26,6 +27,7 @@ import web_to_md # noqa: E402
from svg_to_pptx.drawingml.converter import convert_svg_to_slide_shapes # noqa: E402
from svg_to_pptx.drawingml.utils import project_filter_errors # noqa: E402
from svg_to_pptx.pptx_package.builder import _slide_size_type # noqa: E402
+from project_management.cli import _is_project_tree, PROJECTS_ROOT # noqa: E402
PDF_URL = "https://www.example.gov/content/pkg/report/pdf/report.pdf"
@@ -86,6 +88,48 @@ class PdfBulletTests(unittest.TestCase):
self.assertFalse(pdf_to_md.is_bullet_glyph_span("· Oaks"))
+class PdfClauseAndScanTests(unittest.TestCase):
+ def test_spaced_clause_number_is_not_a_list(self) -> None:
+ self.assertFalse(pdf_to_md.detect_list_item("1. 1 职业名称")[0])
+ self.assertFalse(pdf_to_md.detect_list_item("2. 1. 1 职业道德基本知识")[0])
+
+ def test_ordinary_ordered_items_still_match(self) -> None:
+ self.assertEqual(pdf_to_md.detect_list_item("1. 职业概况"), (True, "ol", "1. 职业概况"))
+ self.assertEqual(pdf_to_md.detect_list_item("3. Overview"), (True, "ol", "3. Overview"))
+ self.assertEqual(pdf_to_md.detect_list_item("1. 2024年营收"), (True, "ol", "1. 2024年营收"))
+ self.assertFalse(pdf_to_md.detect_list_item("83.2% of respondents")[0])
+
+ def test_scanned_pdf_warns(self) -> None:
+ markdown = "\n".join(
+ f"<!-- Page {i} -->\n![page {i}](scan_files/page_{i}.jpg)" for i in range(1, 14))
+ warnings = pdf_to_md.scanned_pdf_warnings(markdown, 13, 13)
+ self.assertEqual(len(warnings), 1)
+ self.assertIn("13 page images", warnings[0])
+
+ def test_text_pdf_does_not_warn(self) -> None:
+ markdown = "\n".join("第一章 总则 " * 20 for _ in range(13))
+ self.assertEqual(pdf_to_md.scanned_pdf_warnings(markdown, 13, 2), [])
+
+
+class ImportSourcesProjectTreeTests(unittest.TestCase):
+ def test_research_web_sources_dir_is_not_a_project(self) -> None:
+ with tempfile.TemporaryDirectory(dir=PROJECTS_ROOT) as tmp:
+ root = Path(tmp)
+ scratch = root.with_name(root.name + "_web_sources")
+ scratch.mkdir()
+ try:
+ (scratch / "page.md").write_text("# page\n", encoding="utf-8")
+ self.assertFalse(_is_project_tree(scratch / "page.md"))
+ (root / "svg_output").mkdir()
+ (root / "sources").mkdir()
+ (root / "sources" / "a.md").write_text("# a\n", encoding="utf-8")
+ self.assertTrue(_is_project_tree(root / "sources" / "a.md"))
+ finally:
+ for child in scratch.iterdir():
+ child.unlink()
+ scratch.rmdir()
+
+
class PolygonFilterTests(unittest.TestCase):
SVG = (
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720">'
diff --git a/skills/ppt-master/scripts/text_measure.py b/skills/ppt-master/scripts/text_measure.py
index 1e9b2acf..28dd236d 100644
--- a/skills/ppt-master/scripts/text_measure.py
+++ b/skills/ppt-master/scripts/text_measure.py
@@ -674,8 +674,9 @@ def _run_calibrate(args: argparse.Namespace) -> int:
'rates for ' + ', '.join(bold_roles) + ' are measured at bold weight'
if bold_roles else
'every role is measured at normal weight; recalibrate a role '
- 'realized as bold deck-wide with --role NAME:FAMILY:SIZE:bold, '
- 'since bold runs about 7% wider'
+ 'realized as bold deck-wide with --role NAME:FAMILY:SIZE:bold: '
+ 'bold widens Latin and digits about 7%, while the bundled advance '
+ 'table gives CJK one width for both weights'
)
output_path = project_path / 'validation' / 'text_calibration.json'
output_path.parent.mkdir(parents=True, exist_ok=True)
@@ -753,8 +754,9 @@ def build_parser() -> argparse.ArgumentParser:
type=_role_argument,
default=[],
metavar='NAME:FAMILY:SIZE[:bold]',
- help='Typography role to calibrate when spec_lock.md is absent, e.g. '
- 'body:"Microsoft YaHei":20; repeatable.',
+ help='Typography role to calibrate, e.g. body:"Microsoft YaHei":20; '
+ 'repeatable. Adds or overrides that role whether or not '
+ 'spec_lock.md exists (FAMILY replaces the role\'s font stack).',
)
calibrate.add_argument('--json', action='store_true')
for command in (measure, wrap, box):