Starting at open_pos (which must be the '{'), find the matching '}'. Returns the content between them (exclusive).
(source: str, open_pos: int)
| 414 | |
| 415 | |
| 416 | def _extract_to_closing_brace(source: str, open_pos: int) -> str: |
| 417 | """ |
| 418 | Starting at open_pos (which must be the '{'), find the matching '}'. |
| 419 | Returns the content between them (exclusive). |
| 420 | """ |
| 421 | assert source[open_pos] == '{' |
| 422 | depth = 0 |
| 423 | for i in range(open_pos, len(source)): |
| 424 | if source[i] == '{': |
| 425 | depth += 1 |
| 426 | elif source[i] == '}': |
| 427 | depth -= 1 |
| 428 | if depth == 0: |
| 429 | return source[open_pos+1:i] |
| 430 | return source[open_pos+1:] |
| 431 | |
| 432 | |
| 433 | def _strip_inline_bodies(text: str) -> str: |