Return ``[(line_index, normalized_heading), ...]`` for every ATX H2. A line counts as H2 when it starts with ``"## "`` (two hashes + space). ``normalized_heading`` is the line with trailing whitespace stripped, so ``"## Documents "`` normalizes to ``"## Documents"`` — letting callers
(lines: list[str])
| 768 | |
| 769 | |
| 770 | def _iter_h2_headings(lines: list[str]) -> list[tuple[int, str]]: |
| 771 | """Return ``[(line_index, normalized_heading), ...]`` for every ATX H2. |
| 772 | |
| 773 | A line counts as H2 when it starts with ``"## "`` (two hashes + space). |
| 774 | ``normalized_heading`` is the line with trailing whitespace stripped, so |
| 775 | ``"## Documents "`` normalizes to ``"## Documents"`` — letting callers |
| 776 | use exact-string comparison without tripping on stray whitespace. |
| 777 | |
| 778 | Used by ``_get_section_bounds`` so heading lookup and the next-section |
| 779 | boundary share one scan and one normalization rule. |
| 780 | """ |
| 781 | return [(i, line.rstrip()) for i, line in enumerate(lines) if line.startswith("## ")] |
| 782 | |
| 783 | |
| 784 | def _get_section_bounds(lines: list[str], heading: str) -> tuple[int, int] | None: |
no outgoing calls
no test coverage detected