MCPcopy Create free account
hub / github.com/cli/cli / closingBracket

Function closingBracket

internal/attachments/references.go:515–531  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
515func 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

Callers 1

inlineRangesFunction · 0.85

Calls 2

isEscapedFunction · 0.85
withinFunction · 0.85

Tested by

no test coverage detected