(body: str, start: int)
| 105 | |
| 106 | |
| 107 | def parse_markdown_target(body: str, start: int) -> tuple[str, int]: |
| 108 | i = start |
| 109 | while i < len(body) and body[i].isspace(): |
| 110 | i += 1 |
| 111 | if i >= len(body): |
| 112 | return "", i |
| 113 | if body[i] == "<": |
| 114 | end = body.find(">", i + 1) |
| 115 | if end == -1: |
| 116 | return "", i + 1 |
| 117 | return body[i + 1 : end].strip(), end + 1 |
| 118 | |
| 119 | target: list[str] = [] |
| 120 | depth = 0 |
| 121 | while i < len(body): |
| 122 | char = body[i] |
| 123 | if depth == 0 and (char.isspace() or char == ")"): |
| 124 | break |
| 125 | if char == "(": |
| 126 | depth += 1 |
| 127 | elif char == ")": |
| 128 | depth -= 1 |
| 129 | target.append(char) |
| 130 | i += 1 |
| 131 | return "".join(target).strip(), i |
| 132 | |
| 133 | |
| 134 | def iter_markdown_link_targets(body: str): |
no outgoing calls
no test coverage detected