mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-09-11 19:57:15 +03:00
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:
parent
31f5069954
commit
1f2e9a8a91
@ -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';
|
||||
|
4
test/fixtures/no-heading-indent-valid.md
vendored
4
test/fixtures/no-heading-indent-valid.md
vendored
@ -7,3 +7,7 @@ Foo
|
||||
|
||||
Bar
|
||||
=====
|
||||
|
||||
<!-- Empty headers are fine -->
|
||||
|
||||
#####
|
||||
|
Loading…
Reference in New Issue
Block a user