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)
| 571 | // bracket is a character rather than markdown. goldmark parsed them, so their |
| 572 | // text nodes already say where they are. |
| 573 | func 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. |
| 590 | func within(ranges []byteRange, i int) bool { |