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

Function literalText

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

571// bracket is a character rather than markdown. goldmark parsed them, so their
572// text nodes already say where they are.
573func literalText(n ast.Node) []byteRange {
574 var out []byteRange
575 for c := n.FirstChild(); c != nil; c = c.NextSibling() {
576 if _, ok := c.(*ast.CodeSpan); !ok {
577 out = append(out, literalText(c)...)
578 continue
579 }
580 for t := c.FirstChild(); t != nil; t = t.NextSibling() {
581 if text, ok := t.(*ast.Text); ok {
582 out = append(out, byteRange{text.Segment.Start, text.Segment.Stop})
583 }
584 }
585 }
586 return out
587}
588
589// within reports whether i falls inside any of ranges.
590func within(ranges []byteRange, i int) bool {

Callers 1

inlineRangesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected