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

Function closingBracket

internal/attachments/references.go:552–568  ·  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

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

Callers 1

inlineRangesFunction · 0.85

Calls 2

isEscapedFunction · 0.85
withinFunction · 0.85

Tested by

no test coverage detected