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

Function standsAlone

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

806// block, which is why a lone reference there stays a link. goldmark draws the
807// same distinction, so testing for a paragraph is the whole rule.
808func standsAlone(src []byte, block ast.Node, node byteRange) bool {
809 if _, ok := block.(*ast.Paragraph); !ok {
810 return false
811 }
812 lo, hi, ok := blockRange(block, len(src))
813 // The node always falls inside the block that produced it, so the range
814 // test here only keeps the slices below in bounds.
815 if !ok || node.start < lo || node.stop > hi {
816 return false
817 }
818 for _, c := range src[lo:node.start] {
819 if !isSpace(c) {
820 return false
821 }
822 }
823 for _, c := range src[node.stop:hi] {
824 if !isSpace(c) {
825 return false
826 }
827 }
828 return true
829}
830
831// isSingleImage reports whether src is one image pointing at wantURL and
832// 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