blockRange returns the byte range a block covers in the source.
(b ast.Node, size int)
| 494 | |
| 495 | // blockRange returns the byte range a block covers in the source. |
| 496 | func 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 |
no test coverage detected