MCPcopy Create free account
hub / github.com/tester-army/e2e / codeBlocks

Function codeBlocks

scripts/check-docs-examples.ts:40–48  ·  view source on GitHub ↗

The bodies of every fenced code block on the page, with the fence's indentation removed.

(text: string)

Source from the content-addressed store, hash-verified

38
39/** The bodies of every fenced code block on the page, with the fence's indentation removed. */
40function codeBlocks(text: string): string[] {
41 return [...text.matchAll(/^( *)```[^\n]*\n([\s\S]*?)^\1```$/gm)].map(([, indent, body]) =>
42 body!
43 .split('\n')
44 .map((line) => (line.startsWith(indent!) ? line.slice(indent!.length) : line))
45 .join('\n')
46 .trimEnd(),
47 );
48}
49
50function main(): number {
51 const blocks = new Map<string, string[]>();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected