Fix hard-break-spaces in indented blocks

Closes GH-31.
This commit is contained in:
Titus Wormer 2015-12-27 20:43:52 +01:00
parent d0264d2432
commit a427c59a35
4 changed files with 12 additions and 2 deletions

View File

@ -43,12 +43,15 @@ function hardBreakSpaces(ast, file, preferred, done) {
visit(ast, 'break', function (node) {
var start = position.start(node).offset;
var end = position.end(node).offset;
var value;
if (position.generated(node)) {
return;
}
if (contents.slice(start, end).length > 3) {
value = contents.slice(start, end).split('\n', 1)[0];
if (value.length > 2) {
file.warn('Use two spaces for hard line breaks', node);
}
});

View File

@ -1,5 +1,8 @@
Heres one that uses too
much white space.
- A bullet with three trailing spaces
Next line.
And heres a commonmark\
break.

View File

@ -1,5 +1,8 @@
Heres one that uses too
just enough white space.
- A bullet with two trailing spaces
Next line.
And heres another
break.

View File

@ -1214,7 +1214,8 @@ describe('Rules', function () {
describeRule('hard-break-spaces', function () {
describeSetting(true, function () {
assertFile('hard-break-spaces-invalid.md', [
'hard-break-spaces-invalid.md:1:25-2:1: Use two spaces for hard line breaks'
'hard-break-spaces-invalid.md:1:25-2:1: Use two spaces for hard line breaks',
'hard-break-spaces-invalid.md:4:40-5:5: Use two spaces for hard line breaks'
]);
assertFile('hard-break-spaces-valid.md', []);