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

Function literalText

internal/attachments/references.go:536–550  ·  view source on GitHub ↗

literalText reports the byte ranges inside n that a code span quotes, where a bracket is a character rather than markdown. goldmark parsed them, so their text nodes already say where they are.

(n ast.Node)

Source from the content-addressed store, hash-verified

534// bracket is a character rather than markdown. goldmark parsed them, so their
535// text nodes already say where they are.
536func literalText(n ast.Node) []byteRange {
537 var out []byteRange
538 for c := n.FirstChild(); c != nil; c = c.NextSibling() {
539 if _, ok := c.(*ast.CodeSpan); !ok {
540 out = append(out, literalText(c)...)
541 continue
542 }
543 for t := c.FirstChild(); t != nil; t = t.NextSibling() {
544 if text, ok := t.(*ast.Text); ok {
545 out = append(out, byteRange{text.Segment.Start, text.Segment.Stop})
546 }
547 }
548 }
549 return out
550}
551
552// within reports whether i falls inside any of ranges.
553func within(ranges []byteRange, i int) bool {

Callers 1

inlineRangesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected