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)
| 513 | // closingBracket finds the "]" that ends a label opened at open, counting the |
| 514 | // brackets of anything nested inside it and ignoring those in literal. |
| 515 | func closingBracket(src []byte, open, hi int, literal []byteRange) (int, bool) { |
| 516 | depth := 0 |
| 517 | for i := open; i < hi; i++ { |
| 518 | if isEscaped(src, i) || within(literal, i) { |
| 519 | continue |
| 520 | } |
| 521 | switch src[i] { |
| 522 | case '[': |
| 523 | depth++ |
| 524 | case ']': |
| 525 | if depth--; depth == 0 { |
| 526 | return i, true |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | return 0, false |
| 531 | } |
| 532 | |
| 533 | // literalText reports the byte ranges inside n that a code span quotes, where a |
| 534 | // bracket is a character rather than markdown. goldmark parsed them, so their |
no test coverage detected