dsh-zju-lecture-note 2.2.6 → 2.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +154 -2
- package/README.md +77 -46
- package/SECURITY.md +169 -66
- package/docs/technical.md +101 -50
- package/lib/bridge.js +288 -79
- package/lib/client.js +1013 -758
- package/lib/index.js +349 -75
- package/lib/tools.js +28 -3
- package/lib/tools.schema.json +23 -3
- package/mcp.json +21 -0
- package/mcp_server.py +186 -44
- package/package.json +5 -2
- package/plugin.json +19 -0
- package/server.mjs +118 -0
- package/skills/scholia-notes/references/prelude.typ +9 -1
- package/skills/scholia-notes.manifest.json +3 -3
- package/skills/zju-lecture-summarizer/SKILL.md +14 -4
- package/skills/zju-lecture-summarizer/SLIDES.md +42 -5
- package/skills/zju-lecture-summarizer-help/SKILL.md +3 -3
- package/skills/zju-lecture-summarizer-help.manifest.json +4 -4
- package/skills/zju-lecture-summarizer-login/SKILL.md +1 -1
- package/skills/zju-lecture-summarizer-login.manifest.json +4 -4
- package/skills/zju-lecture-summarizer.manifest.json +6 -6
- package/zju_lecture/browser_login.py +174 -210
- package/zju_lecture/cli.py +50 -2
- package/zju_lecture/client.py +95 -18
- package/zju_lecture/cookies.py +43 -4
- package/zju_lecture/courseware.py +37 -2
- package/zju_lecture/credential_store.py +621 -0
- package/zju_lecture/deps.py +114 -17
- package/zju_lecture/handout.py +29 -3
- package/zju_lecture/note_lint.py +34 -10
- package/zju_lecture/paths.py +57 -2
- package/zju_lecture/prelude.typ +9 -1
- package/zju_lecture/slides.py +73 -35
- package/zju_lecture/study_notes.py +40 -4
|
@@ -1219,7 +1219,7 @@ def typst_string(value: str) -> str:
|
|
|
1219
1219
|
return '"' + str(value).replace("\\", "\\\\").replace('"', '\\"') + '"'
|
|
1220
1220
|
|
|
1221
1221
|
|
|
1222
|
-
def
|
|
1222
|
+
def escape_typst_text(text: str, known_labels: Optional[Sequence[str]] = None) -> str:
|
|
1223
1223
|
"""把一段 Markdown 文本转成可以直接放进 Typst markup 的形式。
|
|
1224
1224
|
|
|
1225
1225
|
Typst 的 markup 有几个会咬人的地方,这里逐个处理:
|
|
@@ -1281,6 +1281,35 @@ def escape_typst(text: str, known_labels: Optional[Sequence[str]] = None) -> str
|
|
|
1281
1281
|
return restored
|
|
1282
1282
|
|
|
1283
1283
|
|
|
1284
|
+
#: 正文转义的旧名字;保留给调用方与既有测试。
|
|
1285
|
+
escape_typst = escape_typst_text
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
def escape_typst_string(value: str) -> str:
|
|
1289
|
+
"""Typst 字符串字面量内部转义(不含外层引号)。
|
|
1290
|
+
|
|
1291
|
+
``escape_typst_text`` 是给 markup 用的,不转义双引号——把它塞进
|
|
1292
|
+
``"…"`` 里,一个 ``"`` 就能闭合字符串并注入 ``#read(...)``。
|
|
1293
|
+
这里按 Typst 的字符串语法转义 ``\\``、``"``、换行与制表符,并剥掉
|
|
1294
|
+
裸 ``\\r``(Typst 只认 ``\\n``)。
|
|
1295
|
+
"""
|
|
1296
|
+
text = str(value if value is not None else "").replace("\r\n", "\n")
|
|
1297
|
+
text = text.replace("\r", "")
|
|
1298
|
+
out: List[str] = []
|
|
1299
|
+
for char in text:
|
|
1300
|
+
if char == "\\":
|
|
1301
|
+
out.append("\\\\")
|
|
1302
|
+
elif char == '"':
|
|
1303
|
+
out.append('\\"')
|
|
1304
|
+
elif char == "\n":
|
|
1305
|
+
out.append("\\n")
|
|
1306
|
+
elif char == "\t":
|
|
1307
|
+
out.append("\\t")
|
|
1308
|
+
else:
|
|
1309
|
+
out.append(char)
|
|
1310
|
+
return "".join(out)
|
|
1311
|
+
|
|
1312
|
+
|
|
1284
1313
|
# --------------------------------------------------------------------- 结果类型
|
|
1285
1314
|
|
|
1286
1315
|
|
|
@@ -2237,12 +2266,15 @@ def _render_cover(draft_text: str) -> str:
|
|
|
2237
2266
|
if not fields:
|
|
2238
2267
|
return ""
|
|
2239
2268
|
|
|
2240
|
-
|
|
2269
|
+
# 全部走命名参数,值按字符串字面量转义;位置参数一旦被注入的引号打断,
|
|
2270
|
+
# 后面的 `#read(...)` 就会变成可执行代码。
|
|
2271
|
+
title = fields.get("title") or ""
|
|
2272
|
+
arguments = [f'title: "{escape_typst_string(title)}"']
|
|
2241
2273
|
for key in ("subtitle", "author", "date", "kicker"):
|
|
2242
2274
|
value = fields.get(key)
|
|
2243
2275
|
if value:
|
|
2244
|
-
arguments.append(f'{key}: "{
|
|
2245
|
-
return "#cover(" + ", ".join(arguments) + ")"
|
|
2276
|
+
arguments.append(f'{key}: "{escape_typst_string(value)}"')
|
|
2277
|
+
return "#scholia-cover(" + ", ".join(arguments) + ")"
|
|
2246
2278
|
|
|
2247
2279
|
|
|
2248
2280
|
# ----------------------------------------------------------------- 讲义 → 底稿
|
|
@@ -2501,6 +2533,8 @@ def _prelude_text() -> str:
|
|
|
2501
2533
|
|
|
2502
2534
|
|
|
2503
2535
|
def _run_typst(typst: str, args: Sequence[str], cwd: str, timeout: int) -> Tuple[int, str]:
|
|
2536
|
+
from .deps import typst_env
|
|
2537
|
+
|
|
2504
2538
|
try:
|
|
2505
2539
|
completed = subprocess.run(
|
|
2506
2540
|
[typst, *args],
|
|
@@ -2509,6 +2543,8 @@ def _run_typst(typst: str, args: Sequence[str], cwd: str, timeout: int) -> Tuple
|
|
|
2509
2543
|
stderr=subprocess.STDOUT,
|
|
2510
2544
|
timeout=timeout,
|
|
2511
2545
|
check=False,
|
|
2546
|
+
# Never hand the classroom cookie to the compiler subprocess.
|
|
2547
|
+
env=typst_env(),
|
|
2512
2548
|
)
|
|
2513
2549
|
except subprocess.TimeoutExpired:
|
|
2514
2550
|
return 124, f"typst 编译超时({timeout} 秒)。"
|