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

163 lines
2.8 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
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)
formats fences using a backtick (``'`'``) by default. Pass
2017-12-08 17:39:26 +03:00
[`fence: '~'`](https://github.com/remarkjs/remark/tree/master/packages/remark-stringify#optionsfence)
to use tildes instead.
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
```alpha
bravo();
```
~~~
charlie();
~~~
````
###### Out
```text
5:1-7:4: Fenced code should use ` as a marker
```
##### `valid.md`
When configured with ``'`'``.
###### In
````markdown
```alpha
bravo();
```
```
charlie();
```
````
###### Out
No messages.
##### `valid.md`
When configured with `'~'`.
###### In
```markdown
~~~alpha
bravo();
~~~
~~~
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
2017-12-08 17:39:26 +03:00
[MIT](https://github.com/remarkjs/remark-lint/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com)