机械原理前四章重写为在学练习模式(20-23:盘点+点文件+速查卡+旧版快照);新增803真正的考点大纲与重写规范;同步14-16章修改

This commit is contained in:
2026-10-28 22:39:30 +08:00
parent 224dd91a85
commit 08c43ddc10
66 changed files with 5099 additions and 14 deletions
+26
View File
@@ -0,0 +1,26 @@
param(
[Parameter(Mandatory=$true)][string]$Src,
[Parameter(Mandatory=$true)][string]$Out
)
# Convert .ppt (legacy) to .pptx via PowerPoint COM, then quit.
# Usage: powershell -File convert_ppt.ps1 -Src "D:\...\xxx.ppt" -Out "D:\...\xxx.pptx"
# Never modifies the source file (opened ReadOnly). Output format 24 = ppSaveAsOpenXMLPresentation.
$ErrorActionPreference = 'Stop'
$ppt = $null
$pres = $null
try {
$ppt = New-Object -ComObject PowerPoint.Application
$pres = $ppt.Presentations.Open($Src, $true, $false, $false)
$pres.SaveAs($Out, 24)
$pres.Close()
Write-Output ("OK: " + $Out)
} catch {
Write-Error ("Convert failed: " + $_.Exception.Message)
exit 1
} finally {
if ($null -ne $pres) { try { $pres.Close() } catch {} }
if ($null -ne $ppt) { try { $ppt.Quit() } catch {} }
if ($null -ne $pres) { try { [void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($pres) } catch {} }
if ($null -ne $ppt) { try { [void][System.Runtime.InteropServices.Marshal]::ReleaseComObject($ppt) } catch {} }
[GC]::Collect(); [GC]::WaitForPendingFinalizers()
}
+44
View File
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
"""Extract all text (text frames + tables, incl. group shapes) from a .pptx into a UTF-8 txt.
Usage: python extract_pptx.py <input.pptx> <output.txt>
"""
import sys
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE
def iter_shapes(shapes):
for sh in shapes:
yield sh
if sh.shape_type == MSO_SHAPE_TYPE.GROUP:
try:
yield from iter_shapes(sh.shapes)
except Exception:
pass
def main(src, out):
prs = Presentation(src)
lines = []
for idx, slide in enumerate(prs.slides, 1):
lines.append("")
lines.append("===== SLIDE %d =====" % idx)
for sh in iter_shapes(slide.shapes):
if sh.has_text_frame:
txt = "\n".join(p.text for p in sh.text_frame.paragraphs if p.text and p.text.strip())
if txt.strip():
lines.append(txt)
try:
if sh.has_table and sh.has_table:
for row in sh.table.rows:
cells = [c.text.replace("\n", " ") for c in row.cells]
lines.append(" | ".join(cells))
except Exception:
pass
with open(out, "w", encoding="utf-8") as f:
f.write("\n".join(lines))
print("OK: %d lines -> %s" % (len(lines), out))
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])
+90
View File
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
"""Verify a rewritten chapter folder (机械原理 在学练习 pattern).
Checks (per chapter folder passed as argv[1]):
1. required files exist and are non-empty: README.md, 01-知识点盘点.md,
01b-覆盖对照与接口.md, 10-速查卡.md, plus >=4 点 files 02-xx..09-xx
2. no line contains "$$" mixed with other content on the same line
(block math must have $$ alone on its own line; inline math uses single $)
3. every 点 file carries at least one 考点频率 marker (★★★/★★☆/★☆☆/⭐)
4. every 点 file carries a 出处 marker (出处:)
5. Obsidian double links [[ ]] appear in README / 01 / 10 and point files
6. 01 file links to 点 files and 10; 点 files mention [[01-知识点盘点]] or [[10-速查卡]]
7. no 旧版-snapshot folder got new files (skip; informational)
Usage: python verify_chapter.py <chapter_dir>
Exit code 0 = all pass; 1 = issues found (printed).
"""
import re
import sys
from pathlib import Path
REQ = ["README.md", "01-知识点盘点.md", "01b-覆盖对照与接口.md", "10-速查卡.md"]
FREQ = re.compile(r"(★★★|★★☆|★☆☆|⭐|必考|大题|选择|简答|了解|不考)")
SRC = re.compile(r"出处[::]")
def main():
ch = Path(sys.argv[1])
if not ch.is_dir():
print("NOT A DIR:", ch)
sys.exit(1)
issues = []
mds = sorted(ch.glob("*.md"))
names = {p.name for p in mds}
# 1. required files
for r in REQ:
if r not in names:
issues.append("缺少必需文件: " + r)
points = [p for p in mds if re.match(r"^0[2-9]-点\d+-", p.name)]
if len(points) < 4:
issues.append("点文件不足 4 个: %d" % len(points))
# per-file checks
for p in mds:
text = p.read_text(encoding="utf-8")
if len(text.strip()) == 0:
issues.append("空文件: " + p.name)
continue
# 2. $$ must stand alone on its line (strip inline-code spans first,
# so prose like "use `$$` as block math" is not flagged)
for ln, line in enumerate(text.splitlines(), 1):
line_nocode = re.sub(r"`[^`]*`", "", line)
if "$$" in line_nocode:
stripped = line_nocode.strip()
if stripped != "$$":
issues.append("%s:%d 同行块公式: %s" % (p.name, ln, stripped[:40]))
# 3/4. 点 files need frequency + source
if re.match(r"^0[2-9]-点\d+-", p.name):
if not FREQ.search(text):
issues.append("%s 缺考点频率标注" % p.name)
if not SRC.search(text):
issues.append("%s 缺出处标注" % p.name)
if "【图:" not in text and "图" not in text[:2000]:
pass # 配图占位非强制每点
# 5/6. links
if p.name in ("README.md", "01-知识点盘点.md", "10-速查卡.md", "01b-覆盖对照与接口.md"):
if "[[" not in text:
issues.append("%s 无双链" % p.name)
# 01 must link to each 点 file basename
if "01-知识点盘点.md" in names:
t01 = (ch / "01-知识点盘点.md").read_text(encoding="utf-8")
for pt in points:
if pt.stem not in t01:
issues.append("01 未链接点文件: " + pt.name)
# README must list 点 files
if "README.md" in names:
tr = (ch / "README.md").read_text(encoding="utf-8")
for pt in points:
if pt.stem not in tr:
issues.append("README 未列出点文件: " + pt.name)
if issues:
print("ISSUES (%d):" % len(issues))
for i in issues:
print(" -", i)
sys.exit(1)
print("OK: %s | %d md files, %d 点 files" % (ch.name, len(mds), len(points)))
sys.exit(0)
if __name__ == "__main__":
main()