(text_with_code_block: str)
| 2 | from typing import Optional |
| 3 | |
| 4 | def parse_python_code(text_with_code_block: str) -> Optional[str]: |
| 5 | pattern = re.compile(r"```python\s*\n(.*?)\n\s*```", re.DOTALL) |
| 6 | |
| 7 | match = pattern.search(text_with_code_block) |
| 8 | |
| 9 | if match: |
| 10 | return match.group(1).strip() |
| 11 | |
| 12 | return None |
| 13 | |
| 14 | def parse_yaml_code(text_with_code_block: str) -> Optional[str]: |
| 15 | pattern = re.compile(r"```yaml\s*\n(.*?)\n\s*```", re.DOTALL) |