closingBracket finds the "]" that ends a label opened at open, counting the brackets of anything nested inside it and ignoring those in literal.
(src []byte, open, hi int, literal []byteRange)
| 550 | // closingBracket finds the "]" that ends a label opened at open, counting the |
| 551 | // brackets of anything nested inside it and ignoring those in literal. |
| 552 | func closingBracket(src []byte, open, hi int, literal []byteRange) (int, bool) { |
| 553 | depth := 0 |
| 554 | for i := open; i < hi; i++ { |
| 555 | if isEscaped(src, i) || within(literal, i) { |
| 556 | continue |
| 557 | } |
| 558 | switch src[i] { |
| 559 | case '[': |
| 560 | depth++ |
| 561 | case ']': |
| 562 | if depth--; depth == 0 { |
| 563 | return i, true |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | return 0, false |
| 568 | } |
| 569 | |
| 570 | // literalText reports the byte ranges inside n that a code span quotes, where a |
| 571 | // bracket is a character rather than markdown. goldmark parsed them, so their |
no test coverage detected