markdownlint-rule-trace-template-headers
A custom markdownlint rule that provides the functionality to check the headers of a Markdown file based on the headers of a template file, verifying the match and order of the headers.
This package is compatible with markdownlint-cli2 and not markdownlint-cli.
Usage
CLI
-
Install dependencies.
npm install -D markdownlint-cli2 @lainNao/markdownlint-trace-template-headers
-
Create config file.
touch .markdownlint-cli2.jsonc
-
Edit
.markdownlint-cli2.jsonc
.- if markdownlint-rule-trace-template-headers is v2 or higher
{ "customRules": [ "markdownlint-rule-trace-template-headers" ], "config": { "markdownlint-rule-trace-template-headers": { "settings": [ { "templateFile": "YOUR_TEMPLATE_FILE.md", // template headers file "includedFiles": ["*.md"], // files to lint "excludedFiles": [] // files to exclude }, ... ] } } }
- if markdownlint-rule-trace-template-headers is v1 or lower
{ "customRules": [ "markdownlint-rule-trace-template-headers" ], "config": { "markdownlint-rule-trace-template-headers": { "templateFile": "YOUR_TEMPLATE_FILE.md", // template headers file "includedFiles": ["*.md"], // files to lint "excludedFiles": [] // files to exclude } } }
-
Run lint.
npx markdownlint-cli2 SOME_MARKDOWN_FILE.md
VSCode
- Install
markdownlint
in your VSCode extensions marketplace. - Create and edit
.markdownlint-cli2.jsonc
like above. - Verify the lint rule works works in Editor.
Other
To disable the rule, edit .markdownlint-cli2.jsonc
.
{
"customRules": [
"markdownlint-rule-trace-template-headers"
],
"config": {
"markdownlint-rule-trace-template-headers": false // change this value to falsy
}
}
TODO
- Improve CI/CD. Add auto tests and auto versioning, updating changelog, release scripts.
- Create CONTRIBUTION.md
- Config to select error/warn