2017-02-23 20:07:52 +03:00
|
|
|
<!--This file is generated-->
|
|
|
|
|
|
|
|
# remark-lint-fenced-code-marker
|
|
|
|
|
|
|
|
Warn for violating fenced code markers.
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
Options: ``'`'``, `'~'`, or `'consistent'`, default: `'consistent'`.
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
`'consistent'` detects the first used fenced code marker style and warns
|
2019-06-20 11:51:46 +03:00
|
|
|
when subsequent fenced code blocks use different styles.
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-09-02 18:26:54 +03:00
|
|
|
## Fix
|
|
|
|
|
2017-12-08 17:39:26 +03:00
|
|
|
[`remark-stringify`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify)
|
2019-06-20 11:51:46 +03:00
|
|
|
formats fences using ``'`'`` (grave accent) by default.
|
|
|
|
Pass
|
2017-12-08 17:39:26 +03:00
|
|
|
[`fence: '~'`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsfence)
|
2019-06-20 11:51:46 +03:00
|
|
|
to use `~` (tilde) instead.
|
2017-09-02 18:26:54 +03:00
|
|
|
|
2019-06-20 11:51:46 +03:00
|
|
|
See [Using remark to fix your Markdown](https://github.com/remarkjs/remark-lint#using-remark-to-fix-your-markdown)
|
2017-09-02 18:26:54 +03:00
|
|
|
on how to automatically fix warnings for this rule.
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
## Presets
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
This rule is included in the following presets:
|
|
|
|
|
|
|
|
| Preset | Setting |
|
|
|
|
| ------ | ------- |
|
2017-12-08 17:39:26 +03:00
|
|
|
| [`remark-preset-lint-consistent`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-consistent) | `'consistent'` |
|
|
|
|
| [`remark-preset-lint-markdown-style-guide`](https://github.com/remarkjs/remark-lint/tree/master/packages/remark-preset-lint-markdown-style-guide) | ``'`'`` |
|
2017-02-23 20:07:52 +03:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
##### `valid.md`
|
|
|
|
|
|
|
|
###### In
|
2017-02-23 20:07:52 +03:00
|
|
|
|
|
|
|
```markdown
|
|
|
|
Indented code blocks are not affected by this rule:
|
|
|
|
|
|
|
|
bravo();
|
|
|
|
```
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
###### Out
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
No messages.
|
|
|
|
|
|
|
|
##### `invalid.md`
|
|
|
|
|
|
|
|
###### In
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
````markdown
|
2018-05-17 23:12:24 +03:00
|
|
|
```alpha
|
|
|
|
bravo();
|
|
|
|
```
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2018-05-17 23:12:24 +03:00
|
|
|
~~~
|
|
|
|
charlie();
|
|
|
|
~~~
|
2017-02-23 20:07:52 +03:00
|
|
|
````
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
###### Out
|
|
|
|
|
2017-02-23 20:07:52 +03:00
|
|
|
```text
|
2017-08-17 14:52:59 +03:00
|
|
|
5:1-7:4: Fenced code should use ` as a marker
|
2017-02-23 20:07:52 +03:00
|
|
|
```
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
##### `valid.md`
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
When configured with ``'`'``.
|
|
|
|
|
|
|
|
###### In
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
````markdown
|
2018-05-17 23:12:24 +03:00
|
|
|
```alpha
|
|
|
|
bravo();
|
|
|
|
```
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2018-05-17 23:12:24 +03:00
|
|
|
```
|
|
|
|
charlie();
|
|
|
|
```
|
2017-02-23 20:07:52 +03:00
|
|
|
````
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
###### Out
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
No messages.
|
|
|
|
|
|
|
|
##### `valid.md`
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
When configured with `'~'`.
|
|
|
|
|
|
|
|
###### In
|
|
|
|
|
|
|
|
```markdown
|
2018-05-17 23:12:24 +03:00
|
|
|
~~~alpha
|
|
|
|
bravo();
|
|
|
|
~~~
|
2017-02-23 20:07:52 +03:00
|
|
|
|
2018-05-17 23:12:24 +03:00
|
|
|
~~~
|
|
|
|
charlie();
|
|
|
|
~~~
|
2017-02-23 20:07:52 +03:00
|
|
|
```
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
###### Out
|
|
|
|
|
|
|
|
No messages.
|
|
|
|
|
|
|
|
##### `invalid.md`
|
|
|
|
|
|
|
|
When configured with `'!'`.
|
|
|
|
|
|
|
|
###### Out
|
2017-02-23 20:07:52 +03:00
|
|
|
|
|
|
|
```text
|
|
|
|
1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'`
|
|
|
|
```
|
|
|
|
|
2017-08-17 14:52:59 +03:00
|
|
|
## Install
|
|
|
|
|
|
|
|
```sh
|
|
|
|
npm install remark-lint-fenced-code-marker
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
You probably want to use it on the CLI through a config file:
|
|
|
|
|
|
|
|
```diff
|
|
|
|
...
|
|
|
|
"remarkConfig": {
|
|
|
|
"plugins": [
|
|
|
|
...
|
|
|
|
"lint",
|
|
|
|
+ "lint-fenced-code-marker",
|
|
|
|
...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
|
|
|
Or use it on the CLI directly
|
|
|
|
|
|
|
|
```sh
|
|
|
|
remark -u lint -u lint-fenced-code-marker readme.md
|
|
|
|
```
|
|
|
|
|
|
|
|
Or use this on the API:
|
|
|
|
|
|
|
|
```diff
|
|
|
|
var remark = require('remark');
|
|
|
|
var report = require('vfile-reporter');
|
|
|
|
|
|
|
|
remark()
|
|
|
|
.use(require('remark-lint'))
|
|
|
|
+ .use(require('remark-lint-fenced-code-marker'))
|
|
|
|
.process('_Emphasis_ and **importance**', function (err, file) {
|
|
|
|
console.error(report(err || file));
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2017-02-23 20:07:52 +03:00
|
|
|
## License
|
|
|
|
|
2018-11-22 14:18:12 +03:00
|
|
|
[MIT](https://github.com/remarkjs/remark-lint/blob/master/license) © [Titus Wormer](https://wooorm.com)
|