plugins to check (lint) markdown code style
Go to file
Titus Wormer 136e7608b4 Add gap support
Gaps are nodes of (re)generated content, without positional
information, which are therefore impossible to warn about.
This feature adds support of the detection of those, and ignores
warnings for already removed content.

Closes GH-8.
2015-06-29 19:26:15 +02:00
doc Add checkbox-content-indent rule 2015-06-20 17:36:51 +02:00
lib Add gap support 2015-06-29 19:26:15 +02:00
script Add support for external rules 2015-06-13 12:08:21 +02:00
test Add gap support 2015-06-29 19:26:15 +02:00
.editorconfig Initial commit 2015-06-11 18:07:00 +02:00
.eslintignore Initial commit 2015-06-11 18:07:00 +02:00
.eslintrc Initial commit 2015-06-11 18:07:00 +02:00
.gitignore Initial commit 2015-06-11 18:07:00 +02:00
.jscs.json Initial commit 2015-06-11 18:07:00 +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 Update .travis.yml 2015-06-11 18:17:39 +02:00
bower.json Initial commit 2015-06-11 18:07:00 +02:00
component.json 0.3.0 2015-06-20 17:39:56 +02:00
example.js Initial commit 2015-06-11 18:07:00 +02:00
history.md 0.3.0 2015-06-20 17:39:56 +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 Add gap support 2015-06-29 19:26:15 +02:00
mdast-lint.min.js Add gap support 2015-06-29 19:26:15 +02:00
package.json Update mdast 2015-06-28 17:27:33 +02:00
readme.md Add gap support 2015-06-29 19:26:15 +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 build 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, component, 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 👍

License

MIT © Titus Wormer