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.
- Input:
# A New Method for Creating JavaScript Rollovers- Output:
# A new method for creating JavaScript rolloversInstall:
npm add heading-case -DAdd 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 fmtAdd 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 . --writeThe existing CLI remains available. Check all Markdown and MDX files in the current directory:
npx heading-caseBy 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 --writeThe programmatic CLI and core formatting utilities are available from subpath exports:
import { headingCase } from 'heading-case/cli';
import { formatLine } from 'heading-case/core';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.
MIT.