plugins to check (lint) markdown code style
Go to file
2015-08-08 15:34:40 +02:00
doc Remove maximum-line-length warnings on definitions 2015-08-05 10:06:42 +02:00
lib Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
script Update eslint, jscs, browserify 2015-08-08 15:30:32 +02:00
test Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
.editorconfig Initial commit 2015-06-11 18:07:00 +02:00
.eslintignore Update eslint, jscs, browserify 2015-08-08 15:30:32 +02:00
.eslintrc Update eslint, jscs, browserify 2015-08-08 15:30:32 +02:00
.gitignore Initial commit 2015-06-11 18:07:00 +02:00
.jscs.json Update eslint, jscs, browserify 2015-08-08 15:30:32 +02:00
.mdastignore Initial commit 2015-06-11 18:07:00 +02:00
.mdastrc Remove mdast-usage, add mdast-yaml-config as dependencies 2015-06-13 12:28:09 +02:00
.travis.yml Remove travis deploy 2015-07-12 21:38:23 +02:00
bower.json Update eslint, jscs, browserify 2015-08-08 15:30:32 +02:00
component.json Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
history.md 0.4.4 2015-08-05 10:07:54 +02:00
index.js Initial commit 2015-06-11 18:07:00 +02:00
LICENSE Initial commit 2015-06-11 18:07:00 +02:00
logo.svg Initial commit 2015-06-11 18:07:00 +02:00
mdast-lint.js Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
mdast-lint.min.js Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
package.json Replace mdast-util-visit with unist-util-visit 2015-08-08 15:34:40 +02:00
readme.md Add linter-markdown to readme.md 2015-08-04 11:09:28 +02:00
screen-shot.png Initial commit 2015-06-11 18:07:00 +02:00

mdast-lint

Build Status Coverage Status

mdast-lint is a markdown code style linter. Another linter? Yes. Ensuring the markdown you (and contributors) write is of great quality will provide better rendering in all the different markdown parsers, and makes sure less refactoring is needed afterwards. What is quality? Thats up to you, but the defaults are sensible 👌.

mdast-lint has lots of tests. Supports Node, io.js, and the browser. 100% coverage. 50+ rules. Its built on mdast, a powerful markdown processor powered by plugins (such as this one).

Table of Contents

Installation

npm:

npm install mdast-lint

mdast-lint is also available for bower, duo, and for AMD, CommonJS, and globals.

Command line

Example how mdast-lint looks on screen

Use mdast-lint together with mdast:

npm install --global mdast mdast-lint

Lets say example.md looks as follows:

* Hello

-   World

Then, to run mdast-lint on example.md:

mdast -u mdast-lint example.md
#
# Yields:
#
# example.md
#   1:3  warning  Incorrect list-item content indent: add 2 spaces  list-item-indent
#   3:1  warning  Invalid ordered list item marker: should be `*`   unordered-list-marker-style
#
# ✖ 2 problems (0 errors, 2 warnings)
#
# *   Hello
#
#
# *   World
#

See doc/rules.md for what those warnings are (and how to turn them off).

Programmatic

doc/api.md describes how to use mdast-lints programatic interface in JavaScript.

Rules

doc/rules.md describes all available rules, what they check for, examples of markdown they warn for, and how to fix their warnings.

Configuring mdast-lint

mdast-lint is just an mdast plug-in. Meaning, you can opt to configure using configuration files. Read more about these files (.mdastrc or package.json) in mdasts docs.

An example .mdastrc file could look as follows:

{
  "plugins": {
    "lint": {
        "no-multiple-toplevel-headings": false,
        "maximum-line-length": 79,
        "emphasis-marker": "_",
        "strong-marker": "*"
    }
  },
  "settings": {
    "commonmark": true
  }
}

Where the object at plugins.lint is a map of ruleIds and their values. The object at settings determines how mdast parses (and compiles) markdown code. Read more about the latter on mdasts readme.

In addition, you can also provide configuration comments to turn a rule on or off inside a file (note that you cannot change what a setting, such as maximum-line-length, youre either enabling or disabling warnings).

The following file will warn twice for the duplicate headings:

# Hello

## Hello

### Hello

The following file will warn once (the second heading is ignored, but the third is re-enabled):

# Hello

<!--lint disable no-duplicate-headings-->

## Hello

<!--lint enable no-duplicate-headings-->

### Hello

Using mdast to fix your markdown

One of mdasts cool parts is that it compiles to very clean, and highly cross-vendor supported markdown. Itll ensure list items use a single bullet, emphasis and strong use a standard marker, and that your table fences are aligned.

mdast should be able to fix most of your styling issues automatically, and I strongly suggest checking out how it can make your life easier 👍

Editor Integrations

Currently, mdast-lint is integrated with Atom through leipert/linter-markdown.

Im very interested in more integrations. Let me know if I can help.

License

MIT © Titus Wormer