headings

Document-wide rules over every heading: level, mask, and order.

First officer: Bridge, engineering, medbay. In that order, and nothing bolted on.

Quick reference

Examples

headings.level

Select which ATX heading level (1-6) the directive's heading collection draws from; a selector atom for headings.mask / headings.order on the same directive.

Only headings at the chosen level are checked

contract.mdv.md
<!-- mdv: document headings.level=2 headings.mask="Sol <num>" -->
document.md
## Sol 12

### Drill notes

Core sample taken.

## Sol 13

Dust storm, rover parked.

✓ passes

headings.select.mask

Narrow the directive's heading collection to headings whose whole text matches this mask (a predicate selector — non-matching headings fall outside the collection, they are not violations).

<!-- mdv: document headings.level=2 headings.select.mask="<semver>[ - <date>]" headings.order=desc headings.order.compare=semver -->

headings.mask

Require EVERY heading in the directive's collection (all headings at headings.level and/or matching headings.select.mask) to match this anchored mask, or any one of an array of masks, read as a section binds the heading (links and bare [text] read as text); one diagnostic per failing heading, on that heading's line.

Every heading matching the mask passes

contract.mdv.md
<!-- mdv: document headings.level=2 headings.mask="<semver> - <date>" -->
document.md
## [1.4.0] - 2026-06-21

Relay retuned.

## [1.3.2] - 2026-05-30

Docking light fixed.

✓ passes

A heading that misses the mask is flagged

contract.mdv.md
<!-- mdv: document headings.level=2 headings.mask="<semver> - <date>" -->
document.md
## [1.4.0] - 2026-06-21

Relay retuned.

## Docking light fixed

No version, no date.

✗ value-not-given error · line 5

headings.raw.mask

Like headings.mask, but on each heading as written (brackets, link syntax and leading symbols included) instead of the cleaned heading a section binds by.

<!-- mdv: document headings.level=2 headings.raw.mask="\[<semver>\] - <date>" -->
## [1.4.0] - 2026-06-21

headings.order

Require the keys extracted from the directive's heading collection to strictly descend down the file (headings.order.compare picks the comparator: semver, date, or number; unkeyed headings are skipped; equal keys are violations).

Newest-first versions pass

contract.mdv.md
<!-- mdv: document headings.level=2 headings.order=desc headings.order.compare=semver -->
document.md
## [1.4.0] - 2026-06-21

Relay retuned.

## [1.3.2] - 2026-05-30

Docking light fixed.

✓ passes

A newer version listed after an older one is flagged

contract.mdv.md
<!-- mdv: document headings.level=2 headings.order=desc headings.order.compare=semver -->
document.md
## [1.3.2] - 2026-05-30

Docking light fixed.

## [1.4.0] - 2026-06-21

Relay retuned.

✗ headings-out-of-order warn · line 5

headings.order.compare

Name the comparator headings.order sorts by: semver (SemVer 2.0.0 precedence, lenient extraction), date (first ISO YYYY-MM-DD run), or number (first numeric run); a modifier atom for headings.order on the same directive.

<!-- mdv: document headings.level=2 headings.order=desc headings.order.compare=date -->

headings.order.extract.mask

Narrow where headings.order reads its key: the mask's first match in the heading is handed to the comparator's extractor; without it the extractor scans the whole heading. A modifier atom.

<!-- mdv: document headings.level=2 headings.order=desc headings.order.compare=number headings.order.extract.mask="v<num>" -->

On this page