front-matter-markdown
Version:
get the config and toc object from the markdown string.
44 lines (37 loc) • 1.03 kB
JavaScript
(function() {
var isArray, isBoolean, isIn;
isIn = require('util-ex/lib/is/in');
isArray = require('util-ex/lib/is/type/array');
isBoolean = require('util-ex/lib/is/type/boolean');
module.exports = function(nodes, headings, caseSensitive) {
var end, node, result, start;
start = 0;
if (headings && !isArray(headings)) {
headings = [headings];
}
while (start < nodes.length) {
node = nodes[start++];
if (node.type === 'heading' && (!headings || isIn(node.text, headings, caseSensitive))) {
break;
}
}
if (start <= nodes.length && node.type === 'heading') {
end = start;
while (end < nodes.length) {
node = nodes[end++];
if (node.type === 'heading') {
break;
}
}
if (end !== nodes.length) {
end--;
}
if (start !== 0) {
start--;
}
result = nodes.slice(start, end);
}
return result;
};
}).call(this);
//# sourceMappingURL=get-heading-section.js.map