MCPcopy Create free account
hub / github.com/catid/supercharger / extract_code_from_md

Function extract_code_from_md

codegen/extract_code_from_md.py:2–18  ·  view source on GitHub ↗
(input_text)

Source from the content-addressed store, hash-verified

1# Remove everything outside the first ``` code block containing a function.
2def extract_code_from_md(input_text):
3 output = []
4 code_block = False
5 found_def = False
6 for line in input_text.splitlines():
7 if line.strip().startswith("```"):
8 if found_def:
9 break
10 code_block = not code_block
11 if code_block:
12 found_def = False
13 output.clear()
14 elif code_block:
15 output.append(line)
16 if 'def' in line:
17 found_def = True
18 return '\n'.join(output)

Callers 2

clean_codeFunction · 0.90

Calls

no outgoing calls

Tested by 1