# -*- coding: utf-8 -*-
import io, sys, os
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

TEMPLATE = '''<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><title>__TITLE__ | 北卡教堂山 | 美加硕博项目库</title><style>
:root{{--bg:#f7f8fa;--card:#fff;--pri:#c8102e;--pri2:#a00d24;--line:#e5e7eb;--txt:#1f2937;--sub:#6b7280;--chip:#fef2f2;--link:#c8102e;}}
*{{box-sizing:border-box}}body{{margin:0;font-family:-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:var(--bg);color:var(--txt);line-height:1.65}}
.wrap{{max-width:1080px;margin:0 auto;padding:24px}}
.crumb{{font-size:13px;color:var(--sub);margin-bottom:14px}}
.crumb a{{color:var(--link);text-decoration:none}}
.card{{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:22px 26px;margin-bottom:18px;box-shadow:0 1px 2px rgba(0,0,0,.03)}}
h1{{font-size:26px;margin:0 0 6px;color:#111}}h2{{font-size:17px;margin:0 0 12px;color:var(--pri);border-left:4px solid var(--pri);padding-left:10px}}
.meta{{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 0}}
.chip{{background:var(--chip);color:var(--pri2);padding:3px 10px;border-radius:999px;font-size:12.5px}}
.kv{{display:grid;grid-template-columns:110px 1fr;row-gap:8px;font-size:14px}}
.kv dt{{color:var(--sub)}}.kv dd{{margin:0}}
ul{{margin:6px 0;padding-left:20px}}li{{margin:3px 0}}
.note{{background:#fffbeb;border-left:4px solid #f59e0b;padding:10px 14px;border-radius:6px;font-size:13.5px;color:#92400e;margin-top:8px}}
</style></head><body><div class="wrap">
<div class="crumb"><a href="../index_main.html">← 返回项目库</a> / 北卡教堂山 UNC-Chapel Hill / __BREAD__</div>
<div class="card">
<h1>__H1__</h1>
<div class="meta"><span class="chip">__DEG__</span><span class="chip">北卡教堂山 UNC-Chapel Hill</span><span class="chip">__DISC__</span><span class="chip">__COLLEGE__</span></div>
<dl class="kv" style="margin-top:14px">
<dt>开设院系</dt><dd>__DEPT__</dd>
<dt>官网链接</dt><dd><a href="__URL__" target="_blank" rel="noopener">__URL__</a></dd>
<dt>截止日期</dt><dd>catalog 页未列具体轮次（待补）</dd>
<dt>语言要求</dt><dd>TOEFL iBT / IELTS Academic（最低分待补）</dd>
<dt>标化考试</dt><dd>__TEST__</dd>
<dt>学费</dt><dd>catalog 页未列打包学费（待补）</dd>
</dl>
</div>
<div class="card"><h2>核心课程 / 学位要求</h2><ul>__CORE__</ul></div>
<div class="card"><h2>方向选修 / 特色</h2><ul>__ELECT__</ul></div>
<div class="card"><h2>备注</h2><div class="note">__NOTE__</div></div>
</div></body></html>'''

