remark-lint/packages/remark-lint-fenced-code-marker/readme.md

164 lines
2.7 KiB
Markdown
Raw Normal View History

<!--This file is generated-->
# remark-lint-fenced-code-marker
Warn for violating fenced code markers.
Options: ``'`'``, `'~'`, or `'consistent'`, default: `'consistent'`.
`'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.
## 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.
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)
on how to automatically fix warnings for this rule.
## Presets
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) | ``'`'`` |
## Example
##### `valid.md`
###### In
```markdown
Indented code blocks are not affected by this rule:
bravo();
```
###### Out
No messages.
##### `invalid.md`
###### In
````markdown
2018-05-17 23:12:24 +03:00
```alpha
bravo();
```
2018-05-17 23:12:24 +03:00
~~~
charlie();
~~~
````
###### Out
```text
5:1-7:4: Fenced code should use ` as a marker
```
##### `valid.md`
When configured with ``'`'``.
###### In
````markdown
2018-05-17 23:12:24 +03:00
```alpha
bravo();
```
2018-05-17 23:12:24 +03:00
```
charlie();
```
````
###### Out
No messages.
##### `valid.md`
When configured with `'~'`.
###### In
```markdown
2018-05-17 23:12:24 +03:00
~~~alpha
bravo();
~~~
2018-05-17 23:12:24 +03:00
~~~
charlie();
~~~
```
###### Out
No messages.
##### `invalid.md`
When configured with `'!'`.
###### Out
```text
1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'`
```
## 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));
});
```
## License
2018-11-22 14:18:12 +03:00
[MIT](https://github.com/remarkjs/remark-lint/blob/master/license) © [Titus Wormer](https://wooorm.com)