dsh-zju-lecture-note 2.2.3 → 2.2.4
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 +41 -0
- package/README.md +8 -7
- package/docs/technical.md +26 -4
- package/mcp_server.py +1 -1
- package/package.json +1 -1
- package/skills/scholia-notes/SKILL.md +8 -1
- package/skills/scholia-notes/references/format-spec.md +57 -6
- package/skills/scholia-notes/references/prelude.typ +42 -0
- package/skills/scholia-notes/references/typography-spec.md +4 -4
- package/skills/scholia-notes.manifest.json +9 -9
- package/skills/zju-lecture-summarizer/SKILL.md +13 -1
- package/skills/zju-lecture-summarizer.manifest.json +4 -4
- package/zju_lecture/client.py +741 -741
- package/zju_lecture/handout.py +353 -57
- package/zju_lecture/handout_prelude.typ +35 -2
- package/zju_lecture/prelude.typ +42 -0
- package/zju_lecture/study_notes.py +296 -1
- package/zju_lecture/typst-packages/VENDORED.md +1 -1
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/LICENSE +20 -20
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/lib.typ +128 -128
- package/zju_lecture/typst-packages/preview/noteworthy/0.4.0/typst.toml +15 -15
- package/zju_lecture/typst-packages/preview/scholia/0.1.0/src/lib.typ +2 -2
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/LICENSE +21 -21
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/func.typ +142 -142
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/id.typ +11 -11
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/pre-rendering.typ +50 -50
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/sections.typ +141 -141
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/lib/shadows.typ +118 -118
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/showy.typ +267 -267
- package/zju_lecture/typst-packages/preview/showybox/2.0.4/typst.toml +11 -11
|
@@ -216,6 +216,45 @@ _HELPER_RE = re.compile(
|
|
|
216
216
|
#: 证明骨架里的缺口标记:`[缺口: 关键那一步]`
|
|
217
217
|
_GAP_RE = re.compile(r"\[缺口\s*[::]\s*([^\]]*)\]")
|
|
218
218
|
|
|
219
|
+
#: 自测题块:`<details><summary>答案</summary>…</details>`。
|
|
220
|
+
#: 阅读版与填空版都把它排成「题干琥珀框 + 框外答案」,题目与答案不再糊成一片。
|
|
221
|
+
_DETAILS_START_RE = re.compile(r"^<details\b", re.IGNORECASE)
|
|
222
|
+
_DETAILS_END_RE = re.compile(r"^</details\s*>", re.IGNORECASE)
|
|
223
|
+
_SUMMARY_LINE_RE = re.compile(r"<summary[^>]*>(.*?)</summary\s*>", re.IGNORECASE)
|
|
224
|
+
|
|
225
|
+
#: 自测题的编号写法:模型最常用 `**1.**`,也兼容 `1.` / `1、`。
|
|
226
|
+
_QUESTION_NUMBER_RE = re.compile(r"^\*\*\s*(\d+)\s*[..、))]\s*\*\*\s*")
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def split_question_number(text: str) -> Tuple[str, str]:
|
|
230
|
+
"""把「**1.** 题干」拆成 ``("1", "题干")``;没有编号时返回 ``("", 原文)``。"""
|
|
231
|
+
stripped = text.strip()
|
|
232
|
+
match = _QUESTION_NUMBER_RE.match(stripped)
|
|
233
|
+
if not match:
|
|
234
|
+
return "", stripped
|
|
235
|
+
return match.group(1), stripped[match.end():].strip()
|
|
236
|
+
|
|
237
|
+
#: 复习版例题的四段式标签。模型常把它们写进同一段(「…跳起来。切入点:…」),
|
|
238
|
+
#: 方框里会排成一大坨;渲染时在这些标签前断段,一条一行。
|
|
239
|
+
_REVIEW_LABEL_RE = re.compile(r"(?<=[。!?;])(题目|切入点|关键步骤|易错点|易错)\s*[::]")
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def split_review_labels(text: str) -> List[str]:
|
|
243
|
+
"""按「题目 / 切入点 / 关键步骤 / 易错点」把一段正文拆成多段。
|
|
244
|
+
|
|
245
|
+
只在这些标签**紧跟句末标点**(或位于段首)时断段,正文一个字都不改 ——
|
|
246
|
+
断的是排版段落,不是内容。标签排在段首时本来就在新行,不重复拆。
|
|
247
|
+
"""
|
|
248
|
+
pieces: List[str] = []
|
|
249
|
+
start = 0
|
|
250
|
+
for match in _REVIEW_LABEL_RE.finditer(text):
|
|
251
|
+
if match.start() <= start:
|
|
252
|
+
continue
|
|
253
|
+
pieces.append(text[start:match.start()])
|
|
254
|
+
start = match.start()
|
|
255
|
+
pieces.append(text[start:])
|
|
256
|
+
return [piece.strip() for piece in pieces if piece.strip()]
|
|
257
|
+
|
|
219
258
|
#: 行首标记:`[定义] …`
|
|
220
259
|
_MARKER_RE = re.compile(r"^\[([^\]\n]{1,8})\]\s*(.*)$")
|
|
221
260
|
|
|
@@ -246,6 +285,12 @@ _TABLE_SEP_RE = re.compile(r"^\s*\|[\s:|-]+\|\s*$")
|
|
|
246
285
|
#: 孤立的「–」;底稿里出现时必须映射成 `#divider`,不能当普通段落。
|
|
247
286
|
_HR_RE = re.compile(r"^\s*([-*_])(?:\s*\1){2,}\s*$")
|
|
248
287
|
|
|
288
|
+
#: 伪标题:整行只有一段粗体(可带 `[mm:ss]` 时间码)。讲义里常拿它当小标题,
|
|
289
|
+
#: 它是**下一个话题**的抬头,不属于前一个装置的正文;跨段收集到这里收尾。
|
|
290
|
+
_PSEUDO_HEADING_RE = re.compile(
|
|
291
|
+
r"^\*\*[^*\n]{1,40}\*\*(?:\s*`?\[\d{1,2}:\d{2}(?::\d{2})?\]`?)?\s*$"
|
|
292
|
+
)
|
|
293
|
+
|
|
249
294
|
#: 斜杠分式:`\partial D/\partial t`、`\mathrm{d}i/\mathrm{d}t`、
|
|
250
295
|
#: `\sqrt{\mu_0/\varepsilon_0}`。这些写法在行内会与上下标挤在一起,
|
|
251
296
|
#: 渲染层统一改成 `\frac{…}{…}`;只处理**明确的微分/根式**,不碰一般 `a/b`。
|
|
@@ -852,6 +897,13 @@ def latex_to_typst(expression: str, inline: bool = False) -> Tuple[str, List[str
|
|
|
852
897
|
# 单字母(\mathrm{d} 里的 d)用直立文本包起来:既保留微分符号的
|
|
853
898
|
# 直立字形,又不会和后面的 x 粘成未知变量 `dx`。
|
|
854
899
|
_emit('"' + argument.strip() + '"', next_index)
|
|
900
|
+
elif "\\" in argument:
|
|
901
|
+
# 参数里还有 LaTeX 命令(`\mathrm{\mu F}`、`\mathrm{\Omega}`):
|
|
902
|
+
# 先递归转成 Typst 数学再交给 upright()。直接塞进字符串会把
|
|
903
|
+
# 反斜杠当字面量印出来(PDF 里就是 `\mu F`)。
|
|
904
|
+
converted, issues = latex_to_typst(argument)
|
|
905
|
+
warnings.extend(issues)
|
|
906
|
+
_emit("upright(" + converted + ")", next_index)
|
|
855
907
|
else:
|
|
856
908
|
escaped = argument.replace('"', '\\"')
|
|
857
909
|
_emit(f'upright("{escaped}")', next_index)
|
|
@@ -1078,6 +1130,11 @@ def _restore(text: str, kept: Sequence[Tuple[str, str]]) -> str:
|
|
|
1078
1130
|
return text
|
|
1079
1131
|
|
|
1080
1132
|
|
|
1133
|
+
def typst_string(value: str) -> str:
|
|
1134
|
+
"""Typst 的字符串字面量(与 handout 的 ``_json_string`` 同义)。"""
|
|
1135
|
+
return '"' + str(value).replace("\\", "\\\\").replace('"', '\\"') + '"'
|
|
1136
|
+
|
|
1137
|
+
|
|
1081
1138
|
def escape_typst(text: str, known_labels: Optional[Sequence[str]] = None) -> str:
|
|
1082
1139
|
"""把一段 Markdown 文本转成可以直接放进 Typst markup 的形式。
|
|
1083
1140
|
|
|
@@ -1316,6 +1373,192 @@ def _render_marker(
|
|
|
1316
1373
|
return fragment, label
|
|
1317
1374
|
|
|
1318
1375
|
|
|
1376
|
+
def _marker_absorbs_blocks(name: str) -> bool:
|
|
1377
|
+
"""框类装置与证明可以**跨段**:一直写到下一个标题或下一个标记。
|
|
1378
|
+
|
|
1379
|
+
旧实现一次只读标记行那一行,紧跟着的块级公式与段落都会掉到装置外:
|
|
1380
|
+
定理框里的公式跑到框外,证明的 qed 方块停在第一段末尾,看起来像
|
|
1381
|
+
「证明到这就结束了」。讲义阅读版链路(``handout._absorbs_blocks``)
|
|
1382
|
+
用同一套规则,两条 PDF 的语义才一致。
|
|
1383
|
+
"""
|
|
1384
|
+
call, shape = MARKERS[name]
|
|
1385
|
+
return call == "proof" or shape == "knot"
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
def _is_marker_line(text: str) -> bool:
|
|
1389
|
+
marker = _MARKER_RE.match(text)
|
|
1390
|
+
return bool(
|
|
1391
|
+
marker
|
|
1392
|
+
and (marker.group(1) in MARKERS or marker.group(1).startswith("缺口"))
|
|
1393
|
+
)
|
|
1394
|
+
|
|
1395
|
+
|
|
1396
|
+
def _collect_block_lines(
|
|
1397
|
+
lines: Sequence[str],
|
|
1398
|
+
cursor: int,
|
|
1399
|
+
) -> Tuple[List[str], int]:
|
|
1400
|
+
"""收集标记行之后、到下一个标题/标记为止的底稿行(空行保留)。"""
|
|
1401
|
+
body: List[str] = []
|
|
1402
|
+
total = len(lines)
|
|
1403
|
+
while cursor < total:
|
|
1404
|
+
raw = lines[cursor]
|
|
1405
|
+
stripped = raw.strip()
|
|
1406
|
+
if stripped and (
|
|
1407
|
+
re.match(r"^#{1,6}\s+", stripped)
|
|
1408
|
+
or _is_marker_line(stripped)
|
|
1409
|
+
or _PSEUDO_HEADING_RE.match(stripped)
|
|
1410
|
+
):
|
|
1411
|
+
break
|
|
1412
|
+
body.append(raw)
|
|
1413
|
+
cursor += 1
|
|
1414
|
+
while body and not body[0].strip():
|
|
1415
|
+
body.pop(0)
|
|
1416
|
+
while body and not body[-1].strip():
|
|
1417
|
+
body.pop()
|
|
1418
|
+
return body, cursor
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
def _split_trailing_label(text: str) -> Tuple[str, str]:
|
|
1422
|
+
match = _LABEL_RE.search(text)
|
|
1423
|
+
if not match:
|
|
1424
|
+
return text.rstrip(), ""
|
|
1425
|
+
return text[: match.start()].rstrip(), match.group(1)
|
|
1426
|
+
|
|
1427
|
+
|
|
1428
|
+
def _render_block_body(
|
|
1429
|
+
lines: Sequence[str],
|
|
1430
|
+
known_labels: Sequence[str],
|
|
1431
|
+
warnings: List[str],
|
|
1432
|
+
) -> Tuple[str, int]:
|
|
1433
|
+
"""把标记块内部的底稿行渲染成 Typst 内容(块内段落不缩进)。
|
|
1434
|
+
|
|
1435
|
+
返回 ``(Typst 内容, 段落数)``:段落数要计入「方框 : 正文」的统计,
|
|
1436
|
+
否则内容一旦搬进装置,分母就凭空变小,批量误报「框框滥用」。
|
|
1437
|
+
"""
|
|
1438
|
+
out: List[str] = []
|
|
1439
|
+
paragraphs = 0
|
|
1440
|
+
index = 0
|
|
1441
|
+
total = len(lines)
|
|
1442
|
+
while index < total:
|
|
1443
|
+
raw = lines[index]
|
|
1444
|
+
stripped = raw.strip()
|
|
1445
|
+
if not stripped:
|
|
1446
|
+
out.append("")
|
|
1447
|
+
index += 1
|
|
1448
|
+
continue
|
|
1449
|
+
display = _DISPLAY_MATH_RE.match(stripped)
|
|
1450
|
+
if display:
|
|
1451
|
+
out.append("$ " + display.group(1) + " $")
|
|
1452
|
+
index += 1
|
|
1453
|
+
continue
|
|
1454
|
+
if _TABLE_ROW_RE.match(raw):
|
|
1455
|
+
rows: List[str] = []
|
|
1456
|
+
while index < total and _TABLE_ROW_RE.match(lines[index]):
|
|
1457
|
+
rows.append(lines[index])
|
|
1458
|
+
index += 1
|
|
1459
|
+
out.extend(_convert_table(rows, warnings))
|
|
1460
|
+
continue
|
|
1461
|
+
bullet = _BULLET_RE.match(raw)
|
|
1462
|
+
if bullet:
|
|
1463
|
+
indent = bullet.group(1).replace("\t", " ")
|
|
1464
|
+
out.append(indent + "- " + escape_typst(bullet.group(2), known_labels))
|
|
1465
|
+
index += 1
|
|
1466
|
+
continue
|
|
1467
|
+
ordered = _OL_RE.match(raw)
|
|
1468
|
+
if ordered:
|
|
1469
|
+
indent = ordered.group(1).replace("\t", " ")
|
|
1470
|
+
out.append(
|
|
1471
|
+
indent + "+ " + escape_typst(raw[ordered.end():].strip(), known_labels)
|
|
1472
|
+
)
|
|
1473
|
+
index += 1
|
|
1474
|
+
continue
|
|
1475
|
+
# 「题目 / 切入点 / 关键步骤 / 易错点」写在同一段里时,一条一行排开。
|
|
1476
|
+
for position, part in enumerate(split_review_labels(stripped)):
|
|
1477
|
+
if position:
|
|
1478
|
+
out.append("")
|
|
1479
|
+
out.append(_render_gaps(part, known_labels))
|
|
1480
|
+
paragraphs += 1
|
|
1481
|
+
index += 1
|
|
1482
|
+
while out and not out[0].strip():
|
|
1483
|
+
out.pop(0)
|
|
1484
|
+
while out and not out[-1].strip():
|
|
1485
|
+
out.pop()
|
|
1486
|
+
return "\n".join(out), paragraphs
|
|
1487
|
+
|
|
1488
|
+
|
|
1489
|
+
def _render_label_paragraphs(text: str, known_labels: Sequence[str]) -> str:
|
|
1490
|
+
"""把「题目:…。切入点:…」这类一行写全的正文按标签拆成多段。"""
|
|
1491
|
+
if not text.strip():
|
|
1492
|
+
return ""
|
|
1493
|
+
return "\n\n".join(
|
|
1494
|
+
_render_gaps(part, known_labels) for part in split_review_labels(text)
|
|
1495
|
+
)
|
|
1496
|
+
|
|
1497
|
+
|
|
1498
|
+
def _render_block_marker(
|
|
1499
|
+
marker: str,
|
|
1500
|
+
first: str,
|
|
1501
|
+
extra: Sequence[str],
|
|
1502
|
+
known_labels: Sequence[str],
|
|
1503
|
+
warnings: List[str],
|
|
1504
|
+
) -> Tuple[str, str, int]:
|
|
1505
|
+
"""渲染一个跨段标记(标记行 + 后续正文行),返回 ``(Typst, label, 段落数)``。"""
|
|
1506
|
+
call, shape = MARKERS[marker]
|
|
1507
|
+
if call is None:
|
|
1508
|
+
return "#divider", "", 0
|
|
1509
|
+
|
|
1510
|
+
first, label = _split_trailing_label(first)
|
|
1511
|
+
extra = list(extra)
|
|
1512
|
+
if not label:
|
|
1513
|
+
# 独占一行的 <label>(写在公式后面)也认。
|
|
1514
|
+
for position, raw_line in enumerate(extra):
|
|
1515
|
+
stripped_line = raw_line.strip()
|
|
1516
|
+
if not stripped_line:
|
|
1517
|
+
continue
|
|
1518
|
+
text, found = _split_trailing_label(stripped_line)
|
|
1519
|
+
if not found or text.strip():
|
|
1520
|
+
continue
|
|
1521
|
+
del extra[position]
|
|
1522
|
+
label = found
|
|
1523
|
+
break
|
|
1524
|
+
if not label:
|
|
1525
|
+
# <label> 写在最后一段末尾也很自然:两处都认,回指编号才不会悬空。
|
|
1526
|
+
for position in range(len(extra) - 1, -1, -1):
|
|
1527
|
+
if not extra[position].strip():
|
|
1528
|
+
continue
|
|
1529
|
+
text, found = _split_trailing_label(extra[position])
|
|
1530
|
+
if found:
|
|
1531
|
+
extra[position] = text
|
|
1532
|
+
if not text.strip():
|
|
1533
|
+
del extra[position]
|
|
1534
|
+
label = found
|
|
1535
|
+
break
|
|
1536
|
+
|
|
1537
|
+
rest_typst, rest_paragraphs = _render_block_body(extra, known_labels, warnings)
|
|
1538
|
+
if shape == "knot":
|
|
1539
|
+
title, tag, content = _split_knot_parts(first)
|
|
1540
|
+
head = _render_label_paragraphs(content, known_labels)
|
|
1541
|
+
content_typst = "\n\n".join(part for part in (head, rest_typst) if part.strip())
|
|
1542
|
+
title_typst = escape_typst(title, known_labels)
|
|
1543
|
+
tag_typst = escape_typst(tag, known_labels)
|
|
1544
|
+
if tag:
|
|
1545
|
+
fragment = f"#{call}[{title_typst}][{tag_typst}][{content_typst}]"
|
|
1546
|
+
elif title:
|
|
1547
|
+
fragment = f"#{call}[{title_typst}][{content_typst}]"
|
|
1548
|
+
else:
|
|
1549
|
+
fragment = f"#{call}[{content_typst}]"
|
|
1550
|
+
else:
|
|
1551
|
+
head = _render_label_paragraphs(first, known_labels)
|
|
1552
|
+
content_typst = "\n\n".join(part for part in (head, rest_typst) if part.strip())
|
|
1553
|
+
if call == "sidenote":
|
|
1554
|
+
fragment = f"#sidenote([{content_typst}], symbol: [!])"
|
|
1555
|
+
else:
|
|
1556
|
+
fragment = f"#{call}[{content_typst}]"
|
|
1557
|
+
if label:
|
|
1558
|
+
fragment += f" <{label}>"
|
|
1559
|
+
return fragment, label, rest_paragraphs
|
|
1560
|
+
|
|
1561
|
+
|
|
1319
1562
|
def _collapse_display_math(text: str) -> str:
|
|
1320
1563
|
"""把跨行的 ``$$ … $$`` 块压成单行 ``$ … $``。
|
|
1321
1564
|
|
|
@@ -1530,6 +1773,9 @@ def render_typst(
|
|
|
1530
1773
|
paragraphs = 0
|
|
1531
1774
|
devices: Dict[str, int] = {}
|
|
1532
1775
|
lines_out: List[str] = []
|
|
1776
|
+
#: 已排版段落 → 原始 Markdown,用来在遇到 `<details>` 时把上一段改成题干框。
|
|
1777
|
+
paragraph_raw: Dict[int, str] = {}
|
|
1778
|
+
question_count = 0
|
|
1533
1779
|
|
|
1534
1780
|
def _count(name: str) -> None:
|
|
1535
1781
|
devices[name] = devices.get(name, 0) + 1
|
|
@@ -1573,6 +1819,46 @@ def render_typst(
|
|
|
1573
1819
|
continue
|
|
1574
1820
|
in_cover = False
|
|
1575
1821
|
|
|
1822
|
+
# 自测题:`**1.** 题干` + `<details><summary>答案</summary>…</details>`。
|
|
1823
|
+
# 题干换成琥珀方框(#selftest),答案排在框外(#answer + 灰色左边线),
|
|
1824
|
+
# 题目与答案因此有一道清楚的边界;旧实现会把标签原样印成 `<details>`。
|
|
1825
|
+
if _DETAILS_START_RE.match(stripped):
|
|
1826
|
+
last = len(lines_out) - 1
|
|
1827
|
+
while last >= 0 and not lines_out[last].strip():
|
|
1828
|
+
last -= 1
|
|
1829
|
+
raw_question = paragraph_raw.get(last)
|
|
1830
|
+
if raw_question:
|
|
1831
|
+
number, stem = split_question_number(raw_question)
|
|
1832
|
+
if number:
|
|
1833
|
+
question_count = max(question_count, int(number))
|
|
1834
|
+
else:
|
|
1835
|
+
question_count += 1
|
|
1836
|
+
number = str(question_count)
|
|
1837
|
+
lines_out[last] = (
|
|
1838
|
+
"#selftest(" + number + ")[" + escape_typst(stem, known_labels) + "]"
|
|
1839
|
+
)
|
|
1840
|
+
_count("selftest")
|
|
1841
|
+
label = "答案"
|
|
1842
|
+
content_lines: List[str] = []
|
|
1843
|
+
while cursor < len(input_lines):
|
|
1844
|
+
candidate = input_lines[cursor]
|
|
1845
|
+
candidate_text = candidate.strip()
|
|
1846
|
+
cursor += 1
|
|
1847
|
+
if _DETAILS_END_RE.match(candidate_text):
|
|
1848
|
+
break
|
|
1849
|
+
summary = _SUMMARY_LINE_RE.search(candidate_text)
|
|
1850
|
+
if summary:
|
|
1851
|
+
label = summary.group(1).strip() or label
|
|
1852
|
+
continue
|
|
1853
|
+
content_lines.append(candidate)
|
|
1854
|
+
answer_typst, answer_paragraphs = _render_block_body(
|
|
1855
|
+
content_lines, known_labels, warnings
|
|
1856
|
+
)
|
|
1857
|
+
lines_out.append("#answer(" + typst_string(label) + ")[" + answer_typst + "]")
|
|
1858
|
+
paragraphs += answer_paragraphs
|
|
1859
|
+
_count("answer")
|
|
1860
|
+
continue
|
|
1861
|
+
|
|
1576
1862
|
marker = _MARKER_RE.match(stripped)
|
|
1577
1863
|
if marker and (marker.group(1) in MARKERS or marker.group(1).startswith("缺口")):
|
|
1578
1864
|
name = marker.group(1)
|
|
@@ -1581,7 +1867,15 @@ def render_typst(
|
|
|
1581
1867
|
hint = body.split(":", 1)[1].strip() if ":" in body else body.strip()
|
|
1582
1868
|
lines_out.append("#TODO[" + escape_typst(hint, known_labels) + "]")
|
|
1583
1869
|
continue
|
|
1584
|
-
|
|
1870
|
+
if _marker_absorbs_blocks(name):
|
|
1871
|
+
# 框与证明跨段:同一装置的公式、段落、列表都留在块内。
|
|
1872
|
+
extra, cursor = _collect_block_lines(input_lines, cursor)
|
|
1873
|
+
fragment, label, body_paragraphs = _render_block_marker(
|
|
1874
|
+
name, body, extra, known_labels, warnings
|
|
1875
|
+
)
|
|
1876
|
+
paragraphs += body_paragraphs
|
|
1877
|
+
else:
|
|
1878
|
+
fragment, label = _render_marker(name, body, known_labels)
|
|
1585
1879
|
lines_out.append(fragment)
|
|
1586
1880
|
if label:
|
|
1587
1881
|
labels.append(label)
|
|
@@ -1656,6 +1950,7 @@ def render_typst(
|
|
|
1656
1950
|
|
|
1657
1951
|
# 普通段落 —— 正文的主体。段首空两格。
|
|
1658
1952
|
lines_out.append(BODY_INDENT + escape_typst(stripped, known_labels))
|
|
1953
|
+
paragraph_raw[len(lines_out) - 1] = stripped
|
|
1659
1954
|
paragraphs += 1
|
|
1660
1955
|
|
|
1661
1956
|
body_text = "\n".join(lines_out).strip()
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
| :--- | :--- |
|
|
27
27
|
| `src/fonts.typ` | 字体表改为可再分发栈:`body`/`heading` 用 STIX Two + 随包 Notes Kai SC、Notes Serif SC;`sans` 用 Noto Sans / Liberation Sans / DejaVu Sans(中文回 Notes Kai SC);移除 Optima / Avenir Next / Menlo / Songti SC |
|
|
28
28
|
| `src/theorems.typ` | 方框标签(`Theorem` / `Definition` / `Example`)改用 `default-fonts.sans`,标签末尾句点同步 |
|
|
29
|
-
| `src/lib.typ` | `Your turn.` 标签改用 `sans`;二级/三级标题字号统一为 12.5pt / 11.5pt;边注段距补 0.4em |
|
|
29
|
+
| `src/lib.typ` | `Your turn.` 标签改用 `sans`;二级/三级标题字号统一为 12.5pt / 11.5pt;一/二级标题上方留白 24pt / 22pt;边注段距补 0.4em |
|
|
30
30
|
|
|
31
31
|
除上述补丁外,其余代码、`typst.toml` 与许可文件保持上游原样。
|
|
32
32
|
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025-2026 Tarun Kumar Jana
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Tarun Kumar Jana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
// All imports
|
|
3
|
-
#import "@preview/theoretic:0.3.1" as theoretic: proof, qed, theorem
|
|
4
|
-
#import theoretic.presets.basic: *
|
|
5
|
-
#show ref: theoretic.show-ref
|
|
6
|
-
#import "@preview/showybox:2.0.4": showybox
|
|
7
|
-
|
|
8
|
-
// Main noteworthy function
|
|
9
|
-
#let noteworthy(
|
|
10
|
-
paper-size: "a4",
|
|
11
|
-
font: "New Computer Modern",
|
|
12
|
-
language: "EN",
|
|
13
|
-
title: none,
|
|
14
|
-
header-title: none,
|
|
15
|
-
date: none,
|
|
16
|
-
author: none,
|
|
17
|
-
contact-details: none,
|
|
18
|
-
toc-title: "Table of Contents",
|
|
19
|
-
toc-depth: none,
|
|
20
|
-
watermark: none,
|
|
21
|
-
content,
|
|
22
|
-
) = {
|
|
23
|
-
// Document metadata
|
|
24
|
-
set document(
|
|
25
|
-
title: [#title - #author],
|
|
26
|
-
author: author,
|
|
27
|
-
date: auto,
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
// Page settings
|
|
31
|
-
set page(
|
|
32
|
-
paper: paper-size,
|
|
33
|
-
background: if watermark != none {
|
|
34
|
-
rotate(-40deg, text(30pt, fill: rgb("FFCBC4"))[*#watermark*])
|
|
35
|
-
},
|
|
36
|
-
header: context {
|
|
37
|
-
if (counter(page).get().at(0) > 1) [
|
|
38
|
-
#grid(
|
|
39
|
-
columns: (1fr, 1fr),
|
|
40
|
-
align: (left, right),
|
|
41
|
-
smallcaps(if header-title != none {
|
|
42
|
-
header-title
|
|
43
|
-
} else {
|
|
44
|
-
title
|
|
45
|
-
}),
|
|
46
|
-
if date != none {
|
|
47
|
-
date
|
|
48
|
-
} else {
|
|
49
|
-
datetime.today().display("[day]/[month]/[year]")
|
|
50
|
-
},
|
|
51
|
-
)
|
|
52
|
-
#line(length: 100%)
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
footer: context [
|
|
56
|
-
#line(length: 100%)
|
|
57
|
-
#grid(
|
|
58
|
-
columns: (1fr, 1fr, 1fr),
|
|
59
|
-
align: (left, center, right),
|
|
60
|
-
author,
|
|
61
|
-
if contact-details != none {
|
|
62
|
-
[#sym.diamond.filled #link(contact-details) #sym.diamond.filled]
|
|
63
|
-
},
|
|
64
|
-
counter(page).display(
|
|
65
|
-
"(1/1)",
|
|
66
|
-
both: true,
|
|
67
|
-
),
|
|
68
|
-
)
|
|
69
|
-
],
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
// Text settings
|
|
73
|
-
set text(
|
|
74
|
-
font: font,
|
|
75
|
-
size: 12pt,
|
|
76
|
-
lang: language,
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
// TOC settings
|
|
80
|
-
show outline.entry.where(level: 1): it => {
|
|
81
|
-
v(12pt, weak: true)
|
|
82
|
-
strong(it)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Heading settings
|
|
86
|
-
set heading(numbering: "1.")
|
|
87
|
-
|
|
88
|
-
// Paragraph settings
|
|
89
|
-
set par(justify: true)
|
|
90
|
-
|
|
91
|
-
// Title
|
|
92
|
-
showybox(
|
|
93
|
-
frame: (
|
|
94
|
-
border-color: blue.darken(50%),
|
|
95
|
-
body-color: blue.lighten(80%),
|
|
96
|
-
),
|
|
97
|
-
shadow: (
|
|
98
|
-
offset: 3pt,
|
|
99
|
-
),
|
|
100
|
-
body-style: (
|
|
101
|
-
align: center,
|
|
102
|
-
),
|
|
103
|
-
text(weight: "black", size: 15pt, title),
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
// Table of contents
|
|
107
|
-
showybox(
|
|
108
|
-
breakable: true,
|
|
109
|
-
outline(
|
|
110
|
-
indent: auto,
|
|
111
|
-
title: toc-title,
|
|
112
|
-
depth: toc-depth,
|
|
113
|
-
),
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
// Main content
|
|
117
|
-
content
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Custom environment using Theoretic package
|
|
121
|
-
|
|
122
|
-
// Solution environment
|
|
123
|
-
#let solution = theoretic.theorem.with(
|
|
124
|
-
supplement: "Solution",
|
|
125
|
-
kind: "solution",
|
|
126
|
-
variant: "remark",
|
|
127
|
-
number: none,
|
|
128
|
-
)
|
|
1
|
+
|
|
2
|
+
// All imports
|
|
3
|
+
#import "@preview/theoretic:0.3.1" as theoretic: proof, qed, theorem
|
|
4
|
+
#import theoretic.presets.basic: *
|
|
5
|
+
#show ref: theoretic.show-ref
|
|
6
|
+
#import "@preview/showybox:2.0.4": showybox
|
|
7
|
+
|
|
8
|
+
// Main noteworthy function
|
|
9
|
+
#let noteworthy(
|
|
10
|
+
paper-size: "a4",
|
|
11
|
+
font: "New Computer Modern",
|
|
12
|
+
language: "EN",
|
|
13
|
+
title: none,
|
|
14
|
+
header-title: none,
|
|
15
|
+
date: none,
|
|
16
|
+
author: none,
|
|
17
|
+
contact-details: none,
|
|
18
|
+
toc-title: "Table of Contents",
|
|
19
|
+
toc-depth: none,
|
|
20
|
+
watermark: none,
|
|
21
|
+
content,
|
|
22
|
+
) = {
|
|
23
|
+
// Document metadata
|
|
24
|
+
set document(
|
|
25
|
+
title: [#title - #author],
|
|
26
|
+
author: author,
|
|
27
|
+
date: auto,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
// Page settings
|
|
31
|
+
set page(
|
|
32
|
+
paper: paper-size,
|
|
33
|
+
background: if watermark != none {
|
|
34
|
+
rotate(-40deg, text(30pt, fill: rgb("FFCBC4"))[*#watermark*])
|
|
35
|
+
},
|
|
36
|
+
header: context {
|
|
37
|
+
if (counter(page).get().at(0) > 1) [
|
|
38
|
+
#grid(
|
|
39
|
+
columns: (1fr, 1fr),
|
|
40
|
+
align: (left, right),
|
|
41
|
+
smallcaps(if header-title != none {
|
|
42
|
+
header-title
|
|
43
|
+
} else {
|
|
44
|
+
title
|
|
45
|
+
}),
|
|
46
|
+
if date != none {
|
|
47
|
+
date
|
|
48
|
+
} else {
|
|
49
|
+
datetime.today().display("[day]/[month]/[year]")
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
#line(length: 100%)
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
footer: context [
|
|
56
|
+
#line(length: 100%)
|
|
57
|
+
#grid(
|
|
58
|
+
columns: (1fr, 1fr, 1fr),
|
|
59
|
+
align: (left, center, right),
|
|
60
|
+
author,
|
|
61
|
+
if contact-details != none {
|
|
62
|
+
[#sym.diamond.filled #link(contact-details) #sym.diamond.filled]
|
|
63
|
+
},
|
|
64
|
+
counter(page).display(
|
|
65
|
+
"(1/1)",
|
|
66
|
+
both: true,
|
|
67
|
+
),
|
|
68
|
+
)
|
|
69
|
+
],
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
// Text settings
|
|
73
|
+
set text(
|
|
74
|
+
font: font,
|
|
75
|
+
size: 12pt,
|
|
76
|
+
lang: language,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
// TOC settings
|
|
80
|
+
show outline.entry.where(level: 1): it => {
|
|
81
|
+
v(12pt, weak: true)
|
|
82
|
+
strong(it)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Heading settings
|
|
86
|
+
set heading(numbering: "1.")
|
|
87
|
+
|
|
88
|
+
// Paragraph settings
|
|
89
|
+
set par(justify: true)
|
|
90
|
+
|
|
91
|
+
// Title
|
|
92
|
+
showybox(
|
|
93
|
+
frame: (
|
|
94
|
+
border-color: blue.darken(50%),
|
|
95
|
+
body-color: blue.lighten(80%),
|
|
96
|
+
),
|
|
97
|
+
shadow: (
|
|
98
|
+
offset: 3pt,
|
|
99
|
+
),
|
|
100
|
+
body-style: (
|
|
101
|
+
align: center,
|
|
102
|
+
),
|
|
103
|
+
text(weight: "black", size: 15pt, title),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
// Table of contents
|
|
107
|
+
showybox(
|
|
108
|
+
breakable: true,
|
|
109
|
+
outline(
|
|
110
|
+
indent: auto,
|
|
111
|
+
title: toc-title,
|
|
112
|
+
depth: toc-depth,
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
// Main content
|
|
117
|
+
content
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Custom environment using Theoretic package
|
|
121
|
+
|
|
122
|
+
// Solution environment
|
|
123
|
+
#let solution = theoretic.theorem.with(
|
|
124
|
+
supplement: "Solution",
|
|
125
|
+
kind: "solution",
|
|
126
|
+
variant: "remark",
|
|
127
|
+
number: none,
|
|
128
|
+
)
|