Fix incorrect error in no-heading-content-indent

Fix an error in `no-heading-content-indent` which occurred if
said heading had no content.

Closes wooorm/remark@177.
This commit is contained in:
Titus Wormer 2016-04-26 13:28:24 +02:00
parent 31f5069954
commit 1f2e9a8a91
2 changed files with 16 additions and 1 deletions

View File

@ -59,6 +59,7 @@ function noHeadingContentIndent(ast, file, preferred, done) {
var depth = node.depth;
var children = node.children;
var type = style(node, 'atx');
var head;
var initial;
var final;
var diff;
@ -78,7 +79,17 @@ function noHeadingContentIndent(ast, file, preferred, done) {
}
index = depth + (index - initial.offset);
diff = start(children[0]).column - initial.column - 1 - index;
head = start(children[0]).column;
/*
* Ignore empty headings.
*/
if (!head) {
return;
}
diff = head - initial.column - 1 - index;
if (diff) {
word = diff > 0 ? 'Remove' : 'Add';

View File

@ -7,3 +7,7 @@ Foo
Bar
=====
<!-- Empty headers are fine -->
#####