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

Function blockRange

internal/attachments/references.go:496–509  ·  view source on GitHub ↗

blockRange returns the byte range a block covers in the source.

(b ast.Node, size int)

Source from the content-addressed store, hash-verified

494
495// blockRange returns the byte range a block covers in the source.
496func blockRange(b ast.Node, size int) (int, int, bool) {
497 if b == nil {
498 return 0, 0, false
499 }
500 lines := b.Lines()
501 if lines == nil || lines.Len() == 0 {
502 return 0, 0, false
503 }
504 lo, hi := lines.At(0).Start, lines.At(lines.Len()-1).Stop
505 if lo < 0 || hi > size || lo > hi {
506 return 0, 0, false
507 }
508 return lo, hi, true
509}
510
511// inlineRanges locates the source of an inline link or image. goldmark reports
512// where every inline node starts, so the only thing left to find is where it

Callers 4

scanMarkdownRefsFunction · 0.85
linkReferenceDefinitionsFunction · 0.85
linkReferenceDestinationFunction · 0.85
standsAloneFunction · 0.85

Calls 1

LenMethod · 0.65

Tested by

no test coverage detected