//#region src/lib/tree.d.ts type Compare = (current: T, next: T) => boolean; //#endregion //#region src/lib/toc-item.d.ts type TocItem = { level: number; text: string; id: string; href: string; source: TSource; children: TocItem[]; }; //#endregion //#region src/lib/md-list.d.ts type MdListOptions = { type?: "ol" | "ul"; }; /** * Given TOC items extracted from markdown headings, creates a markdown list of * references that point to those headings. * * @param items Array of nested TOC items. * @param options Options object. * @param options.type Type of list to use, ordered or unordered. * @param depth Initial indentation depth. * @returns A new markdown list. * @example * * const items = [ * { * level: 1, * text: 'First', * id: 'first', * href: '#first', * source: '# First', * children: [ * { * level: 2, * text: 'Second', * id: 'second', * href: '#second', * source: '## Second', * children: [ * { * level: 3, * text: 'Third', * id: 'third', * href: '#third', * source: '### Third', * children: [], * }, * ], * }, * ], * }, * ] * * mdList(items) * // => "1. [First](#first)\n 1. [Second](#second)\n 1. [Third](#third)" * * mdList(items, { type: 'ul' }) * // => "* [First](#first)\n * [Second](#second)\n * [Third](#third)" */ declare function mdList(items: TocItem[], options?: MdListOptions, depth?: number): string; //#endregion //#region src/lib/md-toc.d.ts type MdItemsOptions = { compare?: Compare; headings?: RegExp | ((text: string) => string[]); text?: (heading: string) => string; id?: (text: string, heading: string) => string; }; type MdTocOptions = MdListOptions & MdItemsOptions & { target?: RegExp; }; /** * Extract TOC items from markdown headings. * * @param input Markdown text. * @param options Options object. * @param options.compare Function used to compare hierarchy of headings. * @param options.headings Regex or function used to extract headings from * `text`. * @param options.text Function used to generate the visible heading text. * @param options.id Function used to generate the heading id. * @returns TOC items generated from the headings. */ declare function mdItems(input: string, options?: MdItemsOptions): TocItem[]; /** * Handy function to automagically generate a table of contents for a markdown * document. * * @param text Markdown text. * @param options Options object. * @param options.compare Function used to compare hierarchy of headings. * @param options.headings Regex or function used to extract headings from * `text`. * @param options.target Regex to search for text to be replaced with the table * of contents. * @returns The input text with a markdown list inserted at `target`. * @example * * const mdText = ` * * TOC * * # First * * Bla bla Bla. * * ## Second * * Bla. * * # Third * * End. * ` * * mdToc(mdText) * // => "\n\n1. [First](#first)\n 1. [Second](#second)\n2. [Third](#third)\n\n# First\n\nBla bla Bla.\n\n## Second\n\nBla.\n\n# Third\n\nEnd.\n" */ declare function mdToc(text: string, options?: MdTocOptions): string; //#endregion export { type MdItemsOptions, type MdListOptions, type MdTocOptions, type TocItem, mdItems, mdList, mdToc }; //# sourceMappingURL=md.d.ts.map