← All Exercises

Lint Heading Structure in API Docs

basicjavascript~20min

Background

Broken heading levels break anchor links and screen-reader navigation. Duplicate headings produce colliding anchors that silently point at the wrong section.

Problem

Scan a Markdown document for heading-level jumps and duplicate headings, returning stable issue strings so documentation review catches structural breakage before publishing.

Input

JSON object: { markdown: string }

Output

JSON array of issue strings "<line>:<kind>:<detail>", sorted

Sample tests

Sample 1

Input: {"markdown":"# API\n\n### Usage\n\n## Usage"}
Expected: ["2:heading-jump:h1->h3","4:duplicate-heading:usage"]

Sample 2

Input: {"markdown":"# Guide\n\n## Setup\n\n## Verify"}
Expected: []

Your solution

Learning objective

Review documentation structure with an automated lint instead of eyeballing headings.