Skip to content

ilyatitovich/remark-lint-check-toc

Repository files navigation

remark-lint-check-toc

remark-lint plugin to ensure that your Markdown headings capitalization is correct.

The plugin checks:

  • The ratio of the number of sections in the document and the TOC (to ensure consistency when sections are added or removed).
  • The presence of a section in the TOC (to detect when a section is missing or incorrectly listed).
  • Correctness of URLs (ensuring they are generated correctly using a slugger for GitHub).
  • The order of sections in the TOC compared to the document.
  • Ensuring that the sections in the TOC maintain the correct hierarchy based on the headings in the document.

Install

npm install remark-lint-check-toc

Usage

Use like any other remark-lint plugin. Check out the remark-lint documentation for details.

Examples

When this rule is turned on, the following valid.md is ok:

* [Heading One](#heading-one)
  * [Sub Heading](#sub-heading)
* [Heading Two](#heading-two)

## Heading One

Lorem ipsum dolor sit amet.

### Sub Heading

Lorem ipsum dolor sit amet.

## Heading Two

Lorem ipsum dolor sit amet.

When this rule is turned on, the following invalid.md is not ok:

* [Heaing One](#heading-one)
  * [Sub Heading](#subheading)
* [heading Two](#heading-two)

## Heading One

Lorem ipsum dolor sit amet.

### Sub Heading

Lorem ipsum dolor sit amet.

## Heading Two

Lorem ipsum dolor sit amet.
1:3-1:29 warning Incorrect title or URL in TOC. Title: Heaing One, URL: #heading-one  check-toc remark-lint

2:5-2:31 warning Incorrect title or URL in TOC. Title: Sub Heading, URL: #subheading  check-toc remark-lint

3:3-3:30 warning Incorrect title or URL in TOC. Title: heading Two, URL: #heading-two check-toc remark-lint

About

Ensure that your Markdown TOC is correct

Resources

License

Stars

Watchers

Forks