Skip to content

Commit

Permalink
Add support for inline warning control
Browse files Browse the repository at this point in the history
This update adds support for per paragraph message silencing
(`ignore`), turning off messages (`disable`) and turning on messages
(`enable`) through HTML comment markers in markdown.

For example:

```md
<!--alex ignore dad-mom-->

A window will **not** pop up.
```

Yields:

```txt
readme.md: no issues found
```

Closes GH-16.
  • Loading branch information
wooorm committed Feb 3, 2016
1 parent 409c3cd commit 89dd779
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
var VFile = require('vfile');
var remark = require('remark');
var retext = require('retext');
var control = require('remark-message-control');
var english = require('retext-english');
var equality = require('retext-equality');
var remark2retext = require('remark-retext');
Expand All @@ -29,7 +30,10 @@ var sort = require('vfile-sort');
*/

var text = retext().use(english).use(equality);
var markdown = remark().use(remark2retext, text);
var markdown = remark().use(remark2retext, text).use(control, {
'name': 'alex',
'source': 'retext-equality'
});

/**
* Wrap the given processor.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
"get-stdin": "^5.0.0",
"glob": "^6.0.1",
"globby": "^4.0.0",
"remark": "^3.0.0",
"meow": "^3.3.0",
"minimatch": "^3.0.0",
"remark": "^3.0.0",
"remark-message-control": "^1.0.1",
"remark-retext": "^1.1.0",
"retext": "^1.0.0",
"retext-english": "^1.0.0",
Expand Down
71 changes: 71 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ $ npm install alex --global

* [.alexignore](#alexignore)

* [Ignoring messages](#ignoring-messages)

* [Workflow](#workflow)

* [FAQ](#faq)
Expand Down Expand Up @@ -219,6 +221,75 @@ components/
example.md
```

## Ignoring messages

Sometimes, **alex** makes mistakes:

```md
A window will pop up.
```

Yields:

```txt
readme.md
1:15-1:18 warning `pop` may be insensitive, use `parent` instead dad-mom
⚠ 1 warning
```

**alex** can silence message through HTML comments in markdown:

```md
<!--alex ignore dad-mom-->

A window will **not** pop up.
```

Yields:

```txt
readme.md: no issues found
```

`ignore` turns off messages for the thing after the comment (in this
case, the paragraph).
It’s also possible to turn off messages after a comment by using
`disable`, and, turn those messages back on using `enable`:

```md
<!--alex disable dad-mom-->

A window will **not** pop up.

A window will **not** pop up.

<!--alex enable dad-mom-->

A window will pop up.
```

Yields:

```txt
readme.md
9:15-9:18 warning `pop` may be insensitive, use `parent` instead dad-mom
⚠ 1 warning
```

Multiple messages can be controlled in one go:

```md
<!--alex disable he-her his-hers dad-mom-->
```

...and all messages can be controlled by omitting all rule identifiers:

```md
<!--alex ignore-->
```

## Workflow

The recommended workflow is to add **alex** locally and to run it with your
Expand Down

0 comments on commit 89dd779

Please sign in to comment.