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