MCPcopy Create free account
hub / github.com/anus-dev/ANUS / findCodeBlocks

Function findCodeBlocks

packages/core/src/utils/memoryImportProcessor.test.ts:64–92  ·  view source on GitHub ↗
(
  content: string,
)

Source from the content-addressed store, hash-verified

62};
63
64const 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
94describe('memoryImportProcessor', () => {
95 beforeEach(() => {

Callers 1

Calls 2

parseMarkdownFunction · 0.85
walkTokensFunction · 0.85

Tested by

no test coverage detected