()
| 150 | preamble_lines: List[str] = [] |
| 151 | |
| 152 | def _flush_current() -> None: |
| 153 | nonlocal current_lines, current_title, current_path |
| 154 | content = "".join(current_lines).strip() |
| 155 | if not content: |
| 156 | current_lines = [] |
| 157 | return |
| 158 | sections.append({ |
| 159 | "title": current_title or "Untitled Section", |
| 160 | "heading_path": list(current_path) if current_path else [current_title or "Untitled Section"], |
| 161 | "content": content, |
| 162 | "order_index": len(sections), |
| 163 | "estimated_tokens": estimate_text_tokens(content), |
| 164 | }) |
| 165 | current_lines = [] |
| 166 | |
| 167 | for line in lines: |
| 168 | match = _HEADING_RE.match(line.strip("\n")) |
no test coverage detected