# MD052 - Reference Link/Image Not Found
## Description
This rule is triggered when a reference link or image uses a reference that doesn't exist in the document. This helps ensure that all reference links and images are valid and can be properly rendered.
In Markdown, reference links and images allow you to define the URL or path separately from where the link or image is used,
making the document more readable and maintainable. This rule verifies that every reference used in a link or image has a
corresponding definition in the document.
## Configuration
This rule has no specific configuration options.
```json
{
"MD052": true
}
```
## Examples
### Valid
```markdown
This is a [reference link][1] and here is a [second link][second].
![Reference image][img]
[1]: https://example.com
[second]: https://example.org
[img]: /path/to/image.jpg
```
```markdown
This is a [shortcut reference] link.
```
### Invalid
```markdown
This is a [broken reference][nonexistent] that will trigger a warning.
This [shortcut reference] will also trigger a warning.
[another-ref]: https://example.com
```
This will produce warnings for both "nonexistent" and "shortcut reference" since neither is defined in the document.
### Fixed
References must be fixed manually by either:
1. Adding the missing reference definition:
```markdown
This is a [broken reference][nonexistent] that will trigger a warning.
This [shortcut reference] will also trigger a warning.
[nonexistent]: https://example.com
[another-ref]: https://example.com
```
1. Or changing the reference to one that exists:
```markdown
This is a [reference][another-ref] that works.
This [another-ref] will also work.
[another-ref]: https://example.com
```
## Special Cases
### Case Sensitivity
Reference matching is case-insensitive. For example:
```markdown
[Reference][ID]
```
Will not trigger a warning because "ID" and "id" are treated as the same reference.
### Shortcut References
This rule also checks shortcut references (where the link text is used as the reference identifier):
```markdown
[shortcut reference]
```
### Multiple References
A single reference definition can be used by multiple links or images:
```markdown
[First link][ref] and [second link][ref]
![Image also using same reference][ref]
[ref]: https://example.com
```
## Related Rules
- [MD051](md051.md) - Link fragments should exist
- [MD049](md049.md) - Emphasis style should be consistent
- [MD050](md050.md) - Strong style should be consistent