@@ -11748,6 +11748,11 @@ window.__ModuleLoader__.load({
1174811748 };
1174911749 let listItems = [];
1175011750 let inCode = false;
11751+ // 围栏要记「开启用的字符与长度」(PR #678 评审):只认三反引号会把
11752+ // `~~~html` 整块当正文,于是一条 `<!-- -->` 注释行会被下面的隐藏规则
11753+ // 删掉;四反引号块内部出现三反引号时旧写法也会提前退出代码态。
11754+ // CommonMark:结束围栏必须与开启同字符、长度不小于开启、其后只有空白。
11755+ let fence = null;
1175111756 let codeLines = [];
1175211757 // --- 表格(v0.11.1 美化):连续 `|` 行解析成真 table,不再按等宽行画竖线 ---
1175311758 const splitRow = (line) => String(line).trim().replace(/^\|/, "").replace(/\|$/, "")
@@ -11789,14 +11794,31 @@ window.__ModuleLoader__.load({
1178911794 };
1179011795 for (; i < lines.length; i++) {
1179111796 const line = lines[i];
11792- if (line.trim().startsWith("```")) {
11793- if (inCode) {
11797+ const fenceOpen = /^(`{3,}|~{3,})(.*)$/.exec(line.trim());
11798+ if (!inCode && fenceOpen) {
11799+ flushList(); flushTable();
11800+ inCode = true;
11801+ fence = { ch: fenceOpen[1][0], len: fenceOpen[1].length };
11802+ codeLines = [];
11803+ continue;
11804+ }
11805+ if (inCode) {
11806+ if (fenceOpen && fenceOpen[1][0] === fence.ch && fenceOpen[1].length >= fence.len
11807+ && fenceOpen[2].trim() === "") {
1179411808 out.push(h("pre", { key: out.length, className: "mneme-wikipre" }, codeLines.join("\n")));
11795- codeLines = []; inCode = false;
11796- } else { flushList(); flushTable(); inCode = true; }
11809+ codeLines = []; inCode = false; fence = null;
11810+ } else {
11811+ codeLines.push(line);
11812+ }
1179711813 continue;
1179811814 }
11799- if (inCode) { codeLines.push(line); continue; }
11815+ // 机器标记行不进正文(#582):`<!-- CHORO:T1:START/END -->` 与
11816+ // `<!-- CHORO:HUMAN:START/END -->` 是 t0/t1 剥段与回填用的段落边界,
11817+ // 给程序看的;排版里它们是一行裸文本噪音。只隐藏「整行以 <!-- 开头」
11818+ // 的情况;代码围栏里的注释原样保留(上面 inCode 分支已经 continue),
11819+ // choro_read_page 的工具回执与磁盘文件同样原样——真源纪律只约束数据
11820+ // 面,渲染层另有一层口径。
11821+ if (/^\s*<!--/.test(line)) continue;
1180011822 const heading = line.match(/^(#{1,6})\s+(.*)$/);
1180111823 if (heading) {
1180211824 flushList(); flushTable();
@@ -13738,9 +13760,40 @@ window.__ModuleLoader__.load({
1373813760 if (c.reason === "unverifiable") return t("wiki.drift.unverifiable");
1373913761 return String(c.reason ?? "");
1374013762 };
13763+ // 树的层级看 parent_id 真父子(#582),不看 slug 里的连字符数——
13764+ // slugify 把路径分隔与一切非字母数字都变成 `-`,目录名自带的连字符与
13765+ // 去重序号(-2)都会冒充层级,`packages-computer-use-src` 会被画成
13766+ // 三层深。moduleMap 本来就回了 id/parent_id,拿它建序:根(无父或父
13767+ // 不在表里)按 slug 序先出、孩子紧跟父后;环成员防御性归入兜底。
13768+ const depthById = new Map();
13769+ const order = [];
13770+ {
13771+ const ids = new Set(state.modules.map((m) => m.id));
13772+ const byParent = new Map();
13773+ for (const mod of state.modules) {
13774+ const pid = mod.parent_id != null && ids.has(mod.parent_id) ? mod.parent_id : null;
13775+ if (!byParent.has(pid)) byParent.set(pid, []);
13776+ byParent.get(pid).push(mod);
13777+ }
13778+ const bySlug = (a, b) => (a.slug < b.slug ? -1 : a.slug > b.slug ? 1 : 0);
13779+ for (const list of byParent.values()) list.sort(bySlug);
13780+ const walk = (pid, depth) => {
13781+ for (const mod of byParent.get(pid) || []) {
13782+ if (depthById.has(mod.id)) continue; // 环防御:同一模块只进一次
13783+ depthById.set(mod.id, depth);
13784+ order.push(mod);
13785+ walk(mod.id, depth + 1);
13786+ }
13787+ };
13788+ walk(null, 0);
13789+ // 兜底:上面走不到的(不该存在的环)按 slug 序补在根层,不静默丢行。
13790+ for (const mod of state.modules.slice().sort(bySlug)) {
13791+ if (!depthById.has(mod.id)) { depthById.set(mod.id, 0); order.push(mod); }
13792+ }
13793+ }
1374113794 const tree = [];
13742- for (const mod of state.modules ) {
13743- const depth = (mod.slug.match(/-/g) || []).length ;
13795+ for (const mod of order ) {
13796+ const depth = depthById.get (mod.id) ?? 0 ;
1374413797 // 树里直接挂「这页有几条要复核」:用户不用先点开才知道哪页被改动碰到。
1374513798 const dp = driftBySlug.get(mod.slug);
1374613799 const riskN = dp && dp.atRisk ? dp.atRisk.length : 0;
0 commit comments