| 557 | |
| 558 | |
| 559 | def inspect_figure_callouts(text: str) -> list[str]: |
| 560 | warnings: list[str] = [] |
| 561 | lines = text.splitlines() |
| 562 | i = 0 |
| 563 | saw_legacy_block = False |
| 564 | while i < len(lines): |
| 565 | stripped = lines[i].strip() |
| 566 | if stripped.startswith("[FIGURE_PLACEHOLDER]"): |
| 567 | saw_legacy_block = True |
| 568 | if not stripped.startswith("> [!figure]"): |
| 569 | i += 1 |
| 570 | continue |
| 571 | if not figure_callout_title(stripped): |
| 572 | warnings.append("figure_callout_missing_title") |
| 573 | has_location = False |
| 574 | has_reason = False |
| 575 | has_status = False |
| 576 | j = i + 1 |
| 577 | while j < len(lines): |
| 578 | nxt = lines[j].strip() |
| 579 | if not nxt.startswith(">"): |
| 580 | break |
| 581 | if nxt.startswith("> 建议位置:"): |
| 582 | has_location = True |
| 583 | if nxt.startswith("> 放置原因:"): |
| 584 | has_reason = True |
| 585 | if nxt.startswith("> 当前状态:"): |
| 586 | has_status = True |
| 587 | j += 1 |
| 588 | if not has_location: |
| 589 | warnings.append("figure_callout_missing_location") |
| 590 | if not has_reason: |
| 591 | warnings.append("figure_callout_missing_reason") |
| 592 | if not has_status: |
| 593 | warnings.append("figure_callout_missing_status") |
| 594 | i = j |
| 595 | if saw_legacy_block: |
| 596 | warnings.append("legacy_figure_placeholder_block_used") |
| 597 | return warnings |
| 598 | |
| 599 | |
| 600 | def figure_callout_title(line: str) -> str: |