@0x6b/textlint-rule-no-hr-before-heading
v0.1.0
Published
textlint rule which detects horizontal rules appearing immediately before headings.
Maintainers
Readme
textlint-rule-no-hr-before-heading
textlint rule which detects and reports horizontal rules appearing immediately before headings in your markdown document.
While horizontal rules (---, ***, ___) before headings are syntactically valid in Markdown, they often create visual clutter. Markdown headings already provide clear visual separation, making horizontal rules redundant in this context.
Install
Install with pnpm:
pnpm add @0x6b/textlint-rule-no-hr-before-headingOr with npm:
npm install @0x6b/textlint-rule-no-hr-before-headingThis module requires Node.js >= 20.0.0.
Usage
Via .textlintrc(recommended):
{
"rules": {
"@0x6b/no-hr-before-heading": true
}
}Via CLI:
textlint --rule @0x6b/no-hr-before-heading README.mdExamples
Invalid
---
# Heading
Some content
___
## Another HeadingValid
# Heading
Some content
---
More content
## Another HeadingFixable
This rule is automatically fixable using the --fix option. The horizontal rule and any whitespace between it and the heading will be removed.
Front Matter Support
This rule correctly handles YAML front matter in Markdown files. Front matter delimiters (---) are not treated as horizontal rules when properly formatted:
---
title: My Document
date: 2023-01-01
---
# HeadingThis is valid and will not trigger the rule because textlint's markdown parser includes remark-frontmatter support by default, which correctly parses front matter as a special node type rather than as horizontal rules.
Build
Builds source codes for publish to the lib/ folder.
pnpm install && pnpm run buildTest
Run test code in test folder by textlint-tester.
pnpm testReferences
License
MIT © 0x6b
