# MD043 - Required Headings

## Description

This rule ensures that a document contains a specific set of headings. This is useful for enforcing  
consistent document structure across a collection of documents, such as documentation or a knowledge base.

The rule can be configured with an array of required heading strings or regular expressions.

<!-- markdownlint-disable -->
## Examples

### Valid

With configuration `["# Introduction", "## Installation", "## Usage", "## License"]`:

```markdown
# Introduction

This is the introduction section.

## Installation

Installation instructions go here.

## Usage

Usage examples go here.

## License

This project is licensed under the MIT License.
```

### Invalid

With the same configuration:

```markdown
# Getting Started

This is the introduction section.

## How to Install

Installation instructions go here.

## Examples

Usage examples go here.

## License

This project is licensed under the MIT License.
```

### Fixed

```markdown
# Introduction

This is the introduction section.

## Installation

Installation instructions go here.

## Usage

Usage examples go here.

## License

This project is licensed under the MIT License.
```
<!-- markdownlint-enable -->

## Configuration

This rule has the following configuration options:

- `headings`: An array of strings or regular expressions representing the required headings. Default is an empty array.
- `match_case`: Whether to perform case-sensitive matching. Default is `false`.

Example configuration:

```json
{
  "MD043": {
    "headings": ["# Introduction", "## Installation", "## Usage", "## License"],
    "match_case": true
  }
}
```

## Special Cases

- This rule only applies when the `headings` array is not empty
- Regular expressions can be used by starting and ending the string with `/`
- The rule checks for exact matches unless regular expressions are used
- When `match_case` is `false`, the rule performs case-insensitive matching
- The rule does not check the order of headings unless specified in the configuration

## Related Rules

- [MD001 - Heading increment](md001.md): Ensures heading levels increment by one level at a time
- [MD003 - Heading style](md003.md): Ensures consistent heading style
- [MD025 - Single title/h1](md025.md): Ensures there's only one top-level heading
