Skip to content

Links and Images

Links and images in Markdown can be validated using literal matching or matchers in both the text/alt text and URL portions.

Links must match exactly by default:

schema.mds
[Click here](https://example.com)
input.md
[Click here](https://example.com)
schema.mds
[Click here](https://example.com)
input.md
[Click here](https://different.com)

Images work the same way:

schema.mds
![alt text](image.png)
input.md
![alt text](image.png)
schema.mds
![alt text](image.png)
input.md
![different](image.png)

To use matchers in links, within the link segments surround a matcher with ”{” s.

schema.mds
[{text:/\w+/}](https://example.com)
input.md
[Hello](https://example.com)
Output:
{"text":"Hello"}
schema.mds
[{text:/\w+/}](https://example.com)
input.md
[123](https://example.com)
Output:
{"text":"123"}

Use matchers in the URL:

schema.mds
[Click here]({url:/https?:\/\/.+/})
input.md
[Click here](https://example.com)
Output:
{"url":"https://example.com"}
schema.mds
[Documentation]({page:/\/docs\/.+/})
input.md
[Documentation](/docs/getting-started)
Output:
{"page":"/docs/getting-started"}

Use matchers in image alt text:

schema.mds
![{alt:/\w+/}](image.png)
input.md
![logo](image.png)
Output:
{"alt":"logo"}

Use matchers in image paths:

schema.mds
![Logo]({img:/images\/.+\.png/})
input.md
![Logo](images/logo.png)
Output:
{"img":"images/logo.png"}
schema.mds
![Logo]({img:/images\/.+\.png/})
input.md
![Logo](images/icon.jpg)

Combine matchers in both positions:

schema.mds
[{text:/\w+/}]({url:/https?:\/\/.+/})
input.md
[Home](https://example.com)
Output:
{"text":"Home","url":"https://example.com"}
schema.mds
![{alt:/\w+/}]({path:/.+\.png/})
input.md
![icon](assets/icon.png)
Output:
{"alt":"icon","path":"assets/icon.png"}
  • Links use [text](url) syntax
  • Images use ![alt](src) syntax
  • Matchers work in both text/alt and URL/path positions
  • Reference-style links are also supported (e.g., [text][ref] with [ref]: url)