linkReferenceDefinitions indexes every one in the document by its destination. One inside a code fence or a code span is not parsed as a definition at all, so both are excluded for free.
(doc ast.Node, size int)
| 301 | // destination. One inside a code fence or a code span is not parsed as a |
| 302 | // definition at all, so both are excluded for free. |
| 303 | func linkReferenceDefinitions(doc ast.Node, size int) map[string][]*ast.LinkReferenceDefinition { |
| 304 | out := map[string][]*ast.LinkReferenceDefinition{} |
| 305 | _ = ast.Walk(doc, func(n ast.Node, entering bool) (ast.WalkStatus, error) { |
| 306 | if !entering { |
| 307 | return ast.WalkContinue, nil |
| 308 | } |
| 309 | def, ok := n.(*ast.LinkReferenceDefinition) |
| 310 | if !ok { |
| 311 | return ast.WalkContinue, nil |
| 312 | } |
| 313 | if _, _, ok := blockRange(def, size); !ok { |
| 314 | return ast.WalkContinue, nil |
| 315 | } |
| 316 | key := comparableDestination(string(def.Destination)) |
| 317 | out[key] = append(out[key], def) |
| 318 | return ast.WalkContinue, nil |
| 319 | }) |
| 320 | return out |
| 321 | } |
| 322 | |
| 323 | // attachmentArgsByPath indexes the attached files by absolute path, ready for |
| 324 | // attachmentArgForDestination to look one up. An argument with no URL is |
no test coverage detected