MCPcopy Create free account
hub / github.com/Qinbf/groundmap / _classify_lines

Function _classify_lines

scripts/section_parser.py:75–104  ·  view source on GitHub ↗

逐行分类:blank / heading / hr / fence / text / fence-mid。

(lines: list[str])

Source from the content-addressed store, hash-verified

73
74
75def _classify_lines(lines: list[str]) -> list[str]:
76 """逐行分类:blank / heading / hr / fence / text / fence-mid。"""
77 out = []
78 in_fence = False
79 fence_marker = None
80 for line in lines:
81 if in_fence:
82 if fence_marker and line.startswith(fence_marker):
83 out.append("fence-end")
84 in_fence = False
85 fence_marker = None
86 else:
87 out.append("fence-mid")
88 continue
89 m = FENCE_RE.match(line)
90 if m:
91 out.append("fence-start")
92 in_fence = True
93 fence_marker = m.group(1)
94 continue
95 stripped = line.strip()
96 if not stripped:
97 out.append("blank")
98 elif HEADING_RE.match(line):
99 out.append("heading")
100 elif HR_RE.match(stripped):
101 out.append("hr")
102 else:
103 out.append("text")
104 return out
105
106
107def split_blocks(text: str) -> list[Block]:

Callers 1

split_blocksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected