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