import type Slugger from 'github-slugger'; import type { Lexer, Tokens, TokensList } from 'marked'; /** * A markdown header */ export type MarkdownHeader = { id: string; depth: number; text: string; }; export declare enum IndexableMarkdownType { SECTION = "section", HEADER = "header" } /** * A section of text that is indexed. This is everything that is found under a title or that has no title at all. */ export type IndexableMarkdownSection = { type: IndexableMarkdownType.SECTION; /*** * The header list leading to this markdown section. They will be in order of depth. */ headers: MarkdownHeader[]; /** * The content used for the full text search in this section. */ content: string; }; /** * A markdown header that is indexed. Headers receive a higher scoring than sections. */ export type IndexableMarkdownHeader = { type: IndexableMarkdownType.HEADER; /** * The path that leads to this header. */ path: MarkdownHeader[]; /** * The title of this header. */ title: string; }; export type IndexableMarkdownPart = IndexableMarkdownSection | IndexableMarkdownHeader; export type TextExtractor = (token: Tokens.Generic, extract: ExtractFunction) => string; export type ExtractFunction = (tokens: Tokens.Generic[]) => string; export type TextExtractors = Record; export type Options = { slugger: Slugger; lexer: Lexer; extractors: TextExtractors; }; export declare function extract(source: string, options: Options): IndexableMarkdownPart[]; export declare function extractTokens(tokens: TokensList, options: Options): IndexableMarkdownPart[]; export declare function extractFunction(extractors: TextExtractors): ExtractFunction;