MCPcopy
hub / github.com/codeaashu/claude-code / extractCodeBlocks

Function extractCodeBlocks

src/commands/copy/copy.tsx:30–43  ·  view source on GitHub ↗
(markdown: string)

Source from the content-addressed store, hash-verified

28 lang: string | undefined;
29};
30function 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

Callers 1

callFunction · 0.85

Calls 2

stripPromptXMLTagsFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected