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)
| 612 | // at the ")" closing the link. Parentheses inside the path are part of it as |
| 613 | // long as they balance. |
| 614 | func scanBareDest(src []byte, i, hi int) int { |
| 615 | depth := 0 |
| 616 | for i < hi { |
| 617 | switch c := src[i]; { |
| 618 | case c == '\\': |
| 619 | if i+1 < hi { |
| 620 | i++ |
| 621 | } |
| 622 | case isSpace(c): |
| 623 | return i |
| 624 | case c == '(': |
| 625 | depth++ |
| 626 | case c == ')': |
| 627 | if depth == 0 { |
| 628 | return i |
| 629 | } |
| 630 | depth-- |
| 631 | } |
| 632 | i++ |
| 633 | } |
| 634 | return i |
| 635 | } |
| 636 | |
| 637 | // scanTitle skips the optional title following a destination and returns the |
| 638 | // index just past it. i may point at anything: a byte that opens no title |
no test coverage detected