Skip to content

Commit

Permalink
Update MD030/list-marker-space to allow bare list item markers for te…
Browse files Browse the repository at this point in the history
…mplating scenarios (fixes #235).
  • Loading branch information
DavidAnson committed Dec 11, 2019
1 parent 6f3c67f commit 5ae5e44
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 41 deletions.
36 changes: 19 additions & 17 deletions lib/md030.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,26 @@ module.exports = {
const { line, lineNumber } = item;
const match = /^[\s>]*\S+(\s*)/.exec(line);
const [ { "length": matchLength }, { "length": actualSpaces } ] = match;
let fixInfo = null;
if ((expectedSpaces !== actualSpaces) && (line.length > matchLength)) {
fixInfo = {
"editColumn": matchLength - actualSpaces + 1,
"deleteCount": actualSpaces,
"insertText": "".padEnd(expectedSpaces)
};
if (matchLength < line.length) {
let fixInfo = null;
if (expectedSpaces !== actualSpaces) {
fixInfo = {
"editColumn": matchLength - actualSpaces + 1,
"deleteCount": actualSpaces,
"insertText": "".padEnd(expectedSpaces)
};
}
addErrorDetailIf(
onError,
lineNumber,
expectedSpaces,
actualSpaces,
null,
null,
[ 1, matchLength ],
fixInfo
);
}
addErrorDetailIf(
onError,
lineNumber,
expectedSpaces,
actualSpaces,
null,
null,
[ 1, matchLength ],
fixInfo
);
});
});
}
Expand Down
31 changes: 27 additions & 4 deletions test/bare-list-markers.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
# Bare List Markers

## Ordered 1/1/1

1.
1.
1.

## Ordered 1/2/3

1.
2.
3.

## Unordered *

*
*
*

## Unordered +

+
+
+

-
## Unordered -

1.
-
-
-

{MD004:3}{MD004:5}
{MD030:1}{MD030:3}{MD030:5}{MD030:7}
<!-- markdownlint-disable-file ul-style -->
8 changes: 8 additions & 0 deletions test/detailed-results-MD030-warning-message.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#

-
(bare list item marker)

1.
(bare list item marker)

-a
(not a list item)

1.a
(not a list item)

- a

Expand Down
8 changes: 8 additions & 0 deletions test/detailed-results-MD030-warning-message.md.fixed
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#

-
(bare list item marker)

1.
(bare list item marker)

-a
(not a list item)

1.a
(not a list item)

- a

Expand Down
22 changes: 2 additions & 20 deletions test/detailed-results-MD030-warning-message.results.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
[
{
"lineNumber": 3,
"ruleNames": [ "MD030", "list-marker-space" ],
"ruleDescription": "Spaces after list markers",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
"errorDetail": "Expected: 1; Actual: 0",
"errorContext": null,
"errorRange": [1, 1]
},
{
"lineNumber": 5,
"ruleNames": [ "MD030", "list-marker-space" ],
"ruleDescription": "Spaces after list markers",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
"errorDetail": "Expected: 1; Actual: 0",
"errorContext": null,
"errorRange": [1, 2]
},
{
"lineNumber": 11,
"lineNumber": 19,
"ruleNames": [ "MD030", "list-marker-space" ],
"ruleDescription": "Spaces after list markers",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
Expand All @@ -27,7 +9,7 @@
"errorRange": [1, 3]
},
{
"lineNumber": 13,
"lineNumber": 21,
"ruleNames": [ "MD030", "list-marker-space" ],
"ruleDescription": "Spaces after list markers",
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
Expand Down

0 comments on commit 5ae5e44

Please sign in to comment.