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

Function blockRange

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

457
458// blockRange returns the byte range a block covers in the source.
459func blockRange(b ast.Node, size int) (int, int, bool) {
460 if b == nil {
461 return 0, 0, false
462 }
463 lines := b.Lines()
464 if lines == nil || lines.Len() == 0 {
465 return 0, 0, false
466 }
467 lo, hi := lines.At(0).Start, lines.At(lines.Len()-1).Stop
468 if lo < 0 || hi > size || lo > hi {
469 return 0, 0, false
470 }
471 return lo, hi, true
472}
473
474// inlineRanges locates the source of an inline link or image. goldmark reports
475// 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