(body: str)
| 176 | |
| 177 | |
| 178 | def markdown_sections(body: str) -> dict[str, str]: |
| 179 | cleaned = ( |
| 180 | strip_html_comments(body).replace("\r\n", "\n").replace("\r", "\n") |
| 181 | ) |
| 182 | matches = list(HEADING_RE.finditer(cleaned)) |
| 183 | sections: dict[str, str] = {} |
| 184 | for index, match in enumerate(matches): |
| 185 | start = match.end() |
| 186 | end = ( |
| 187 | matches[index + 1].start() |
| 188 | if index + 1 < len(matches) |
| 189 | else len(cleaned) |
| 190 | ) |
| 191 | sections[normalize_whitespace(match.group(1))] = cleaned[ |
| 192 | start:end |
| 193 | ].strip() |
| 194 | return sections |
| 195 | |
| 196 | |
| 197 | def section_value(sections: dict[str, str], name: str) -> str: |
no test coverage detected