(text: str)
| 279 | |
| 280 | |
| 281 | def extract_code(text: str) -> str: |
| 282 | # Match triple backtick blocks first |
| 283 | triple_match = re.search(r'```[^\n]*\n(.+?)```', text, re.DOTALL) |
| 284 | if triple_match: |
| 285 | text = triple_match.group(1) |
| 286 | else: |
| 287 | try: |
| 288 | text = json5.loads(text)['code'] |
| 289 | except Exception: |
| 290 | print_traceback(is_error=False) |
| 291 | # If no code blocks found, return original text |
| 292 | return text |
| 293 | |
| 294 | |
| 295 | def json_loads(text: str) -> dict: |
no test coverage detected