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.
Literal Link Matching
Section titled “Literal Link Matching”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)Literal Image Matching
Section titled “Literal Image Matching”Images work the same way:
schema.mds
input.md
schema.mds
input.md
Link Text with Matchers
Section titled “Link Text with Matchers”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"}Link URL with Matchers
Section titled “Link URL with Matchers”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"}Image Alt Text with Matchers
Section titled “Image Alt Text with Matchers”Use matchers in image alt text:
schema.mds
input.md
Output:
{"alt":"logo"}Image Path with Matchers
Section titled “Image Path with Matchers”Use matchers in image paths:
schema.mds
input.md
Output:
{"img":"images/logo.png"}schema.mds
input.md
Both Text and URL with Matchers
Section titled “Both Text and URL with Matchers”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
input.md
Output:
{"alt":"icon","path":"assets/icon.png"}- Links use
[text](url)syntax - Images use
syntax - Matchers work in both text/alt and URL/path positions
- Reference-style links are also supported (e.g.,
[text][ref]with[ref]: url)