remark-lint-no-heading-content-indent
raw JSON → 5.0.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when there is extra whitespace between the opening hashes and the content of headings (ATX headings) in Markdown. It enforces a single space after the `#` markers and before the closing `#`s. This package is part of the remark-lint ecosystem, version 5.0.1, ESM-only, ships TypeScript type definitions. It has no dependencies and is recommended for ensuring consistent heading formatting. The rule is included in the `remark-preset-lint-recommended` preset.
Common errors
error Unexpected `N` spaces between hashes and content, expected `1` space, remove `N-1` spaces ↓
cause Heading content has more than one space after the opening hashes or before the closing hashes.
fix
Edit the heading to have exactly one space after the opening
#(s) and exactly one space before any closing #(s). Example: # Heading not # Heading. error Unexpected `N` spaces between content and hashes, expected `1` space, remove `N-1` spaces ↓
cause Closed ATX heading has more than one space before the closing hashes.
fix
Remove extra spaces before the closing
#(s). Example: ## Heading ## not ## Heading ##. Warnings
breaking Version 4.0.0 and later require ESM imports. CommonJS `require()` will fail. ↓
fix Replace `const x = require('remark-lint-no-heading-content-indent')` with `import x from 'remark-lint-no-heading-content-indent'`
gotcha The rule only checks ATX headings (starting with #) and does not affect setext headings (underlined with === or ---). Indented hash characters inside setext headings are not flagged. ↓
fix Use ATX headings if you want consistent indentation linting. Setext headings are ignored by design.
gotcha The rule expects exactly one space between hashes and content; leading whitespace before the hashes is also checked: extra spaces before the opening hashes count as indentation that may not match the expected single space after hashes. ↓
fix Ensure headings are not indented with extra spaces. The rule expects exactly `# SPACE CONTENT` (or `# SPACE CONTENT SPACE #` for closed ATX).
deprecated Version 5.0.1 is the latest. No breaking changes since v4 but the package is part of remark-lint that regularly updates peer dependencies. ↓
fix Upgrade to v5.0.1 to ensure compatibility with unified@11 and remark@15.
Install
npm install remark-lint-no-heading-content-indent yarn add remark-lint-no-heading-content-indent pnpm add remark-lint-no-heading-content-indent Imports
- remarkLintNoHeadingContentIndent wrong
const remarkLintNoHeadingContentIndent = require('remark-lint-no-heading-content-indent')correctimport remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent' - unified wrong
const unified = require('unified')correctimport { unified } from 'unified' - remarkParse
import remarkParse from 'remark-parse' - remarkStringify
import remarkStringify from 'remark-stringify'
Quickstart
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import remarkLint from 'remark-lint'
import remarkLintNoHeadingContentIndent from 'remark-lint-no-heading-content-indent'
import { reporter } from 'vfile-reporter'
const file = await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintNoHeadingContentIndent)
.use(remarkStringify)
.process('# Bad heading\n\n## Good heading')
console.error(reporter(file))
// 1:4: Unexpected `2` spaces between hashes and content, expected `1` space, remove `1` space