(text)
| 253 | |
| 254 | |
| 255 | def extract_code(text): |
| 256 | # Match triple backtick blocks first |
| 257 | triple_match = re.search(r'```[^\n]*\n(.+?)```', text, re.DOTALL) |
| 258 | # Match single backtick blocks second |
| 259 | single_match = re.search(r'`([^`]*)`', text, re.DOTALL) |
| 260 | if triple_match: |
| 261 | text = triple_match.group(1) |
| 262 | elif single_match: |
| 263 | text = single_match.group(1) |
| 264 | else: |
| 265 | try: |
| 266 | text = json5.loads(text)['code'] |
| 267 | except Exception: |
| 268 | pass |
| 269 | # If no code blocks found, return original text |
| 270 | return text |
| 271 | |
| 272 | |
| 273 | def escape_ansi(line): |
no test coverage detected