from pathlib import Path from uuid import uuid4 from phase_z2_pipeline import parse_mdx def _tmp_mdx(name: str) -> Path: base = Path("data") / "_tmp_task15_tests" / uuid4().hex base.mkdir(parents=True, exist_ok=True) return base / name def test_task15_note_summary_is_footer_not_body(): mdx = _tmp_mdx("02.sample.mdx") mdx.write_text( """--- title: Sample --- ## 1. Body - **A** - original text :::note[핵심 요약] * **핵심 문장**은 본문 프레임이 아니라 footer로 간다. ::: """, encoding="utf-8", ) title, sections, footer = parse_mdx(mdx) assert title == "Sample" assert [s.section_id for s in sections] == ["02-1"] assert "핵심 문장" not in sections[0].raw_content assert footer == "핵심 문장은 본문 프레임이 아니라 footer로 간다." def test_task15_summary_subsection_is_removed_from_body(): mdx = _tmp_mdx("04.sample.mdx") mdx.write_text( """--- title: Sample --- ## 1. Parent ### 1.1 본문 소목차 - 원문 본문 ### 1.2 핵심 요약 - 요약 문장은 footer로 이동 ### 1.3 다른 본문 - 다른 원문 """, encoding="utf-8", ) _, sections, footer = parse_mdx(mdx) assert [s.section_id for s in sections] == ["04-1"] assert "### 1.2 핵심 요약" not in sections[0].raw_content assert "요약 문장은 footer로 이동" not in sections[0].raw_content assert "### 1.1 본문 소목차" in sections[0].raw_content assert "### 1.3 다른 본문" in sections[0].raw_content assert footer == "요약 문장은 footer로 이동"