Skip to content

MD043 - required-headings

Description

This rule checks that the headings in a document match a required structure. Use special wildcards in the headings configuration: * for zero or more unspecified headings, + for one or more unspecified headings, and ? for exactly one unspecified heading.

For example, to require a document to follow to include headings # Document Title, ## Description, ### Examples, and no other headings, the headings configuration option would be set to an ordered list of:

headings = ["# Document Title", "## Description", "### Examples"]

Rationale

Projects may wish to enforce a consistent document structure across a set of similar content. This ensures that all documents follow the same heading hierarchy and organization.

Configuration

headings

List of required headings in the format ## Heading Text. Use * for zero or more unspecified headings, + for one or more unspecified headings, and ? for exactly one unspecified heading.

  • Default: [] (empty)
match_case

When True, heading text must match case exactly.

  • Default: false

Examples

Invalid

# Document Title

## Introduction

This section has the wrong name.

## Examples

Some examples here.

Valid

# Document Title

## Description

This section describes the document.

## Examples

Some examples here.