|
|
@@ -21,7 +21,13 @@ interface Block {
|
|
|
function parseBlocks(doc: string): Block[] {
|
|
|
const blocks: Block[] = [];
|
|
|
let current: Block | null = null;
|
|
|
- for (const line of doc.split("\n")) {
|
|
|
+ // ★ 必须按 /\r?\n/ 切,不能按 "\n" 切:本仓 core.autocrlf=true 且无 .gitattributes,
|
|
|
+ // 工作区的 md 是 CRLF,按 "\n" 切会给每行尾巴留一个 \r;而下面那个正则里 `.` 不匹配
|
|
|
+ // \r、`$` 又没开 m 标志 ⇒ **整个文件一行标题都认不出来**,BLOCKS 为空、
|
|
|
+ // 每一条 take() 都返回 []、「收付款接口」整组在侧边栏渲染成一个空 ul。
|
|
|
+ // 2026-09-24 线上实测:md 1013 个 CR、parseBlocks 得 0 块、侧边栏 0 条;
|
|
|
+ // 同一份文件归一成 LF 后 36 块、11 条全回来。改回 "\n" 会让整组文档静默消失。
|
|
|
+ for (const line of doc.split(/\r?\n/)) {
|
|
|
const m = /^(#{1,6})\s+(.*)$/.exec(line);
|
|
|
if (m) {
|
|
|
if (current) blocks.push(current);
|