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)
| 315 | // destination. One inside a code fence or a code span is not parsed as a |
| 316 | // definition at all, so both are excluded for free. |
| 317 | func linkReferenceDefinitions(doc ast.Node, size int) map[string][]*ast.LinkReferenceDefinition { |
| 318 | out := map[string][]*ast.LinkReferenceDefinition{} |
| 319 | _ = ast.Walk(doc, func(n ast.Node, entering bool) (ast.WalkStatus, error) { |
| 320 | if !entering { |
| 321 | return ast.WalkContinue, nil |
| 322 | } |
| 323 | def, ok := n.(*ast.LinkReferenceDefinition) |
| 324 | if !ok { |
| 325 | return ast.WalkContinue, nil |
| 326 | } |
| 327 | if _, _, ok := blockRange(def, size); !ok { |
| 328 | return ast.WalkContinue, nil |
| 329 | } |
| 330 | key := comparableDestination(string(def.Destination)) |
| 331 | out[key] = append(out[key], def) |
| 332 | return ast.WalkContinue, nil |
| 333 | }) |
| 334 | return out |
| 335 | } |
| 336 | |
| 337 | // attachmentArgsByPath indexes the attached files by absolute path, ready for |
| 338 | // attachmentArgForDestination to look one up. An argument with no URL is |
no test coverage detected