heading-case
v2.0.1
Published
Readme
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.
Example
- Input:
# A New Method for Creating JavaScript Rollovers- Output:
# A new method for creating JavaScript rolloversUsage
Install:
npm add heading-case -DRstack 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 fmtPrettier
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 . --writeStandalone CLI
The 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';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.
