front-matter-markdown
Version:
get the config and toc object from the markdown string.
43 lines (40 loc) • 940 B
JavaScript
(function() {
module.exports = function(nodes, aIndex, corrected) {
var end, index, level, node, start;
if (aIndex == null) {
aIndex = 0;
}
if (corrected == null) {
corrected = true;
}
index = -1;
level = 0;
start = null;
end = 0;
while (end < nodes.length) {
node = nodes[end++];
switch (node.type) {
case 'list_start':
if (level === 0) {
index++;
}
if (index === aIndex && !start) {
start = end - 1;
}
level++;
break;
case 'list_end':
level--;
if (level === 0 && index === aIndex) {
return nodes.slice(start, end);
}
break;
case 'loose_item_start':
if (corrected) {
node.type = 'list_item_start';
}
}
}
};
}).call(this);
//# sourceMappingURL=get-list-section.js.map