| 49 | |
| 50 | |
| 51 | def strip_fenced_blocks(text: str) -> str: |
| 52 | output: list[str] = [] |
| 53 | in_fence = False |
| 54 | fence_marker = "" |
| 55 | fence_len = 0 |
| 56 | for line in text.splitlines(): |
| 57 | match = FENCE_RE.match(line) |
| 58 | if match: |
| 59 | marker = match.group(1) |
| 60 | char = marker[0] |
| 61 | length = len(marker) |
| 62 | if not in_fence: |
| 63 | in_fence = True |
| 64 | fence_marker = char |
| 65 | fence_len = length |
| 66 | elif char == fence_marker and length >= fence_len: |
| 67 | in_fence = False |
| 68 | output.append("") |
| 69 | continue |
| 70 | output.append("" if in_fence else line) |
| 71 | return "\n".join(output) |
| 72 | |
| 73 | |
| 74 | def check_fences(path: Path, text: str) -> list[str]: |