Skip to content

Repository files navigation

heading-case

Format page titles and section headings in Markdown and MDX files to use sentence-style capitalization.

It can be used as a Prettier plugin or as a standalone CLI.

npm version license downloads

Example

  • Input:
# A New Method for Creating JavaScript Rollovers
  • Output:
# A new method for creating JavaScript rollovers

Usage

Install:

npm add heading-case -D

Rstack CLI

Add heading-case to the rs fmt Prettier plugins:

import { define } from 'rstack';

define.fmt({
  plugins: ['heading-case'],
});

Check or write formatted files:

rs fmt --check
rs fmt

Prettier

Add the plugin to your Prettier configuration:

/** @type {import('prettier').Config} */
const config = {
  plugins: ['heading-case'],
};

export default config;

Then run Prettier normally:

prettier . --check
prettier . --write

Standalone CLI

The existing CLI remains available. Check all Markdown and MDX files in the current directory:

npx heading-case

By default, files ignored by Git are skipped as well, including rules from .gitignore, .git/info/exclude, and global Git ignore files.

Check and write the formatted content to the file:

npx heading-case --write

The programmatic CLI and core formatting utilities are available from subpath exports:

import { headingCase } from 'heading-case/cli';
import { formatLine } from 'heading-case/core';

Limitations

This package is designed for Rstack's documentation. It follows the writing style of Rstack documentation and may not work well for other projects.

There are some edge cases that can not be correctly handled, so the execution result is not completely reliable.

License

MIT.

About

Format page titles and section headings in markdown files to use sentence-style capitalization.

Resources

Stars

1 star

Watchers

3 watching

Forks

Releases

Contributors

Languages