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