What is markdownlint-cli?
The markdownlint-cli package is a command-line interface for the markdownlint library, which is used to lint Markdown files. It helps ensure that Markdown files adhere to a consistent style and are free of common errors.
What are markdownlint-cli's main functionalities?
Linting a single file
This command lints a single Markdown file (README.md) and outputs any issues found according to the default rules.
markdownlint README.md
Linting multiple files
This command lints all Markdown files in the 'docs' directory and its subdirectories, using a glob pattern to match the files.
markdownlint "docs/**/*.md"
Using a custom configuration file
This command lints the README.md file using a custom configuration file (.markdownlint.json) to specify the rules and options.
markdownlint -c .markdownlint.json README.md
Fixing linting issues automatically
This command attempts to automatically fix any linting issues found in the README.md file.
markdownlint --fix README.md
Ignoring specific files or directories
This command lints all Markdown files in the current directory, but ignores the 'node_modules' directory.
markdownlint . --ignore node_modules
Other packages similar to markdownlint-cli
remark-cli
remark-cli is a command-line interface for the remark library, which is a Markdown processor powered by plugins. It can be used to lint, format, and transform Markdown files. Compared to markdownlint-cli, remark-cli offers more flexibility through its plugin system, allowing for a wider range of transformations and customizations.
markdown-it
markdown-it is a Markdown parser that can be extended with plugins to add custom rules and transformations. While it is primarily used for parsing and rendering Markdown, it can also be used for linting with the appropriate plugins. markdown-it is more focused on parsing and rendering, whereas markdownlint-cli is specifically designed for linting.
markdown-lint
markdown-lint is another linter for Markdown files, similar to markdownlint-cli. It provides a set of rules to enforce consistent style and catch common errors. However, markdown-lint is less feature-rich and less actively maintained compared to markdownlint-cli.
markdownlint-cli
Command Line Interface for MarkdownLint
Installation
npm install -g markdownlint-cli
Usage
$ markdownlint --help
Usage: markdownlint [options] <files>
MarkdownLint Command Line Interface
Options:
-h, --help output usage information
-V, --version output the version number
-c, --config [configFile] Configuration file
Configuration
markdownlint-cli
reuses the rules from markdownlint
package.
Configuration is stored JSON or INI files in the same config format.
The example of configuration file:
{
"default": true,
"MD003": { "style": "atx_closed" },
"MD007": { "indent": 4 },
"no-hard-tabs": false,
"whitespace": false
}
See test configuration file or style folder for more examples.
CLI argument --config
is not mandatory. If it is not provided, markdownlint-cli
looks for file .markdownlint.json
in current folder, or for file .markdownlintrc
in current or all upper folders. The algorithm is described in details on rc package page.
Related
License
MIT © Igor Shubovych