UNPKG

945 BTypeScriptView Raw
1/**
2 * The namespace for code block functions which help
3 * in extract code from markdown text
4 */
5export declare namespace MarkdownCodeBlocks {
6 const CODE_BLOCK_MARKER = "```";
7 class MarkdownCodeBlock {
8 startLine: number;
9 endLine: number;
10 code: string;
11 constructor(startLine: number);
12 }
13 /**
14 * Check whether the given file extension is a markdown extension
15 * @param extension - A file extension
16 *
17 * @returns true/false depending on whether this is a supported markdown extension
18 */
19 function isMarkdown(extension: string): boolean;
20 /**
21 * Construct all code snippets from current text
22 * (this could be potentially optimized if we can cache and detect differences)
23 * @param text - A string to parse codeblocks from
24 *
25 * @returns An array of MarkdownCodeBlocks.
26 */
27 function findMarkdownCodeBlocks(text: string): MarkdownCodeBlock[];
28}