standsAlone reports whether replacing a node with a bare URL will render as a player. GitHub promotes a bare asset URL to a video exactly when it is the whole content of a paragraph, wherever that paragraph sits: a blockquote or a loose list item qualifies, a URL alone on a source line inside a wra
(src []byte, block ast.Node, node byteRange)
| 769 | // block, which is why a lone reference there stays a link. goldmark draws the |
| 770 | // same distinction, so testing for a paragraph is the whole rule. |
| 771 | func standsAlone(src []byte, block ast.Node, node byteRange) bool { |
| 772 | if _, ok := block.(*ast.Paragraph); !ok { |
| 773 | return false |
| 774 | } |
| 775 | lo, hi, ok := blockRange(block, len(src)) |
| 776 | // The node always falls inside the block that produced it, so the range |
| 777 | // test here only keeps the slices below in bounds. |
| 778 | if !ok || node.start < lo || node.stop > hi { |
| 779 | return false |
| 780 | } |
| 781 | for _, c := range src[lo:node.start] { |
| 782 | if !isSpace(c) { |
| 783 | return false |
| 784 | } |
| 785 | } |
| 786 | for _, c := range src[node.stop:hi] { |
| 787 | if !isSpace(c) { |
| 788 | return false |
| 789 | } |
| 790 | } |
| 791 | return true |
| 792 | } |
| 793 | |
| 794 | // isSingleImage reports whether src is one image pointing at wantURL and |
| 795 | // nothing besides. Asset validation uses it to confirm that escaped alt text |
no test coverage detected