Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!generated(node) && children) {
head = children[0]
if (head && !generated(head)) {
// Compare parent and first child.
compare(position.start(node), position.start(head), 0)
// Compare between each child.
children.forEach(visitChild)
tail = children[children.length - 1]
// Compare parent and last child.
if (tail !== head && !generated(tail)) {
compare(position.end(node), position.end(tail), 1)
}
}
}
}
visit(tree, function (node, index, parent) {
var next = parent && parent.children[index + 1];
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
visit(tree, (node, index, parent) => {
const next = parent && parent.children[index + 1];
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
function validate(node) {
var start = position.start(node).offset
var end = position.end(node).offset
var value
if (!generated(node)) {
value = contents.slice(start, end).match(label)[1]
if (value !== value.toLowerCase()) {
file.message(reason, node)
}
}
}
}
if (right.type === 'element' && data.hProperties) {
right.properties = Object.assign({}, right.properties, data.hProperties)
}
if (right.children && data.hChildren) {
right.children = data.hChildren
}
}
ctx = left && left.position ? left : {position: left}
if (!generated(ctx)) {
right.position = {
start: position.start(ctx),
end: position.end(ctx)
}
}
return right
}
function visitor(node, index, parent) {
var next
if (!generated(node) && parent && (!allow || parent.type !== 'listItem')) {
next = parent.children[index + 1]
if (
next &&
types.indexOf(next.type) !== -1 &&
position.start(next).line === position.end(node).line + 1
) {
file.message(reason, next)
}
}
}
}
out[pos] = h(cell, name, { align: align[pos] }, cell ? all(h, cell) : [])
}
result[index] = h(rows[index], 'tr', wrap(out, true))
}
return h(
node,
'table',
wrap(
[
h(result[0].position, 'thead', wrap([result[0]], true)),
h(
{
start: position.start(result[1]),
end: position.end(result[result.length - 1])
},
'tbody',
wrap(result.slice(1), true)
)
],
true
)
)
}
function visitChild(child, index, all) {
var prev = all[index - 1]
var max = 2
if (prev && !generated(prev) && !generated(child)) {
if (
(prev.type === 'list' && child.type === 'list') ||
(child.type === 'code' && prev.type === 'list' && !child.lang)
) {
max++
}
compare(position.end(prev), position.start(child), max)
}
}
}