Skip to content

Commit

Permalink
Fix failure on block-quotes without children
Browse files Browse the repository at this point in the history
Rule: blockquote-indentation.

Closes GH-19.
  • Loading branch information
wooorm committed Aug 4, 2015
1 parent 34df79c commit a9aaff7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 55 deletions.
2 changes: 1 addition & 1 deletion lib/rules/blockquote-indentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function blockquoteIndentation(ast, file, preferred, done) {
var diff;
var word;

if (position.generated(node)) {
if (position.generated(node) || !node.children.length) {
return;
}

Expand Down
67 changes: 14 additions & 53 deletions mdast-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ function blockquoteIndentation(ast, file, preferred, done) {
var diff;
var word;

if (position.generated(node)) {
if (position.generated(node) || !node.children.length) {
return;
}

Expand Down Expand Up @@ -5495,30 +5495,11 @@ module.exports = attacher;
},{}],61:[function(require,module,exports){
'use strict';

/**
* Visit.
*
* @param {Node} tree
* @param {function(node)} callback
/*
* Dependencies.
*/
function visit(tree, callback) {
/**
* Visit a single node.
*/
function one(node) {
callback(node);

var children = node.children;
var index = -1;
var length = children ? children.length : 0;

while (++index < length) {
one(children[index]);
}
}

one(tree);
}
var visit = require('mdast-util-visit');

/**
* Calculate offsets for `lines`.
Expand Down Expand Up @@ -5681,7 +5662,7 @@ function attacher() {

module.exports = attacher;

},{}],62:[function(require,module,exports){
},{"mdast-util-visit":65}],62:[function(require,module,exports){
/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer. All rights reserved.
Expand Down Expand Up @@ -6036,6 +6017,12 @@ module.exports = visit;
},{}],66:[function(require,module,exports){
'use strict';

/*
* Dependencies.
*/

var visit = require('mdast-util-visit');

/*
* Methods.
*/
Expand Down Expand Up @@ -6119,32 +6106,6 @@ function marker(name) {
);
}

/**
* Visit.
*
* @param {Node} tree
* @param {function(node, parent)} callback
*/
function visit(tree, callback) {
/**
* Visit one node.
*
* @param {Node} node
* @param {number} index
*/
function one(node, index) {
var parent = this || null;

callback(node, parent, index);

if (node.children) {
node.children.forEach(one, node);
}
}

one(tree);
}

/**
* Parse `value` into an object.
*
Expand Down Expand Up @@ -6302,10 +6263,10 @@ function run(settings) {
* Passed intto `visit`.
*
* @param {Node} node
* @param {Node} parent
* @param {number} index
* @param {Node} parent
*/
function gather(node, parent, index) {
function gather(node, index, parent) {
var result = test(node);
var type = result && result.type;

Expand Down Expand Up @@ -6412,7 +6373,7 @@ function wrapper(options) {

module.exports = wrapper;

},{}],67:[function(require,module,exports){
},{"mdast-util-visit":65}],67:[function(require,module,exports){
'use strict';
module.exports = function (str, plural, count) {
if (typeof plural === 'number') {
Expand Down
2 changes: 1 addition & 1 deletion mdast-lint.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions test/fixtures/blockquote-indentation-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
<!-- -->

> Baz
<!-- -->

>
4 changes: 4 additions & 0 deletions test/fixtures/blockquote-indentation-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
<!-- -->

> Baz
<!-- -->

>

0 comments on commit a9aaff7

Please sign in to comment.