extractMarkdownProps()function
extractMarkdownProps(text: string): { title: string | undefined; description: string | undefined }| Param | Type | |
|---|---|---|
text | string | The markdown source string (a markdown file's text, or a JSDoc description). required |
| Return | |
|---|---|
{ title: string | undefined; description: string | undefined } | An object whose title and description are each a plain string, or undefined when absent. |
Parse a markdown source string once and derive its title and description in a single pass.
title— plain text of the first# h1heading, orundefinedif there is none.description— plain-text summary of the first prose paragraph, orundefinedif there is none.- Both query the parsed markup tree, so inline syntax (
`code`,*emphasis*, links) resolves to clean plain text.
Examples
extractMarkdownProps("# Title\n\nSome intro.") // { title: "Title", description: "Some intro." }