MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / split_subsections

Function split_subsections

scripts/prepare-release.py:119–136  ·  view source on GitHub ↗

Split a block body into ordered sub-sections keyed by `### Heading`.

(body: list[str])

Source from the content-addressed store, hash-verified

117
118
119def split_subsections(body: list[str]):
120 """Split a block body into ordered sub-sections keyed by `### Heading`."""
121 leading: list[str] = []
122 subs: list[dict] = []
123 cur: dict | None = None
124 for line in body:
125 m = SUBSECTION_RE.match(line)
126 if m:
127 if cur:
128 subs.append(cur)
129 cur = {"heading": m.group(1), "header_line": line, "body": []}
130 elif cur is not None:
131 cur["body"].append(line)
132 else:
133 leading.append(line)
134 if cur:
135 subs.append(cur)
136 return leading, subs
137
138
139def rebuild_body(leading: list[str], subs: list[dict]) -> list[str]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected