Skip to content

VALIDATION-PLANES-13: Bound a paragraph's word count

maxWords(n) constrains a section’s prose, emitting content/max-words at the paragraph’s line when exceeded.

Builds on: VALIDATION-PLANES-02: The smallest contract: one required section

A TypeScript program against the library API; inline comments show the resulting values and behavior.

import { maxWords } from "markdown-contract";
const c = contract({ body: sections({}, [
section("Summary", { content: maxWords(25) }),
]) });
// a 40-word Summary paragraph -> content/max-words at its line
  • maxWords() leaf (src/core/leaves.ts)
  • content/max-words at the paragraph line (src/core/content.ts validateParagraph)