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

Method getText

markdown/inlinepatterns.py:1183–1200  ·  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

1181 return href, title, index, handled
1182
1183 def getText(self, data: str, index: int) -> tuple[str, int, bool]:
1184 """Parse the content between `[]` of the start of an image or link
1185 resolving nested square brackets.
1186
1187 """
1188 bracket_count = 1
1189 text = []
1190 for pos in range(index, len(data)):
1191 c = data[pos]
1192 if c == ']':
1193 bracket_count -= 1
1194 elif c == '[':
1195 bracket_count += 1
1196 index += 1
1197 if bracket_count == 0:
1198 break
1199 text.append(c)
1200 return ''.join(text), index, bracket_count == 0
1201
1202
1203class ImageInlineProcessor(LinkInlineProcessor):

Callers 3

handleMatchMethod · 0.95
handleMatchMethod · 0.80
handleMatchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected