# -*- coding: utf-8 -*- """浠艾福程序升级方案 v1.0:Markdown -> 自包含 HTML(复用已验证 CSS + 链路 SVG)。""" import re, pathlib, markdown DOC = pathlib.Path(r"E:/cfc/docs") MD = DOC / "浠艾福程序-谷禾新版解析与五维归因升级方案-v1.0.md" OUT = DOC / "浠艾福程序-谷禾新版解析与五维归因升级方案-v1.0.html" PREV = pathlib.Path(r"E:/cfc/docs/参考资料/591336962-毛静明-五维本质归因报告-v1.0.html") CSS = re.search(r"", PREV.read_text(encoding="utf-8"), re.S).group(1) CSS += """ @media print { pre { white-space: pre-wrap !important; word-break: break-word; overflow: visible !important; } pre code { white-space: pre-wrap !important; word-break: break-word; } } """ # 升级链路示意(现状双链路 → guhe_v2 走 Python 主路径) FLOW = """ 升级前:双链路,均无谷禾新版能力 上传 PDF /api/health/report/upload ① Java 一步式解析 PdfParseService · 白名单/triplet ② langgraph 异步兜底 v5 移植 + LLM · 无物种功能库字段 升级后:识别分流,guhe_v2 走 Python 主路径 上传 PDF 上传接口不变 Java 指纹识别 detectGuheV2() guhe_v2 → Python 主路径 复用 bun-report-parser v1.3.1 完整 payload 落库 35 键 + _解析自检 异常菌清单接口 /abnormal-species · 12 条 ▲ 直出 归一化真数据填充 17 份样本回归 → 百分位带 五维归因 + 健康计划 §8.1 归因禁区 / §5.8 介导链路审计 架构决策:Python 主导复用上游模块(约 2 人日) vs Java 重写解析(约 8–10 人日);归因禁区与介导链路纪律随 socratic-coach v1.8.0 一并落地 """ html_body = markdown.markdown( MD.read_text(encoding="utf-8"), extensions=["tables", "fenced_code", "sane_lists", "toc", "attr_list"], output_format="html5", ) html_body = html_body.replace("

版本", FLOW + "

版本", 1) html = f""" 浠艾福程序 · 谷禾新版解析与五维归因升级方案 v1.0

{html_body}
""" OUT.write_text(html, encoding="utf-8") print("written", OUT, len(html)) print("tables:", html.count(""), "| h2:", html.count("