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(tools): 增强备注拆分逻辑,支持多种格式的页码前缀 (如 Slide 1, 第1页)

hugohe38659238fab72
diff --git a/tools/total_md_split.py b/tools/total_md_split.py
index 6aa8dc05..3532b19d 100644
--- a/tools/total_md_split.py
+++ b/tools/total_md_split.py
@@ -44,17 +44,34 @@ def normalize_title(title: str) -> str:
return text.lower()
+
+
+
def extract_leading_number(text: str) -> Optional[int]:
"""Extract leading slide number if present."""
if not text:
return None
+
+ # Try 1: Start with digits (standard)
m = re.match(r'^(\d{1,3})', text.strip())
- if not m:
- return None
- try:
+ if m:
return int(m.group(1))
- except ValueError:
- return None
+
+ # Try 2: Common prefixes (Slide X, Page X, 第X页)
+ # Case insensitive for English
+ text_lower = text.lower().strip()
+
+ # Slide/Page X
+ m = re.match(r'^(?:slide|page|p)\s*[-_:]?\s*(\d{1,3})', text_lower)
+ if m:
+ return int(m.group(1))
+
+ # 第X页/张
+ m = re.match(r'^第\s*(\d{1,3})\s*[页张]', text_lower)
+ if m:
+ return int(m.group(1))
+
+ return None
def build_match_maps(svg_stems: List[str]) -> Tuple[set, Dict[str, List[str]], Dict[int, List[str]]]: