UNPKG

@promptbook/remote-server

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

21 lines (20 loc) 1.04 kB
import type { string_markdown } from '../../types/string_markdown'; import type { MarkdownCodeBlock } from './extractAllBlocksFromMarkdown'; /** * Extracts exactly ONE code block from markdown. * * - When there are multiple or no code blocks the function throws a `ParseError` * * Note: There are multiple similar functions: * - `extractBlock` just extracts the content of the code block which is also used as built-in function for postprocessing * - `extractJsonBlock` extracts exactly one valid JSON code block * - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block * - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block * * @param markdown any valid markdown * @returns code block with language and content * @throws {ParseError} if there is not exactly one code block in the markdown * * @public exported from `@promptbook/markdown-utils` */ export declare function extractOneBlockFromMarkdown(markdown: string_markdown): MarkdownCodeBlock;