nomadro/apps/miniprogram/weapp/scripts/_analyze_info_md.py
eric 3e5b7c2098 Monorepo super-optimize: src layout, workspace scripts, docs.
Collapse portal under src/, unify pnpm workspace/scripts, thin VIP topic re-exports, drop orphan vip scaffolds and one-shot scripts, ignore xhs/release, document root commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-01 00:34:04 +08:00

22 lines
836 B
Python

"""Analyze info.md image URLs and headings."""
import re
from pathlib import Path
p = Path(__file__).resolve().parent / "_hackrobot_book" / "info.md"
text = p.read_text(encoding="utf-8")
urls = set()
for m in re.finditer(r"!\[[^\]]*\]\((https?://[^)\s]+)\)", text):
urls.add(m.group(1))
for m in re.finditer(r"""<img[^>]+src=["'](https?://[^"']+)["']""", text, re.I):
urls.add(m.group(1))
print("unique_http_imgs", len(urls))
cdn = [u for u in urls if any(x in u for x in ("minioweb", "hackrobot", "myqcloud", "cos."))]
print("cdn_like", len(cdn))
Path(__file__).resolve().parent.joinpath("_hackrobot_book", "image_urls.txt").write_text(
"\n".join(sorted(urls)), encoding="utf-8"
)
heads = re.findall(r"^(#{1,2})\s+(.+)$", text, re.M)
print("h1_h2", len(heads))
for level, title in heads[:40]:
print(level, title[:80])