All Projects → igorshubovych → Markdownlint Cli

igorshubovych / Markdownlint Cli

Licence: mit
MarkdownLint Command Line Interface

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Markdownlint Cli

Gatsby Theme Code Notes
A Gatsby theme for publishing code-related notes to your website
Stars: ✭ 370 (-4.88%)
Mutual labels:  markdown
Marktext
📝A simple and elegant markdown editor, available for Linux, macOS and Windows.
Stars: ✭ 22,894 (+5785.35%)
Mutual labels:  markdown
Mark Mind
MarkMind — a mind map and outliner editor for Windows, Mac, Linux, andriod and ios ,it support markdown in node.
Stars: ✭ 385 (-1.03%)
Mutual labels:  markdown
Mistletoe
A fast, extensible and spec-compliant Markdown parser in pure Python.
Stars: ✭ 368 (-5.4%)
Mutual labels:  markdown
React Md Editor
A simple markdown editor with preview, implemented with React.js and TypeScript.
Stars: ✭ 374 (-3.86%)
Mutual labels:  markdown
Commonmarkattributedstring
Create NSAttributedStrings from Markdown Text
Stars: ✭ 382 (-1.8%)
Mutual labels:  markdown
Marpit
The skinny framework for creating slide deck from Markdown
Stars: ✭ 364 (-6.43%)
Mutual labels:  markdown
Summarytools
R Package to Quickly and Neatly Summarize Data
Stars: ✭ 390 (+0.26%)
Mutual labels:  markdown
Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (-3.86%)
Mutual labels:  markdown
Gostatic
Fast static site generator
Stars: ✭ 387 (-0.51%)
Mutual labels:  markdown
Markdeep
Official public Markdeep source archive
Stars: ✭ 373 (-4.11%)
Mutual labels:  markdown
Git Tutor
+md=❤️ Awesome tutorials from your git log
Stars: ✭ 376 (-3.34%)
Mutual labels:  markdown
Forum Java
一款用 Java(spring boot) 实现的现代化社区(论坛/问答/BBS/社交网络/博客)系统平台。A modern community (forum/Q&A/BBS/SNS/blog) system platform implemented in Java(spring boot).
Stars: ✭ 380 (-2.31%)
Mutual labels:  markdown
Efmarkdown
DEPRECATED
Stars: ✭ 370 (-4.88%)
Mutual labels:  markdown
React Native Simple Markdown
📜 React Native Markdown component (iOS & Android).
Stars: ✭ 389 (+0%)
Mutual labels:  markdown
Richtext
Android平台下的富文本解析器,支持Html和Markdown
Stars: ✭ 3,715 (+855.01%)
Mutual labels:  markdown
Readme
👋 - The documentation for being an Artsy Engineer
Stars: ✭ 380 (-2.31%)
Mutual labels:  markdown
Doctor
Doctor is a documentation server for your docs in github
Stars: ✭ 391 (+0.51%)
Mutual labels:  markdown
Editormd
Markdown 编辑器 Editor.md for Typecho
Stars: ✭ 389 (+0%)
Mutual labels:  markdown
Github Markdown Toc.go
Easy TOC creation for GitHub README.md (in go)
Stars: ✭ 387 (-0.51%)
Mutual labels:  markdown

markdownlint-cli

GitHub Actions Build Status

Command Line Interface for MarkdownLint

Installation

npm install -g markdownlint-cli

On macOS you can install via Homebrew:

brew install markdownlint-cli

Usage

markdownlint --help

  Usage: markdownlint [options] <files|directories|globs>

  MarkdownLint Command Line Interface

  Options:

    -h, --help                                  output usage information
    -V, --version                               output the version number
    -c, --config [configFile]                   configuration file (JSON, JSONC, JS, or YAML)
    -d, --dot                                   include files/folders with a dot (for example `.github`)
    -f, --fix                                   fix basic errors (does not work with STDIN)
    -i, --ignore [file|directory|glob]          file(s) to ignore/exclude
    -o, --output [outputFile]                   write issues to file (no console)
    -p, --ignore-path [file]                    path to file with ignore pattern(s)
    -r, --rules  [file|directory|glob|package]  custom rule files
    -s, --stdin                                 read from STDIN (does not work with files)

Globbing

markdownlint-cli supports advanced globbing patterns like **/*.md (more information). With shells like Bash, it may be necessary to quote globs so they are not interpreted by the shell. For example, --ignore *.md would be expanded by Bash to --ignore a.md b.md ... before invoking markdownlint-cli, causing it to ignore only the first file because --ignore takes a single parameter (though it can be used multiple times). Quoting the glob like --ignore '*.md' passes it through unexpanded and ignores the set of files.

Globbing examples

To lint all Markdown files in a Node.js project (excluding dependencies), the following commands might be used:

Windows CMD: markdownlint **/*.md --ignore node_modules

Linux Bash: markdownlint '**/*.md' --ignore node_modules

Ignoring files

If present in the current folder, a .markdownlintignore file will be used to ignore files and/or directories according to the rules for gitignore. If the -p/--ignore-path option is present, the specified file will be used instead of .markdownlintignore.

The order of operations is:

  • Enumerate files/directories/globs passed on the command line
  • Apply exclusions from -p/--ignore-path (if specified) or .markdownlintignore (if present)
  • Apply exclusions from any -i/--ignore option(s) that are specified

Fixing errors

When the --fix option is specified, markdownlint-cli tries to apply all fixes reported by the active rules and reports any errors that remain. Because this option makes changes to the input files, it is good to make a backup first or work with files under source control so any unwanted changes can be undone.

Because not all rules include fix information when reporting errors, fixes may overlap, and not all errors are fixable, --fix will not usually address all errors.

Configuration

markdownlint-cli reuses the rules from markdownlint package.

Configuration is stored in JSON, JSONC, YAML, or INI files in the same config format.

A sample configuration file:

{
  "default": true,
  "MD003": { "style": "atx_closed" },
  "MD007": { "indent": 4 },
  "no-hard-tabs": false,
  "whitespace": false
}

For more examples, see .markdownlint.jsonc, .markdownlint.yaml, or the style folder.

The CLI argument --config is not required. If it is not provided, markdownlint-cli looks for the file .markdownlint.json/.markdownlint.yaml/.markdownlint.yml in current folder, or for the file .markdownlintrc in the current or all parent folders. The algorithm is described in detail on the rc package page. If the --config argument is provided, the file must be valid JSON, JSONC, JS, or YAML. JS configuration files contain JavaScript code, must have the .js extension, and must export (via module.exports = ...) a configuration object of the form shown above. A JS configuration file may internally require one or more npm packages as a way of reusing configuration across projects.

JS configuration files must be provided via the --config argument; they are not automatically loaded because running untrusted code is a security concern.

Exit codes

markdownlint-cli returns one of the following exit codes:

  • 0: Program ran successfully
  • 1: Linting errors / bad parameter
  • 2: Unable to write -o/--output output file
  • 3: Unable to load -r/--rules custom rule

Use with pre-commit

To run markdownlint-cli as part of a pre-commit workflow, add something like the below to the repos list in the project's .pre-commit-config.yaml:

- repo: https://github.com/igorshubovych/markdownlint-cli
  rev: v0.27.1
  hooks:
  - id: markdownlint

Depending on the environment this workflow runs in, it may be necessary to override the language version of Node.js used by pre-commit.

Related

  • markdownlint - API for this module
  • glob - Pattern matching implementation
  • ignore - .markdownlintignore implementation

License

MIT © Igor Shubovych

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].