( content: string, )
| 62 | }; |
| 63 | |
| 64 | const findCodeBlocks = ( |
| 65 | content: string, |
| 66 | ): Array<{ type: string; content: string }> => { |
| 67 | const tokens = parseMarkdown(content); |
| 68 | const codeBlocks: Array<{ type: string; content: string }> = []; |
| 69 | |
| 70 | function walkTokens(tokenList: unknown[]) { |
| 71 | for (const token of tokenList) { |
| 72 | const t = token as { type: string; text: string; tokens?: unknown[] }; |
| 73 | if (t.type === 'code') { |
| 74 | codeBlocks.push({ |
| 75 | type: 'code_block', |
| 76 | content: t.text, |
| 77 | }); |
| 78 | } else if (t.type === 'codespan') { |
| 79 | codeBlocks.push({ |
| 80 | type: 'inline_code', |
| 81 | content: t.text, |
| 82 | }); |
| 83 | } |
| 84 | if (t.tokens) { |
| 85 | walkTokens(t.tokens); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | walkTokens(tokens); |
| 91 | return codeBlocks; |
| 92 | }; |
| 93 | |
| 94 | describe('memoryImportProcessor', () => { |
| 95 | beforeEach(() => { |
no test coverage detected