pages = [
    {
        "file": "details/unc-mha.html",
        "title": "卫生管理硕士（MHA）",
        "bread": "卫生管理硕士（MHA）",
        "h1": "卫生管理硕士（Master of Health Administration, MHA）",
        "deg": "MHA",
        "disc": "med",
        "college": "Gillings School of Global Public Health",
        "dept": "Department of Health Policy and Management, Gillings School of Global Public Health",
        "url": "https://catalog.unc.edu/graduate/schools-departments/health-policy-management/",
        "test": "catalog 页未列（待补）",
        "core": "<li>学位授予：MHA（professional）、MSPH（研究型）、MPH（卫生政策方向）、PhD、DrPH</li><li>本条录 professional 型 MHA；MSPH 研究型已录（unc-hpm-msph）</li><li>Gillings 公卫学院下的医疗管理专业硕士</li>",
        "elect": "<li>与 Kenan-Flagler Business School、School of Information and Library Science、Law School 提供多个 dual degree</li><li>社区准备与灾害管理 graduate certificate</li><li>MPH 学生可与 School of Social Work、City and Regional Planning、Eshelman School of Pharmacy、Law School 双学位</li>",
        "note": "catalog 页未列具体学分/课程列表/截止/语言/GRE/学费，整项待补；STEM 状态 catalog 页未明示，保守 stem:0；PhD/DrPH 留批次5。",
    },
    {
        "file": "details/unc-maps.html",
        "title": "应用职业研究硕士（MAPS）",
        "bread": "应用职业研究硕士（MAPS）",
        "h1": "应用职业研究硕士（Master of Applied Professional Studies, M.A.P.S.）",
        "deg": "MAPS",
        "disc": "biz",
        "college": "The Graduate School",
        "dept": "The Graduate School, Interdisciplinary Program",
        "url": "https://catalog.unc.edu/graduate/schools-departments/applied-professional-studies/",
        "test": "GRE is not required",
        "core": "<li>学位授予：M.A.P.S.（interdisciplinary professional）</li><li>核心课程：leadership and business fundamentals series，提供 essential professional skills</li><li>面向需要定制化职业目标的学生，跨学科研究生项目</li><li>入学要求：bachelor's degree + cumulative GPA 3.0 or better</li>",
        "elect": "<li>跨学科定制：学生与导师共同设计个性化课程序列</li><li>The Graduate School 直属项目，非特定学院</li><li>适合职业转型或需要跨领域知识的在职人士</li>",
        "note": "catalog 页未列具体学分/课程列表/截止/语言/学费，整项待补；GRE not required（catalog 明示）；STEM 状态未明示，保守 stem:0；catalog 页未明确是否 online/part-time，按 on-campus professional 暂录，待终检定性。",
    },
    {
        "file": "details/unc-global-studies-ma.html",
        "title": "全球研究文学硕士（MA）",
        "bread": "全球研究文学硕士（MA）",
        "h1": "全球研究文学硕士（Master of Arts in Global Studies）",
        "deg": "MA",
        "disc": "soc",
        "college": "College of Arts and Sciences",
        "dept": "Center for Global Studies",
        "url": "https://catalog.unc.edu/graduate/schools-departments/global-studies/",
        "test": "catalog 页未列（待补）",
        "core": "<li>学位授予：MA（Non-Thesis）</li><li>总学分：36 学分</li><li>Writing Credits：6 hours（second year 每学期 3 hours）</li><li>选修：至少 5 门 concentration 课程，15 hours</li><li>Capstone：完成并答辩 capstone project</li>",
        "elect": "<li>REEES Concentration（Russian, East European and Eurasian Studies）</li><li>跨学科：国际关系、比较政治、文化研究、语言等</li><li>Director of Graduate Studies: Dr. Erica Johnson</li>",
        "note": "catalog 页列总学分 36（6 writing + 15 elective + capstone）；截止/语言/GRE/学费 catalog 页未列，待补；STEM 状态未明示，保守 stem:0；人文社科类。",
    },
    {
        "file": "details/unc-media-comm-ma.html",
        "title": "媒体与传播文学硕士（MA）",
        "bread": "媒体与传播文学硕士（MA）",
        "h1": "媒体与传播文学硕士（Master of Arts in Media and Communication）",
        "deg": "MA",
        "disc": "soc",
        "college": "School of Media and Journalism",
        "dept": "School of Media and Journalism",
        "url": "https://catalog.unc.edu/graduate/schools-departments/media-journalism/",
        "test": "catalog 页未列（待补）",
        "core": "<li>学位授予：MA（Media and Communication）</li><li>三个 distinct areas of study：Journalism / Strategic communication / Theory and research</li><li>JD-MA dual-degree option（与法学院联合）</li><li>另有 Online MA in Digital Communication（在线版，排除）</li>",
        "elect": "<li>三个 graduate certificate（online 面向在职人士）：Digital communication strategy / Digital media management / Digital storytelling</li><li>课程强调 media in society 的批判性审视 + 理论与分析基础</li><li>Scholarly and professional 双轨训练</li>",
        "note": "catalog 页列三个方向 + JD-MA 双学位；Online MA in Digital Communication 在线版排除；截止/语言/GRE/学费 catalog 页未列，待补；STEM 状态未明示，保守 stem:0；传媒类。",
    },
]

for p in pages:
    html = TEMPLATE.replace("__TITLE__", p["title"])
    html = html.replace("__BREAD__", p["bread"])
    html = html.replace("__H1__", p["h1"])
    html = html.replace("__DEG__", p["deg"])
    html = html.replace("__DISC__", p["disc"])
    html = html.replace("__COLLEGE__", p["college"])
    html = html.replace("__DEPT__", p["dept"])
    html = html.replace("__URL__", p["url"])
    html = html.replace("__TEST__", p["test"])
    html = html.replace("__CORE__", p["core"])
    html = html.replace("__ELECT__", p["elect"])
    html = html.replace("__NOTE__", p["note"])
    with open(p["file"], "w", encoding="utf-8") as f:
        f.write(html)
    print("written:", p["file"])
