MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / parseLinkLabel

Function parseLinkLabel

markdown_it/helpers/parse_link_label.py:12–44  ·  view source on GitHub ↗
(state: StateInline, start: int, disableNested: bool = False)

Source from the content-addressed store, hash-verified

10
11
12def parseLinkLabel(state: StateInline, start: int, disableNested: bool = False) -> int:
13 labelEnd = -1
14 oldPos = state.pos
15 found = False
16
17 state.pos = start + 1
18 level = 1
19
20 while state.pos < state.posMax:
21 marker = state.src[state.pos]
22 if marker == "]":
23 level -= 1
24 if level == 0:
25 found = True
26 break
27
28 prevPos = state.pos
29 state.md.inline.skipToken(state)
30 if marker == "[":
31 if prevPos == state.pos - 1:
32 # increase level if we find text `[`,
33 # which is not a part of any token
34 level += 1
35 elif disableNested:
36 state.pos = oldPos
37 return -1
38 if found:
39 labelEnd = state.pos
40
41 # restore old state
42 state.pos = oldPos
43
44 return labelEnd

Callers

nothing calls this directly

Calls 1

skipTokenMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…