UNPKG

front-matter-markdown

Version:

get the config and toc object from the markdown string.

46 lines (34 loc) 1.19 kB
(function() { var AstParser, getHeadingSection, getListSection, getToc, isArray, isString, list2FileObject, markdown, skipSpace; isString = require('util-ex/lib/is/type/string'); isArray = require('util-ex/lib/is/type/array'); markdown = require('./'); getHeadingSection = require('./get-heading-section'); getListSection = require('./get-list-section'); skipSpace = require('./skip-space'); AstParser = require('./ast-parser'); list2FileObject = require('./ast-list-to-file-object'); module.exports = getToc = function(aContent, headings, aOptions) { var links, result; if (isString(aContent)) { aContent = markdown.lexer(aContent); } links = aContent.links; result = getHeadingSection(aContent, headings); if (result) { result = getListSection(result); if (result) { result = skipSpace(result); result.links = links; result = AstParser.parse(result); if (result && result.length) { result = list2FileObject(result[0]); } else { result = null; } } } return result; }; }).call(this); //# sourceMappingURL=get-toc-from-list.js.map