(state: StateInline, silent: bool)
| 5 | |
| 6 | |
| 7 | def link(state: StateInline, silent: bool) -> bool: |
| 8 | href = "" |
| 9 | title = "" |
| 10 | label = None |
| 11 | oldPos = state.pos |
| 12 | maximum = state.posMax |
| 13 | start = state.pos |
| 14 | parseReference = True |
| 15 | |
| 16 | if state.src[state.pos] != "[": |
| 17 | return False |
| 18 | |
| 19 | labelStart = state.pos + 1 |
| 20 | labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, True) |
| 21 | |
| 22 | # parser failed to find ']', so it's not a valid link |
| 23 | if labelEnd < 0: |
| 24 | return False |
| 25 | |
| 26 | pos = labelEnd + 1 |
| 27 | |
| 28 | if pos < maximum and state.src[pos] == "(": |
| 29 | # |
| 30 | # Inline link |
| 31 | # |
| 32 | |
| 33 | # might have found a valid shortcut link, disable reference parsing |
| 34 | parseReference = False |
| 35 | |
| 36 | # [link]( <href> "title" ) |
| 37 | # ^^ skipping these spaces |
| 38 | pos += 1 |
| 39 | while pos < maximum: |
| 40 | ch = state.src[pos] |
| 41 | if not isStrSpace(ch) and ch != "\n": |
| 42 | break |
| 43 | pos += 1 |
| 44 | |
| 45 | if pos >= maximum: |
| 46 | return False |
| 47 | |
| 48 | # [link]( <href> "title" ) |
| 49 | # ^^^^^^ parsing link destination |
| 50 | start = pos |
| 51 | res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax) |
| 52 | if res.ok: |
| 53 | href = state.md.normalizeLink(res.str) |
| 54 | if state.md.validateLink(href): |
| 55 | pos = res.pos |
| 56 | else: |
| 57 | href = "" |
| 58 | |
| 59 | # [link]( <href> "title" ) |
| 60 | # ^^ skipping these spaces |
| 61 | start = pos |
| 62 | while pos < maximum: |
| 63 | ch = state.src[pos] |
| 64 | if not isStrSpace(ch) and ch != "\n": |
nothing calls this directly
no test coverage detected
searching dependent graphs…