Parse the content between `[]` of the start of an image or link resolving nested square brackets.
(self, data: str, index: int)
| 1274 | return href, title, index, handled |
| 1275 | |
| 1276 | def getText(self, data: str, index: int) -> tuple[str, int, bool]: |
| 1277 | """Parse the content between `[]` of the start of an image or link |
| 1278 | resolving nested square brackets. |
| 1279 | |
| 1280 | """ |
| 1281 | # Scanning forward from every `[` is quadratic when the brackets do not |
| 1282 | # close, so find the closing bracket for every index of `data` at once. |
| 1283 | if self._bracket_data is not data: |
| 1284 | self._bracket_data = data |
| 1285 | self._bracket_ends = self._findBracketEnds(data) |
| 1286 | end = self._bracket_ends[index] |
| 1287 | if end is None: |
| 1288 | return data[index:], len(data), False |
| 1289 | return data[index:end - 1], end, True |
| 1290 | |
| 1291 | @staticmethod |
| 1292 | def _findBracketEnds(data: str) -> list[int | None]: |
no test coverage detected