Socket
Socket
Sign inDemoInstall

remark-lint-fenced-code-marker

Package Overview
Dependencies
9
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

58

index.js

@@ -25,3 +25,3 @@ /**

*
* @example {"name": "valid.md"}
* @example {"name": "ok.md"}
*

@@ -32,3 +32,3 @@ * Indented code blocks are not affected by this rule:

*
* @example {"name": "valid.md", "setting": "`"}
* @example {"name": "ok.md", "setting": "`"}
*

@@ -43,3 +43,3 @@ * ```alpha

*
* @example {"name": "valid.md", "setting": "~"}
* @example {"name": "ok.md", "setting": "~"}
*

@@ -54,3 +54,3 @@ * ~~~alpha

*
* @example {"name": "invalid.md", "label": "input"}
* @example {"name": "not-ok-consistent-tick.md", "label": "input"}
*

@@ -65,9 +65,23 @@ * ```alpha

*
* @example {"name": "invalid.md", "label": "output"}
* @example {"name": "not-ok-consistent-tick.md", "label": "output"}
*
* 5:1-7:4: Fenced code should use ` as a marker
* 5:1-7:4: Fenced code should use `` ` `` as a marker
*
* @example {"name": "invalid.md", "setting": "!", "label": "output", "config": {"positionless": true}}
* @example {"name": "not-ok-consistent-tilde.md", "label": "input"}
*
* 1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'`
* ~~~alpha
* bravo();
* ~~~
*
* ```
* charlie();
* ```
*
* @example {"name": "not-ok-consistent-tilde.md", "label": "output"}
*
* 5:1-7:4: Fenced code should use `~` as a marker
*
* @example {"name": "not-ok-incorrect.md", "setting": "💩", "label": "output", "config": {"positionless": true}}
*
* 1:1: Incorrect fenced code marker `💩`: use either `'consistent'`, `` '`' ``, or `'~'`
*/

@@ -90,11 +104,11 @@

function fencedCodeMarker(tree, file, pref) {
function fencedCodeMarker(tree, file, option) {
var contents = String(file)
var preferred =
typeof option === 'string' && option !== 'consistent' ? option : null
pref = typeof pref === 'string' && pref !== 'consistent' ? pref : null
if (markers[pref] !== true) {
if (markers[preferred] !== true) {
file.fail(
'Invalid fenced code marker `' +
pref +
'Incorrect fenced code marker `' +
preferred +
"`: use either `'consistent'`, `` '`' ``, or `'~'`"

@@ -107,8 +121,11 @@ )

function visitor(node) {
var start
var marker
var label
if (!generated(node)) {
start = position.start(node).offset
marker = contents
.substr(position.start(node).offset, 4)
.trimLeft()
.slice(start, start + 4)
.replace(/^\s+/, '')
.charAt(0)

@@ -118,6 +135,7 @@

if (markers[marker] === true) {
if (pref) {
if (marker !== pref) {
if (preferred) {
if (marker !== preferred) {
label = preferred === '~' ? preferred : '` ` `'
file.message(
'Fenced code should use ' + pref + ' as a marker',
'Fenced code should use `' + label + '` as a marker',
node

@@ -127,3 +145,3 @@ )

} else {
pref = marker
preferred = marker
}

@@ -130,0 +148,0 @@ }

{
"name": "remark-lint-fenced-code-marker",
"version": "1.0.3",
"version": "1.0.4",
"description": "remark-lint rule to warn when fenced code markers violate the given style",

@@ -10,2 +10,3 @@ "license": "MIT",

"rule",
"remark-lint-rule",
"fenced",

@@ -17,2 +18,6 @@ "code",

"bugs": "https://github.com/remarkjs/remark-lint/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",

@@ -19,0 +24,0 @@ "contributors": [

@@ -42,3 +42,3 @@ <!--This file is generated-->

##### `valid.md`
##### `ok.md`

@@ -57,3 +57,3 @@ ###### In

##### `invalid.md`
##### `not-ok-consistent-tick.md`

@@ -75,7 +75,27 @@ ###### In

```text
5:1-7:4: Fenced code should use ` as a marker
5:1-7:4: Fenced code should use `` ` `` as a marker
```
##### `valid.md`
##### `not-ok-consistent-tilde.md`
###### In
````markdown
~~~alpha
bravo();
~~~
```
charlie();
```
````
###### Out
```text
5:1-7:4: Fenced code should use `~` as a marker
```
##### `ok.md`
When configured with ``'`'``.

@@ -99,3 +119,3 @@

##### `valid.md`
##### `ok.md`

@@ -120,5 +140,5 @@ When configured with `'~'`.

##### `invalid.md`
##### `not-ok-incorrect.md`
When configured with `'!'`.
When configured with `'💩'`.

@@ -128,3 +148,3 @@ ###### Out

```text
1:1: Invalid fenced code marker `!`: use either `'consistent'`, `` '`' ``, or `'~'`
1:1: Incorrect fenced code marker `💩`: use either `'consistent'`, `` '`' ``, or `'~'`
```

@@ -145,12 +165,12 @@

```diff
...
"remarkConfig": {
"plugins": [
...
"lint",
+ "lint-fenced-code-marker",
...
]
}
...
```

@@ -167,4 +187,4 @@

```diff
var remark = require('remark');
var report = require('vfile-reporter');
var remark = require('remark')
var report = require('vfile-reporter')

@@ -175,4 +195,4 @@ remark()

.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file));
});
console.error(report(err || file))
})
```

@@ -186,4 +206,4 @@

This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

@@ -217,3 +237,3 @@

[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg

@@ -220,0 +240,0 @@ [chat]: https://spectrum.chat/unified/remark

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc