scanBareDest reads an unbracketed destination, which ends at whitespace or at the ")" closing the link. Parentheses inside the path are part of it as long as they balance.
(src []byte, i, hi int)
| 575 | // at the ")" closing the link. Parentheses inside the path are part of it as |
| 576 | // long as they balance. |
| 577 | func scanBareDest(src []byte, i, hi int) int { |
| 578 | depth := 0 |
| 579 | for i < hi { |
| 580 | switch c := src[i]; { |
| 581 | case c == '\\': |
| 582 | if i+1 < hi { |
| 583 | i++ |
| 584 | } |
| 585 | case isSpace(c): |
| 586 | return i |
| 587 | case c == '(': |
| 588 | depth++ |
| 589 | case c == ')': |
| 590 | if depth == 0 { |
| 591 | return i |
| 592 | } |
| 593 | depth-- |
| 594 | } |
| 595 | i++ |
| 596 | } |
| 597 | return i |
| 598 | } |
| 599 | |
| 600 | // scanTitle skips the optional title following a destination and returns the |
| 601 | // index just past it. i may point at anything: a byte that opens no title |
no test coverage detected