UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

30 lines (29 loc) 1.58 kB
import { type FileElementProps } from "../util/element.js"; import { FileExtractor } from "./FileExtractor.js"; /** * File extractor for Markdown files. * - Stores the markdown text as `content`; rendering happens at output time via `<Markup>`. * - Sets `title` from the first `# h1` heading if one is present — otherwise leaves it undefined * (a confident title only). * - When a `title` is found, strips the leading `# h1` from `content` so renderers (which show * `title` separately) don't display the heading twice. * - Sets `description` to the first prose paragraph as a plain-text summary (used for card listings and `<meta>`). */ export declare class MarkupExtractor extends FileExtractor { extractProps(name: string, text: string): Partial<FileElementProps> & { name: string; }; } /** * Parse a markdown source string once and derive its `title` and `description` in a single pass. * - `title` — plain text of the first `# h1` heading, or `undefined` if there is none. * - `description` — plain-text summary of the first prose paragraph, or `undefined` if there is none. * - Both query the parsed markup tree, so inline syntax (`` `code` ``, `*emphasis*`, links) resolves to clean plain text. * * @param text The markdown source string (a markdown file's text, or a JSDoc description). * @returns An object whose `title` and `description` are each a plain string, or `undefined` when absent. */ export declare function extractMarkdownProps(text: string): { title: string | undefined; description: string | undefined; };