Skip to content

markdown_images_have_alt

Require every live CommonMark image to have non-empty rendered alt text.

Formatted label text counts, while whitespace-only labels do not. Fenced and indented code, inline code syntax, comments, and front matter are excluded by the CommonMark parser. Raw HTML <img> elements are outside this kind's contract. Check-only because useful alternative text requires author intent.

This rule takes no kind-specific options.

Plus the common paths, level, id, when, scope_filter, and expect_matches fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

A Markdown image without rendered alt text is reported

Section titled "A Markdown image without rendered alt text is reported"

The rule fires on this repository:

  • README.md

    ✗ error image-alt

    3:1 Markdown image has no alt text

  • architecture.svg✓
README.md
# Project
![](architecture.svg)
architecture.svg
<svg/>

With this .alint.yml:

version: 1
rules:
- id: image-alt
kind: markdown_images_have_alt
paths: "**/*.md"
level: error

alint check reports:

Terminal window
--- README.md ------------------------------------------------------------------
x error image-alt
3:1 Markdown image has no alt text
Summary (1 violation):
x 1 error
0 passing * 1 failing

Formatted image alt text is recognized by the CommonMark parser

Section titled "Formatted image alt text is recognized by the CommonMark parser"

This repository is compliant:

  • README.md✓
  • architecture.svg✓
README.md
# Project
![Component **architecture**](architecture.svg)
`![](example-only.svg)`
architecture.svg
<svg/>

With this .alint.yml:

version: 1
rules:
- id: image-alt
kind: markdown_images_have_alt
paths: "**/*.md"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.