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

Function standsAlone

internal/attachments/references.go:771–792  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
771func 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

Callers 1

attachAssetsToMarkdownFunction · 0.85

Calls 2

blockRangeFunction · 0.85
isSpaceFunction · 0.85

Tested by

no test coverage detected