MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / getText

Method getText

markdown/inlinepatterns.py:1276–1289  ·  view source on GitHub ↗

Parse the content between `[]` of the start of an image or link resolving nested square brackets.

(self, data: str, index: int)

Source from the content-addressed store, hash-verified

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]:

Callers 3

handleMatchMethod · 0.95
handleMatchMethod · 0.80
handleMatchMethod · 0.80

Calls 1

_findBracketEndsMethod · 0.95

Tested by

no test coverage detected