(markdown: string)
| 28 | lang: string | undefined; |
| 29 | }; |
| 30 | function extractCodeBlocks(markdown: string): CodeBlock[] { |
| 31 | const tokens = marked.lexer(stripPromptXMLTags(markdown)); |
| 32 | const blocks: CodeBlock[] = []; |
| 33 | for (const token of tokens) { |
| 34 | if (token.type === 'code') { |
| 35 | const codeToken = token as Tokens.Code; |
| 36 | blocks.push({ |
| 37 | code: codeToken.text, |
| 38 | lang: codeToken.lang |
| 39 | }); |
| 40 | } |
| 41 | } |
| 42 | return blocks; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Walk messages newest-first, returning text from assistant messages that |
no test coverage detected