"""MDX04 partial preview — diagnostic only, NOT a Phase Z final. 목적: F16 (`bim_issues_quadrant_four`) 가 04-2.1 / 04-2.2 의 4 항목 구조와 시각적으로 정합하는지 사용자가 눈으로 확인. 방식: - V4 runtime 우회 (정식 Phase Z 아님) - F16 figma 원본 HTML 을 iframe 으로 임베드 (디자인 형태 그대로) - 04-2.1 / 04-2.2 의 MDX 4 항목을 옆에 시각화 (구조 비교) - 04-1 = frame library gap (5-card 구조, 매칭 frame 부재) placeholder - diagnostic banner + V4 metadata + debug.json 출력: data/runs/mdx04_partial_preview/index.html data/runs/mdx04_partial_preview/debug.json data/runs/mdx04_partial_preview/f16_original/ (figma 원본 + assets) """ import json import re import sys from datetime import datetime from html import escape from pathlib import Path import yaml ROOT = Path(__file__).resolve().parents[2] MDX_PATH = ROOT / "samples" / "mdx_batch" / "04.mdx" V4_RESULT = ROOT / "tests" / "matching" / "v4_full32_result.yaml" RUN_DIR = ROOT / "data" / "runs" / "mdx04_partial_preview" # ─── MDX 04 의 04-2.1 / 04-2.2 섹션 추출 (### bullet) ────────────── RE_SUBSECTION_HEAD = re.compile(r'^###\s+(\d+\.\d+)\s+(.+)$', re.MULTILINE) RE_TOP_BULLET = re.compile(r'^-\s+\*\*([^*]+)\*\*\s*$') def extract_subsection(text, num_label): """### {num_label} ... 부터 다음 ### 또는 --- 직전까지 추출.""" lines = text.split('\n') start = None for i, ln in enumerate(lines): m = RE_SUBSECTION_HEAD.match(ln.strip()) if m and m.group(1) == num_label: start = i break if start is None: return None, [] end = len(lines) for j in range(start + 1, len(lines)): s = lines[j].strip() if RE_SUBSECTION_HEAD.match(s) or s == '---': end = j break section_title = lines[start].lstrip('# ').strip() body_lines = lines[start + 1:end] # 4 항목 추출 (top bullet + nested bullets) items = [] cur = None for ln in body_lines: stripped = ln.strip() m = RE_TOP_BULLET.match(stripped) if m: if cur is not None: items.append(cur) cur = {'headline': m.group(1).strip(), 'subs': []} continue m2 = re.match(r'^-\s+(.+)$', stripped) if m2 and cur is not None and not stripped.startswith('- **'): cur['subs'].append(m2.group(1).strip()) if cur is not None: items.append(cur) return section_title, items def extract_section_04_1(text): """04-1 = ## 1. DX에 대한 인식.
인용 +