dknowc-dsh 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -19
- package/package.json +4 -4
- package/skills/dknowc-official-doc-writer/README.md +18 -16
- package/skills/dknowc-official-doc-writer/SKILL.md +112 -123
- package/skills/dknowc-official-doc-writer/attribution.json +5 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +5 -0
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +18 -8
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/research_notes.md +34 -0
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +2 -9
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +922 -270
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +123 -28
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +6 -6
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +88 -53
- package/skills/dknowc-official-doc-writer/reference/task_router.md +6 -6
- package/skills/dknowc-official-doc-writer/scripts/adapt_mcp_result.py +52 -2
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +41 -14
- package/skills/dknowc-official-doc-writer/scripts/attribution.py +60 -0
- package/skills/dknowc-official-doc-writer/scripts/build_trace_json.py +288 -0
- package/skills/dknowc-official-doc-writer/scripts/check_materials.py +265 -0
- package/skills/dknowc-official-doc-writer/scripts/deep_convert.py +235 -0
- package/skills/dknowc-official-doc-writer/scripts/deep_query.py +333 -0
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +22 -5
- package/skills/dknowc-official-doc-writer/scripts/extract_reference.py +245 -0
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +106 -18
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +15 -17
- package/skills/dknowc-official-doc-writer/scripts/mcp_convert.py +272 -0
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +257 -143
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +72 -8
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +14 -4
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +6 -1
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +120 -48
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +1514 -660
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +151 -6
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +13 -0
- package/skills/dknowc-ppt-assistant/README.md +14 -10
- package/skills/dknowc-ppt-assistant/SKILL.md +33 -15
- package/skills/dknowc-ppt-assistant/attribution.json +5 -0
- package/skills/dknowc-ppt-assistant/references/material_usage.md +9 -5
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +14 -2
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +1343 -292
- package/skills/dknowc-ppt-assistant/references/search_intro.md +1 -1
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +41 -14
- package/skills/dknowc-ppt-assistant/scripts/attribution.py +60 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +9 -17
- package/skills/dknowc-ppt-assistant/scripts/mcp_convert.py +188 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +135 -6
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +1539 -714
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +33 -3
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +17 -19
- package/skills/dknowc-trusted-search/README.md +27 -22
- package/skills/dknowc-trusted-search/SKILL.md +213 -140
- package/skills/dknowc-trusted-search/attribution.json +5 -0
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +17 -7
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +720 -253
- package/skills/dknowc-trusted-search/scripts/api_key.py +41 -14
- package/skills/dknowc-trusted-search/scripts/attribution.py +61 -0
- package/skills/dknowc-trusted-search/scripts/chart_embed.py +350 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +26 -5
- package/skills/dknowc-trusted-search/scripts/initialize.py +20 -29
- package/skills/dknowc-trusted-search/scripts/mcp_convert.py +189 -0
- package/skills/dknowc-trusted-search/scripts/merge_search_results.py +272 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +149 -43
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +1860 -751
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +34 -31
- package/src/index.js +3 -8
- package/skills/dknowc-official-doc-writer/scripts/check_release.py +0 -93
- package/skills/dknowc-ppt-assistant/scripts/adapt_mcp_result.py +0 -279
- package/skills/dknowc-ppt-assistant/scripts/check_release.py +0 -106
- package/skills/dknowc-trusted-consulting/README.md +0 -63
- package/skills/dknowc-trusted-consulting/SKILL.md +0 -236
- package/skills/dknowc-trusted-consulting/reference/consult_intro.md +0 -47
- package/skills/dknowc-trusted-consulting/reference/onboarding_scripts.md +0 -132
- package/skills/dknowc-trusted-consulting/reference/sample_consult_answer.md +0 -31
- package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +0 -502
- package/skills/dknowc-trusted-consulting/scripts/adapt_mcp_result.py +0 -283
- package/skills/dknowc-trusted-consulting/scripts/api_key.py +0 -41
- package/skills/dknowc-trusted-consulting/scripts/check_release.py +0 -66
- package/skills/dknowc-trusted-consulting/scripts/gov_chat.py +0 -508
- package/skills/dknowc-trusted-consulting/scripts/initialize.py +0 -133
- package/skills/dknowc-trusted-consulting/scripts/mcp_direct.py +0 -166
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +0 -279
- package/skills/dknowc-trusted-consulting/scripts/render_trace_html.py +0 -1616
- package/skills/dknowc-trusted-search/scripts/adapt_mcp_result.py +0 -261
- package/skills/dknowc-trusted-search/scripts/check_release.py +0 -79
- package/skills/dknowc-trusted-search/scripts/render_policy_visualization.py +0 -894
|
@@ -5,32 +5,37 @@
|
|
|
5
5
|
- outline 提纲版:结构方案确认门前的提纲答案文件(页面规划表 + 口径事项清单)→ 事前核验
|
|
6
6
|
- final 成稿版:交付时的页面级结论文本 → 事后溯源
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
3.7.x 同源架构(对齐公文写作 3.7.5/3.7.6,参考深知晓交互原型,数据口径保持自有与真实):
|
|
9
|
+
- 顶栏:身份章 + 标题 + 工具组(只看正文 / 复制全文 / 打印归档)+ 阅读进度条
|
|
10
|
+
- Hero:大标题 + 真实统计(N 次检索 · M 条材料 · K 处引用)+ 双视图切换
|
|
11
|
+
- 过程回顾条:检索 → 入库 → 逐条比对 → 核验完成(静态回放,数字全部真实计算)
|
|
12
|
+
- 核验报告视图(默认):核验报告单 + 正文文档流(章节标题 + 句后引文胶囊,点击原地展开溯源卡)
|
|
13
|
+
- 知识专库视图(全屏):大搜索 + 热词(真实计算)+ 检索分组 tabs + 来源文章卡
|
|
14
|
+
- 链接质量保障:生成时检测全部材料链接(HTTP 404/410 + 政府站软 404 标题嗅探),
|
|
15
|
+
失效链接改用存档快照回看(接口 screenShotPath,路径容错补 /A/,纯本地校验不误杀)
|
|
16
|
+
|
|
17
|
+
PPT 特有口径(与公文写作的差异,均为产品决策):
|
|
18
|
+
- 提醒制:数据缺口(缺原文链接/缺摘录)不判不通过、指标恒绿附温和提醒;只有无素材/
|
|
19
|
+
正文无角标/角标未绑定三种真实错误才判不通过
|
|
20
|
+
- 双版 stage:提纲版(事前核验)与成稿版(事后溯源)同脚本同形式,标题与身份章带版本后缀
|
|
21
|
+
- 双形态 JSON:素材数组认顶层 {"检索文章": [...]} 或原始接口 content.data.检索文章
|
|
22
|
+
- 未引用判定双通道:JSON 标记(recalled_materials)∪ 正文角标未引用
|
|
23
|
+
- 去重键含角标:同一文章被赋不同角标时各留一卡;双向硬校验(exit 2)
|
|
24
|
+
|
|
25
|
+
诚实原则:脚本真实计算的结果才打勾;政策现行效力等无法自动判定项归入"建议人工复核"。
|
|
26
|
+
布局为单文件静态 HTML;打印归档模式单栏全展开并附材料附录。
|
|
25
27
|
"""
|
|
26
28
|
|
|
27
29
|
from __future__ import annotations
|
|
28
30
|
|
|
29
31
|
import argparse
|
|
32
|
+
import concurrent.futures
|
|
30
33
|
import html
|
|
31
34
|
import json
|
|
32
35
|
import re
|
|
33
36
|
import sys
|
|
37
|
+
import urllib.error
|
|
38
|
+
import urllib.request
|
|
34
39
|
from datetime import datetime
|
|
35
40
|
from pathlib import Path
|
|
36
41
|
from typing import Any, Dict, List, Optional, Tuple
|
|
@@ -51,6 +56,10 @@ OUTPUT_DIR = WS_ROOT / "official-docs" / "output"
|
|
|
51
56
|
STAGE_LABELS = {"outline": "提纲版", "final": "成稿版"}
|
|
52
57
|
REPORT_NAME = "溯源核验报告"
|
|
53
58
|
|
|
59
|
+
# 快照兜底开关:默认启用。接口 screenShotPath 曾存在路径缺 /A/ 层级的拼接 bug;
|
|
60
|
+
# verify_snapshots 在展示前完成"补 /A/ 修订 + 纯本地格式校验 + 非法弃用"。
|
|
61
|
+
SNAPSHOT_ENABLED = True
|
|
62
|
+
|
|
54
63
|
|
|
55
64
|
def _is_within(path: Path, parent: Path) -> bool:
|
|
56
65
|
try:
|
|
@@ -154,8 +163,8 @@ KIND_CATALOG = {
|
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
|
|
157
|
-
def normalize_kind(raw: str) -> Tuple[str, str
|
|
158
|
-
"""把来源类型文本归一化为(类型键,
|
|
166
|
+
def normalize_kind(raw: str) -> Tuple[str, str]:
|
|
167
|
+
"""把来源类型文本归一化为(类型键, 中文标签);css 类名查 KIND_CATALOG。"""
|
|
159
168
|
text = str(raw or "")
|
|
160
169
|
if "政策" in text or "法规" in text or "依据" in text or "policy" in text.lower():
|
|
161
170
|
key = "policy"
|
|
@@ -167,8 +176,8 @@ def normalize_kind(raw: str) -> Tuple[str, str, str]:
|
|
|
167
176
|
key = "reference"
|
|
168
177
|
else:
|
|
169
178
|
key = "material"
|
|
170
|
-
label,
|
|
171
|
-
return key, label
|
|
179
|
+
label, _css = KIND_CATALOG[key]
|
|
180
|
+
return key, label
|
|
172
181
|
|
|
173
182
|
|
|
174
183
|
def parse_year_month(raw: str) -> Optional[Tuple[int, int]]:
|
|
@@ -186,22 +195,40 @@ def parse_year_month(raw: str) -> Optional[Tuple[int, int]]:
|
|
|
186
195
|
|
|
187
196
|
|
|
188
197
|
# ============================================================
|
|
189
|
-
# 素材提取(数据层:材料级编号优先 +
|
|
198
|
+
# 素材提取(数据层:材料级编号优先 + 位置兜底 + 双形态 JSON)
|
|
190
199
|
# ============================================================
|
|
191
200
|
|
|
201
|
+
def clean_paragraph_noise(text: str) -> str:
|
|
202
|
+
"""清洗接口段落文本中的附件链接噪音。
|
|
203
|
+
|
|
204
|
+
接口段落内容格式为「段落标题 https://attach.dknowc.cn/file/<正文>」——
|
|
205
|
+
URL 前是段落标题(已由标题链单独展示),URL 本身是附件地址(卡片有"查看全文"入口)。
|
|
206
|
+
摘录只保留 URL 之后的正文;无该前缀时兜底剔除文本中的裸 URL。
|
|
207
|
+
"""
|
|
208
|
+
value = str(text or "")
|
|
209
|
+
m = re.search(r"https?://\S*attach\.dknowc\.cn/file/", value)
|
|
210
|
+
if m:
|
|
211
|
+
return value[m.end():].strip()
|
|
212
|
+
value = re.sub(r"https?://\S+", " ", value)
|
|
213
|
+
return re.sub(r"[ \t]{2,}", " ", value).strip()
|
|
214
|
+
|
|
215
|
+
|
|
192
216
|
def paragraph_text(item: Dict[str, Any]) -> str:
|
|
193
217
|
paragraphs = item.get("content") or item.get("段落") or item.get("paragraphs") or item.get("paragraphList")
|
|
194
218
|
if isinstance(paragraphs, list):
|
|
195
219
|
chunks = []
|
|
196
220
|
for para in paragraphs:
|
|
197
221
|
if isinstance(para, dict):
|
|
198
|
-
|
|
222
|
+
chunk = first_str(para.get("text"), para.get("内容"), para.get("content"), para.get("summary"), para.get("标题"), para.get("title"))
|
|
199
223
|
else:
|
|
200
|
-
|
|
201
|
-
|
|
224
|
+
chunk = str(para)
|
|
225
|
+
chunk = clean_paragraph_noise(chunk)
|
|
226
|
+
if chunk:
|
|
227
|
+
chunks.append(chunk)
|
|
228
|
+
text = "\n".join(chunks)
|
|
202
229
|
if text:
|
|
203
230
|
return text
|
|
204
|
-
return first_str(
|
|
231
|
+
return clean_paragraph_noise(first_str(
|
|
205
232
|
item.get("摘录"),
|
|
206
233
|
item.get("摘要"),
|
|
207
234
|
item.get("相关段落"),
|
|
@@ -211,7 +238,7 @@ def paragraph_text(item: Dict[str, Any]) -> str:
|
|
|
211
238
|
item.get("content"),
|
|
212
239
|
item.get("text"),
|
|
213
240
|
item.get("snippet"),
|
|
214
|
-
)
|
|
241
|
+
))
|
|
215
242
|
|
|
216
243
|
|
|
217
244
|
def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
@@ -236,8 +263,8 @@ def content_segments(item: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
236
263
|
def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict[str, str]] = None) -> Dict[str, str]:
|
|
237
264
|
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
238
265
|
segment = segment or {}
|
|
239
|
-
# 材料级编号(角标/编号/materialIndex
|
|
240
|
-
#
|
|
266
|
+
# 材料级编号(角标/编号/materialIndex 等)优先;段落 id 是文章内段落序号(各篇独立
|
|
267
|
+
# 从 1 起,多篇同为 "1" 会互相冲突导致角标错乱),彻底不用作材料编号。
|
|
241
268
|
explicit_id = first_str(
|
|
242
269
|
item.get("角标"),
|
|
243
270
|
item.get("编号"),
|
|
@@ -265,7 +292,7 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
265
292
|
item.get("name"),
|
|
266
293
|
vo.get("showTitle"),
|
|
267
294
|
vo.get("title"),
|
|
268
|
-
"
|
|
295
|
+
"未命名来源文章",
|
|
269
296
|
),
|
|
270
297
|
"agency": first_str(
|
|
271
298
|
item.get("unit") if not isinstance(item.get("unit"), list) else "、".join(str(x) for x in item.get("unit")[:3]),
|
|
@@ -280,46 +307,59 @@ def source_from_article(item: Dict[str, Any], index: int, segment: Optional[Dict
|
|
|
280
307
|
"date": first_str(item.get("发布日期"), item.get("date"), item.get("发布时间"), item.get("createDate"), vo.get("dateTime"), vo.get("createDate")),
|
|
281
308
|
"url": first_str(item.get("sourceUrl"), item.get("source_url"), item.get("源网址"), item.get("原文链接"), item.get("url"), item.get("原文"), vo.get("sourceUrl"), vo.get("url")),
|
|
282
309
|
"policy_url": first_str(item.get("policyUrl"), item.get("policy_url"), item.get("知识专库原文"), vo.get("policyUrl")),
|
|
283
|
-
"excerpt":
|
|
310
|
+
"excerpt": segment.get("text") or paragraph_text(item),
|
|
284
311
|
"section": first_str(item.get("正文对应"), item.get("section"), item.get("支撑")),
|
|
285
312
|
"kind": first_str(item.get("类型"), item.get("type"), item.get("素材类型"), vo.get("typeName"), "材料"),
|
|
286
313
|
"verify_note": first_str(item.get("核验"), item.get("verification"), item.get("核验说明")),
|
|
287
314
|
"area": first_str(item.get("intentionArea"), item.get("area"), item.get("地域")),
|
|
288
315
|
}
|
|
289
|
-
#
|
|
290
|
-
#
|
|
291
|
-
|
|
316
|
+
# 段落级数据(多段分块展示用):每段 {chain:[文章,章节,子节...], text}
|
|
317
|
+
# 段落标题自带 > 层级,拆级成面包屑;段落标题与文章标题相同或缺失时链只含文章一级。
|
|
318
|
+
segments = []
|
|
292
319
|
for seg in content_segments(item):
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
source["
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
320
|
+
seg_title = first_str(seg.get("title"))
|
|
321
|
+
levels = [lvl.strip() for lvl in re.split(r"\s*>\s*", seg_title) if lvl.strip()] if seg_title else []
|
|
322
|
+
if levels and levels[0] == source["title"]:
|
|
323
|
+
levels = levels[1:]
|
|
324
|
+
seg_text = clean_paragraph_noise(seg.get("text"))
|
|
325
|
+
chain_lvls = [source["title"]] + levels
|
|
326
|
+
segments.append({"chain": chain_lvls, "text": strip_leading_chain(seg_text, chain_lvls)})
|
|
327
|
+
source["segments"] = segments
|
|
328
|
+
# 首段章节位置(兼容旧单行引用处)
|
|
329
|
+
first_chain = segments[0]["chain"][1:] if segments else []
|
|
330
|
+
source["doc_section"] = " › ".join(first_chain)
|
|
331
|
+
source["chain_full"] = " › ".join(segments[0]["chain"]) if segments else ""
|
|
332
|
+
# 发文字号:必须是标准格式(〔年份〕序号号);描述性文字("XX印发"类自造
|
|
333
|
+
# 描述)不显示、当无文号处理(对齐公文写作 3.7.3,实测模型把文号写成
|
|
334
|
+
# "中办、国办 2026 年印发"类描述导致关键性行失真)。
|
|
335
|
+
_dn = first_str(item.get("文号"), item.get("发文字号"), item.get("doc_number"))
|
|
336
|
+
source["doc_number"] = _dn if re.search(r"〔\d{4}〕\s*\d+\s*号", _dn) else ""
|
|
337
|
+
# 所属搜索条件(多路检索分组)与引用状态(未引用=接口召回但正文未采用)
|
|
304
338
|
source["search_key"] = first_str(item.get("搜索条件"), item.get("search_key"))
|
|
305
339
|
source["used"] = item.get("已引用", item.get("used", True))
|
|
306
340
|
if not isinstance(source["used"], bool):
|
|
307
341
|
source["used"] = True
|
|
308
|
-
#
|
|
342
|
+
# 快照兜底:原文链接 404/410(生成时真实检测)或接口未返回源网址时,
|
|
343
|
+
# 改用接口提供的存档快照链接回看——快照是原文的存档副本,按钮文案如实区分。
|
|
344
|
+
source["snapshot"] = first_str(item.get("快照链接"), item.get("snapshot"), item.get("screenShotPath"))
|
|
345
|
+
source["link_dead"] = item.get("链接失效") is True or item.get("link_dead") is True
|
|
346
|
+
# 发布日期可信度(实测:「高」=模型治理入库、标题模型精抽;「较高」=门户抓取、标题规则提取)
|
|
309
347
|
source["conf"] = first_str(item.get("发布日期可信度"), item.get("可信度"), item.get("confidence"))
|
|
310
|
-
key, label
|
|
348
|
+
key, label = normalize_kind(source["kind"])
|
|
311
349
|
source["type_key"] = key
|
|
312
350
|
source["type_label"] = label
|
|
313
|
-
source["type_css"] =
|
|
314
|
-
|
|
315
|
-
|
|
351
|
+
source["type_css"] = KIND_CATALOG[key][1]
|
|
352
|
+
live_url = bool(source["url"] and source["url"] != "接口未返回") and not source["link_dead"]
|
|
353
|
+
source["has_link"] = live_url or bool(source["policy_url"]) or bool(source["snapshot"])
|
|
354
|
+
# 核验状态只看摘录可比对;原文链接死活与快照有无是回看通道问题,不影响核验结论
|
|
355
|
+
# (PPT 提醒制:数据缺口不判不通过,卡片与指标行温和提醒)
|
|
316
356
|
source["verified"] = bool(source["excerpt"])
|
|
317
357
|
return source
|
|
318
358
|
|
|
319
359
|
|
|
320
360
|
def extract_articles_from_search(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
321
361
|
# 兼容两种形态:原始接口的 content.data.检索文章(嵌套)与手工合并 JSON 的
|
|
322
|
-
# 顶层 检索文章(Agent 合并时常剥掉接口包装,与
|
|
362
|
+
# 顶层 检索文章(Agent 合并时常剥掉接口包装,与 self_check 平级)。
|
|
323
363
|
content = payload.get("content") if isinstance(payload.get("content"), dict) else payload
|
|
324
364
|
data = content.get("data") if isinstance(content.get("data"), dict) else content.get("data")
|
|
325
365
|
articles: List[Dict[str, Any]] = []
|
|
@@ -359,15 +399,16 @@ def extract_reference_materials(payload: Dict[str, Any]) -> List[Dict[str, Any]]
|
|
|
359
399
|
return []
|
|
360
400
|
|
|
361
401
|
|
|
362
|
-
def
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
402
|
+
def collect_raw_articles(payload: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
403
|
+
"""链接检测/快照校验的作用对象:全部原始材料 dict(含未引用召回),就地修改生效。"""
|
|
404
|
+
raws: List[Dict[str, Any]] = []
|
|
405
|
+
raws.extend(extract_reference_materials(payload))
|
|
406
|
+
raws.extend(extract_articles_from_search(payload))
|
|
407
|
+
raws.extend(extract_articles_from_deep(payload))
|
|
408
|
+
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
409
|
+
if isinstance(recalled, list):
|
|
410
|
+
raws.extend(x for x in recalled if isinstance(x, dict))
|
|
411
|
+
return raws
|
|
371
412
|
|
|
372
413
|
|
|
373
414
|
def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
@@ -376,7 +417,7 @@ def extract_sources(payload: Dict[str, Any]) -> List[Dict[str, str]]:
|
|
|
376
417
|
raw_sources.extend(extract_articles_from_search(payload))
|
|
377
418
|
raw_sources.extend(extract_articles_from_deep(payload))
|
|
378
419
|
# 未引用召回材料(接口召回但正文未采用,agent 筛选后全量放入 recalled_materials):
|
|
379
|
-
#
|
|
420
|
+
# 进面板「未引用」分组,不占正文角标编号,不参与核验统计。
|
|
380
421
|
recalled = payload.get("recalled_materials") or payload.get("召回材料")
|
|
381
422
|
if isinstance(recalled, list):
|
|
382
423
|
raw_sources.extend({**{"已引用": False}, **x} for x in recalled if isinstance(x, dict))
|
|
@@ -416,18 +457,18 @@ def extract_answer(payload: Dict[str, Any]) -> str:
|
|
|
416
457
|
return normalize_citations(answer)
|
|
417
458
|
articles = extract_articles_from_search(payload)
|
|
418
459
|
if articles:
|
|
419
|
-
rows = ["
|
|
460
|
+
rows = ["可信搜索召回了以下重点来源文章:"]
|
|
420
461
|
for idx, item in enumerate(articles[:8], start=1):
|
|
421
462
|
rows.append(f"[{idx}] {first_str(item.get('文章标题'), item.get('title'), item.get('标题'), '未命名材料')}")
|
|
422
463
|
return "\n".join(rows)
|
|
423
464
|
deep_articles = extract_articles_from_deep(payload)
|
|
424
465
|
if deep_articles:
|
|
425
|
-
rows = ["
|
|
466
|
+
rows = ["深度搜索召回了以下重点来源文章:"]
|
|
426
467
|
for idx, item in enumerate(deep_articles[:8], start=1):
|
|
427
468
|
vo = item.get("vo") if isinstance(item.get("vo"), dict) else {}
|
|
428
469
|
rows.append(f"[{idx}] {first_str(vo.get('showTitle'), vo.get('title'), item.get('title'), '未命名材料')}")
|
|
429
470
|
return "\n".join(rows)
|
|
430
|
-
return "
|
|
471
|
+
return "接口返回中未识别到正文内容;请查看知识专库或原始 JSON。"
|
|
431
472
|
|
|
432
473
|
|
|
433
474
|
def extract_question(payload: Dict[str, Any]) -> str:
|
|
@@ -443,19 +484,6 @@ def extract_question(payload: Dict[str, Any]) -> str:
|
|
|
443
484
|
)
|
|
444
485
|
|
|
445
486
|
|
|
446
|
-
def extract_knowledge_bases(payload: Dict[str, Any]) -> List[str]:
|
|
447
|
-
content = payload.get("content") if isinstance(payload.get("content"), dict) else payload
|
|
448
|
-
data = content.get("data") if isinstance(content.get("data"), dict) else {}
|
|
449
|
-
values: List[str] = []
|
|
450
|
-
for value in (payload.get("knowledgeBases"), content.get("knowledgeBases"),
|
|
451
|
-
payload.get("knowledgeBase"), content.get("knowledgeBase"), data.get("knowledgeBase")):
|
|
452
|
-
if isinstance(value, list):
|
|
453
|
-
values.extend(str(item).strip() for item in value if str(item).strip())
|
|
454
|
-
elif isinstance(value, str) and value.strip():
|
|
455
|
-
values.append(value.strip())
|
|
456
|
-
return list(dict.fromkeys(values))
|
|
457
|
-
|
|
458
|
-
|
|
459
487
|
def citation_ids(answer: str) -> List[str]:
|
|
460
488
|
ids: List[str] = []
|
|
461
489
|
for match in re.finditer(r"\[(\d+)\]", answer):
|
|
@@ -488,8 +516,10 @@ def classify_check_value(raw: Any) -> Tuple[str, str]:
|
|
|
488
516
|
"""把自检项的值解析为(状态, 核验说明)。
|
|
489
517
|
|
|
490
518
|
兼容多种写法:`pass` / `true` / `通过` / `通过:说明文字` / `✓` 等;
|
|
491
|
-
|
|
492
|
-
|
|
519
|
+
值后面的说明文字保留下来供核验单展示。红项(fail)只给显式声明的
|
|
520
|
+
"未通过";无法识别的描述性文本按"未记录"(none)处理不判红——
|
|
521
|
+
自检书写格式走样不应被放大成核验红项(对齐公文写作 3.7.3,实测
|
|
522
|
+
模型写入"备注"等额外键导致交付前检查误判红)。
|
|
493
523
|
"""
|
|
494
524
|
text = str(raw or "").strip()
|
|
495
525
|
lowered = text.lower()
|
|
@@ -499,7 +529,7 @@ def classify_check_value(raw: Any) -> Tuple[str, str]:
|
|
|
499
529
|
for prefix in ("已通过", "通过", "合格", "pass", "ok", "true", "是", "✓", "yes"):
|
|
500
530
|
if lowered.startswith(prefix):
|
|
501
531
|
return "pass", text[len(prefix):].lstrip("::,,、 ").strip()
|
|
502
|
-
return "
|
|
532
|
+
return "none", text
|
|
503
533
|
|
|
504
534
|
|
|
505
535
|
def normalize_self_check(raw: Any) -> Optional[Dict[str, Tuple[str, str]]]:
|
|
@@ -507,8 +537,13 @@ def normalize_self_check(raw: Any) -> Optional[Dict[str, Tuple[str, str]]]:
|
|
|
507
537
|
return None
|
|
508
538
|
items: Dict[str, Tuple[str, str]] = {}
|
|
509
539
|
for key, value in raw.items():
|
|
540
|
+
# 只认五项标准自检键(英文/中文变体映射);白名单外的键(备注、待核验、
|
|
541
|
+
# 下一步补充等描述性额外键)不计入核验单——分母不被撑大,多余键不构成
|
|
542
|
+
# "交付前检查"定义的核验项。
|
|
543
|
+
label = SELF_CHECK_LABELS.get(key) or SELF_CHECK_LABELS.get(str(key))
|
|
544
|
+
if label is None:
|
|
545
|
+
continue
|
|
510
546
|
status, note = classify_check_value(value)
|
|
511
|
-
label = SELF_CHECK_LABELS.get(key, SELF_CHECK_LABELS.get(str(key), str(key)))
|
|
512
547
|
items[label] = (status, note)
|
|
513
548
|
return items or None
|
|
514
549
|
|
|
@@ -518,12 +553,15 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
518
553
|
"""核验报告单数据。只计算脚本真实可得的结果,不虚构通过。"""
|
|
519
554
|
generated_at = generated_at or datetime.now()
|
|
520
555
|
|
|
521
|
-
# ① 依据溯源:摘录可比对 +
|
|
522
|
-
#
|
|
523
|
-
#
|
|
556
|
+
# ① 依据溯源:摘录可比对 + 原文链接可回看。
|
|
557
|
+
# 只统计被正文引用的材料——未引用召回材料未进入正文核验流程,其缺链在自身卡片上如实标注,
|
|
558
|
+
# 不应拖累"正文依据可交付"的报告级结论。
|
|
559
|
+
# PPT 提醒制:缺原文链接(接口对部分治理库文章不返回源网址,属数据源覆盖问题)与
|
|
560
|
+
# 缺摘录均降级为提醒,不参与核验判定——报告级只拦真实错误。
|
|
524
561
|
cited_sources = [s for s in sources if s.get("used", True)]
|
|
525
562
|
missing_links = [s["title"] for s in cited_sources if not s.get("has_link")]
|
|
526
563
|
missing_excerpts = [s["title"] for s in cited_sources if not (s.get("excerpt") or "").strip()]
|
|
564
|
+
trace_passed = len(cited_sources) - len(missing_excerpts)
|
|
527
565
|
|
|
528
566
|
# ② 引用绑定:正文角标与来源卡一一对应(按角标出现次数计,与用户在正文中数到的一致)
|
|
529
567
|
cited = citation_ids(answer)
|
|
@@ -534,7 +572,9 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
534
572
|
no_citation = bool(sources) and not cited
|
|
535
573
|
|
|
536
574
|
# ③ 时效检查:材料日期范围与历史材料计数
|
|
537
|
-
|
|
575
|
+
# 统计口径(对齐公文 3.7.6):③材料新旧/④材料构成只算正文引用的来源文章——
|
|
576
|
+
# sources 含未引用召回,其未来日期/类型会把时效范围与构成写歪。
|
|
577
|
+
dated = [parse_year_month(s.get("date")) for s in cited_sources]
|
|
538
578
|
dated = [d for d in dated if d]
|
|
539
579
|
freshness = None
|
|
540
580
|
old_count = 0
|
|
@@ -547,10 +587,10 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
547
587
|
|
|
548
588
|
# ④ 类型覆盖:素材四分类分布
|
|
549
589
|
coverage = {key: 0 for key in KIND_CATALOG}
|
|
550
|
-
for s in
|
|
590
|
+
for s in cited_sources:
|
|
551
591
|
coverage[s.get("type_key", "material")] = coverage.get(s.get("type_key", "material"), 0) + 1
|
|
552
592
|
|
|
553
|
-
# ⑤
|
|
593
|
+
# ⑤ 交付前检查:由检索/溯源 JSON 的 self_check 传入,未传入如实显示未记录
|
|
554
594
|
self_check_raw = None
|
|
555
595
|
for holder in (payload, payload.get("content") if isinstance(payload.get("content"), dict) else {}):
|
|
556
596
|
self_check_raw = self_check_raw or holder.get("selfCheck") or holder.get("self_check")
|
|
@@ -558,27 +598,30 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
558
598
|
self_check = None
|
|
559
599
|
if self_items:
|
|
560
600
|
passed = sum(1 for status, _ in self_items.values() if status == "pass")
|
|
601
|
+
fails = sum(1 for status, _ in self_items.values() if status == "fail")
|
|
602
|
+
# 状态由显式 fail 决定;none(描述性值/未记录)不判红也不拖垮通过
|
|
603
|
+
status = "fail" if fails else ("pass" if passed else "missing")
|
|
561
604
|
self_check = {"items": self_items, "passed": passed, "total": len(self_items),
|
|
562
|
-
"status":
|
|
605
|
+
"status": status}
|
|
563
606
|
else:
|
|
564
607
|
self_check = {"items": {}, "passed": 0, "total": len(SELF_CHECK_ITEMS), "status": "missing"}
|
|
565
608
|
|
|
566
609
|
# 政策效力:无法自动判定现行效力,列出建议人工复核
|
|
567
610
|
policy_count = coverage.get("policy", 0)
|
|
568
611
|
|
|
569
|
-
#
|
|
570
|
-
#
|
|
612
|
+
# 核验判定(PPT 提醒制):只有真实错误才判不通过(无素材 / 正文无角标 / 角标未绑定);
|
|
613
|
+
# 数据缺口(缺链/缺摘录)只提醒不影响判定。
|
|
571
614
|
trace_ok = bool(cited_sources)
|
|
572
615
|
binding_ok = (not unbound) and not no_citation
|
|
573
616
|
overall_passed = trace_ok and binding_ok
|
|
574
617
|
|
|
575
618
|
reasons = []
|
|
576
619
|
if not sources:
|
|
577
|
-
reasons.append("
|
|
620
|
+
reasons.append("没有找到来源文章")
|
|
578
621
|
if no_citation:
|
|
579
|
-
reasons.append("
|
|
622
|
+
reasons.append("正文里没有来源角标,对不上来源文章")
|
|
580
623
|
if unbound:
|
|
581
|
-
reasons.append(f"有 {len(unbound)}
|
|
624
|
+
reasons.append(f"有 {len(unbound)} 处角标找不到对应来源文章")
|
|
582
625
|
if self_check["status"] == "fail":
|
|
583
626
|
reasons.append("交付前检查有没过的项")
|
|
584
627
|
|
|
@@ -588,7 +631,7 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
588
631
|
"label": "核验完成,正文依据逐条对过原文" if overall_passed else "核验未完全通过",
|
|
589
632
|
"reasons": reasons,
|
|
590
633
|
},
|
|
591
|
-
"traceability": {"total": len(cited_sources), "passed":
|
|
634
|
+
"traceability": {"total": len(cited_sources), "passed": trace_passed,
|
|
592
635
|
"missing_links": missing_links, "missing_excerpts": missing_excerpts},
|
|
593
636
|
"binding": {"total": len(all_marks), "bound": len(all_marks) - len(unbound), "unbound": unbound_ids, "no_citation": no_citation},
|
|
594
637
|
"freshness": freshness,
|
|
@@ -599,6 +642,100 @@ def compute_verification(answer: str, sources: List[Dict[str, str]], payload: Di
|
|
|
599
642
|
}
|
|
600
643
|
|
|
601
644
|
|
|
645
|
+
# ============================================================
|
|
646
|
+
# 过程回顾 / 热词(真实计算,不虚构流程)
|
|
647
|
+
# ============================================================
|
|
648
|
+
|
|
649
|
+
def compute_process_stats(sources: List[Dict[str, str]], answer: str) -> Dict[str, Any]:
|
|
650
|
+
"""过程回顾条数据:检索次数、每组检索的召回/采用数、入库与引用计数。
|
|
651
|
+
|
|
652
|
+
全部来自素材自带的真实字段(search_key 分组、used 引用状态、正文角标计数),
|
|
653
|
+
不虚构任何流程步骤。
|
|
654
|
+
"""
|
|
655
|
+
order: List[str] = []
|
|
656
|
+
for s in sources:
|
|
657
|
+
key = (s.get("search_key") or "").strip()
|
|
658
|
+
if key and key not in order:
|
|
659
|
+
order.append(key)
|
|
660
|
+
cond_rows = []
|
|
661
|
+
for key in order:
|
|
662
|
+
group = [s for s in sources if (s.get("search_key") or "").strip() == key]
|
|
663
|
+
cond_rows.append({
|
|
664
|
+
"key": key,
|
|
665
|
+
"total": len(group),
|
|
666
|
+
"used": sum(1 for s in group if s.get("used", True)),
|
|
667
|
+
})
|
|
668
|
+
n_searches = len(cond_rows) or (1 if sources else 0)
|
|
669
|
+
used_count = sum(1 for s in sources if s.get("used", True))
|
|
670
|
+
unused_count = len(sources) - used_count
|
|
671
|
+
n_cite_marks = len(re.findall(r"\[(\d+)\]", answer))
|
|
672
|
+
return {
|
|
673
|
+
"conds": cond_rows,
|
|
674
|
+
"n_searches": n_searches,
|
|
675
|
+
"has_cond_detail": bool(cond_rows),
|
|
676
|
+
"n_materials": len(sources),
|
|
677
|
+
"used_count": used_count,
|
|
678
|
+
"unused_count": unused_count,
|
|
679
|
+
"n_cite_marks": n_cite_marks,
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
HOT_STOP = {
|
|
684
|
+
"关于", "通知", "工作", "意见", "方案", "实施", "有关", "问题", "情况", "报告", "总结",
|
|
685
|
+
"制度", "体系", "机制", "指导", "贯彻", "落实", "进一步", "以及", "其他", "相关", "以下",
|
|
686
|
+
"以上", "共和国", "人民", "中华", "国务院", "人民政府", "办公厅", "印发", "试行",
|
|
687
|
+
"办法", "条例", "若干", "的重点", "有所", "一个", "方面", "方式", "内容", "基本",
|
|
688
|
+
"发展", "建设", "政策", "产业", "企业", "应用", "改革", "目标", "任务", "规划",
|
|
689
|
+
"领域", "措施", "支持", "行动", "服务", "管理", "政府",
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
def extract_hot_terms(answer: str, sources: List[Dict[str, str]], top: int = 8) -> List[str]:
|
|
694
|
+
"""知识专库热词:材料标题(加权)+ 检索条件 + 正文的高频 2-4 字词,真实统计。
|
|
695
|
+
|
|
696
|
+
泛词过滤:出现在超过 60% 材料标题中的词(如库内全部材料共有的主题词)
|
|
697
|
+
无法筛出子集,没有筛选价值,剔除。
|
|
698
|
+
"""
|
|
699
|
+
corpus_parts: List[str] = []
|
|
700
|
+
for s in sources:
|
|
701
|
+
if s.get("title"):
|
|
702
|
+
corpus_parts.extend([s["title"]] * 3)
|
|
703
|
+
if s.get("search_key"):
|
|
704
|
+
corpus_parts.extend([s["search_key"]] * 2)
|
|
705
|
+
clean_answer = re.sub(r"\[\d+\]", "", answer or "")
|
|
706
|
+
corpus_parts.append(clean_answer)
|
|
707
|
+
corpus = "\n".join(corpus_parts)
|
|
708
|
+
|
|
709
|
+
counts: Dict[str, int] = {}
|
|
710
|
+
for run in re.findall(r"[一-鿿]{2,}", corpus):
|
|
711
|
+
for n in (2, 3, 4):
|
|
712
|
+
for i in range(len(run) - n + 1):
|
|
713
|
+
gram = run[i:i + n]
|
|
714
|
+
counts[gram] = counts.get(gram, 0) + 1
|
|
715
|
+
|
|
716
|
+
titles = [s.get("title") or "" for s in sources]
|
|
717
|
+
n_titles = max(1, len(titles))
|
|
718
|
+
df_limit = max(1, int(n_titles * 0.6))
|
|
719
|
+
|
|
720
|
+
cands = [(g, c) for g, c in counts.items()
|
|
721
|
+
if c >= 2 and g not in HOT_STOP and "的" not in g and not any(ch.isdigit() for ch in g)
|
|
722
|
+
and sum(1 for t in titles if g in t) <= df_limit]
|
|
723
|
+
cands.sort(key=lambda x: (-x[1], -len(x[0])))
|
|
724
|
+
kept: List[Tuple[str, int]] = []
|
|
725
|
+
for gram, count in cands:
|
|
726
|
+
redundant = False
|
|
727
|
+
for kgram, kcount in kept:
|
|
728
|
+
# 短词是已入选高频长词的子串且计数接近 → 被长词覆盖,剔除
|
|
729
|
+
if gram in kgram and kcount >= count * 0.6:
|
|
730
|
+
redundant = True
|
|
731
|
+
break
|
|
732
|
+
if not redundant:
|
|
733
|
+
kept.append((gram, count))
|
|
734
|
+
if len(kept) >= top:
|
|
735
|
+
break
|
|
736
|
+
return [g for g, _ in kept]
|
|
737
|
+
|
|
738
|
+
|
|
602
739
|
# ============================================================
|
|
603
740
|
# 正文解析与分节
|
|
604
741
|
# ============================================================
|
|
@@ -609,6 +746,7 @@ def render_inline_markdown(text: str, citation_repl) -> str:
|
|
|
609
746
|
body = re.sub(r"\*\*(.+?)\*\*", r"<strong>\1</strong>", body)
|
|
610
747
|
body = re.sub(r"__(.+?)__", r"<strong>\1</strong>", body)
|
|
611
748
|
body = re.sub(r"(?<!\*)\*([^*\n]+)\*(?!\*)", r"<em>\1</em>", body)
|
|
749
|
+
body = re.sub(r"(?<!_)_([^_\n]+_)(?!_)", r"<em>\1</em>", body)
|
|
612
750
|
body = re.sub(r"\[(\d+)\]", citation_repl, body)
|
|
613
751
|
return body
|
|
614
752
|
|
|
@@ -627,7 +765,7 @@ def split_markdown_table_row(line: str) -> List[str]:
|
|
|
627
765
|
return [cell.strip() for cell in line.strip().strip("|").split("|")]
|
|
628
766
|
|
|
629
767
|
|
|
630
|
-
def render_markdown_table(lines: List[str], citation_repl
|
|
768
|
+
def render_markdown_table(lines: List[str], citation_repl) -> str:
|
|
631
769
|
header = split_markdown_table_row(lines[0])
|
|
632
770
|
body_lines = lines[2:] if len(lines) > 1 and is_markdown_table_separator(lines[1]) else lines[1:]
|
|
633
771
|
head_html = "".join(f"<th>{render_inline_markdown(cell, citation_repl)}</th>" for cell in header)
|
|
@@ -636,26 +774,15 @@ def render_markdown_table(lines: List[str], citation_repl, sources: Optional[Lis
|
|
|
636
774
|
cells = split_markdown_table_row(line)
|
|
637
775
|
if len(cells) < len(header): # 行内缺格时补空,保持列对齐
|
|
638
776
|
cells = cells + [""] * (len(header) - len(cells))
|
|
639
|
-
|
|
640
|
-
for cell in cells:
|
|
641
|
-
inner = render_inline_markdown(cell, citation_repl)
|
|
642
|
-
# 证据灰框就地放在含角标的单元格内(文字下方折行),不在表外另挂一排
|
|
643
|
-
if sources:
|
|
644
|
-
cell_cites = citation_ids(cell)
|
|
645
|
-
if cell_cites:
|
|
646
|
-
inner += render_evidence_chips(cell_cites, sources)
|
|
647
|
-
tds.append(f"<td>{inner}</td>")
|
|
648
|
-
rows.append("<tr>" + "".join(tds) + "</tr>")
|
|
777
|
+
rows.append("<tr>" + "".join(f"<td>{render_inline_markdown(cell, citation_repl)}</td>" for cell in cells) + "</tr>")
|
|
649
778
|
wide_cls = " wide" if len(header) >= 4 else ""
|
|
650
779
|
return f'<div class="tbl-wrap"><table class="data-tbl{wide_cls}"><thead><tr>{head_html}</tr></thead><tbody>{"".join(rows)}</tbody></table></div>'
|
|
651
780
|
|
|
652
781
|
|
|
653
|
-
def
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
cleaned = re.sub(r"(?is)<script.*?</script>", "", value)
|
|
658
|
-
cleaned = re.sub(r"(?is)<style.*?</style>", "", value)
|
|
782
|
+
def sanitize_table_html(text: str) -> str:
|
|
783
|
+
"""清洗接口表格 HTML:仅保留 table/thead/tbody/tr/td/th/br,去脚本样式与属性。"""
|
|
784
|
+
cleaned = re.sub(r"(?is)<script.*?</script>", "", text)
|
|
785
|
+
cleaned = re.sub(r"(?is)<style.*?</style>", "", cleaned)
|
|
659
786
|
cleaned = re.sub(r"\s+on\w+\s*=\s*(['\"]).*?\1", "", cleaned)
|
|
660
787
|
cleaned = re.sub(r"\s+(href|src)\s*=\s*(['\"]).*?\2", "", cleaned)
|
|
661
788
|
allowed = {"table", "thead", "tbody", "tr", "td", "th", "br"}
|
|
@@ -666,17 +793,89 @@ def render_excerpt_html(text: str) -> str:
|
|
|
666
793
|
return ""
|
|
667
794
|
return f"<{closing}{name}>"
|
|
668
795
|
|
|
669
|
-
|
|
670
|
-
|
|
796
|
+
return re.sub(r"<\s*(/?)\s*([a-zA-Z0-9]+)(?:\s+[^>]*)?>", tag_repl, cleaned)
|
|
797
|
+
|
|
671
798
|
|
|
799
|
+
def render_excerpt_html(text: str) -> str:
|
|
800
|
+
value = str(text or "")
|
|
801
|
+
if "<table" not in value.lower():
|
|
802
|
+
return f'<div class="sc-excerpt plain">{esc(value)}</div>'
|
|
803
|
+
return f'<div class="sc-excerpt rich">{sanitize_table_html(value)}</div>'
|
|
672
804
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
805
|
+
|
|
806
|
+
def parse_answer_blocks(answer: str, valid_ids: set, chip_map: Optional[Dict[str, Any]] = None) -> Tuple[List[Dict[str, Any]], set]:
|
|
807
|
+
"""把正文 Markdown 解析为结构化块;同时收集全部角标。
|
|
808
|
+
|
|
809
|
+
角标渲染为原型式 jb 胶囊(编号圆徽章 + 材料标题),点击原地展开溯源卡;
|
|
810
|
+
表格单元格内的角标同样就地变胶囊(证据在含角标的单元格内,不挂表外)。
|
|
811
|
+
"""
|
|
812
|
+
|
|
813
|
+
def jb_html(cid: str) -> str:
|
|
814
|
+
jb = chip_map.get(cid)
|
|
815
|
+
if not jb:
|
|
816
|
+
return ""
|
|
817
|
+
if jb.get("url"):
|
|
818
|
+
btn_txt = "查看存档全文" if jb.get("dead") else "查看全文"
|
|
819
|
+
link = (f'<a class="jb-src" href="{esc(jb["url"])}" target="_blank" rel="noopener noreferrer">'
|
|
820
|
+
f'{ARROW_SVG}<span>{btn_txt}</span></a>')
|
|
821
|
+
else:
|
|
822
|
+
link = ""
|
|
823
|
+
# 原文直达区展示标题链(多段分块,各段带链——快速人工核验的核心抓手)
|
|
824
|
+
segs = jb.get("segments") or []
|
|
825
|
+
if segs:
|
|
826
|
+
quote = ""
|
|
827
|
+
seg_idx = -1
|
|
828
|
+
for seg in segs:
|
|
829
|
+
text = (seg.get("text") or "").strip()
|
|
830
|
+
if not text:
|
|
831
|
+
continue
|
|
832
|
+
seg_idx += 1
|
|
833
|
+
if "<table" in text.lower():
|
|
834
|
+
# 表格不能静态写进 span(解析器会拆散):此处留占位,
|
|
835
|
+
# 表格数据由 render_html 汇总注入页尾 JSON,展开时 JS 填充
|
|
836
|
+
tbl_key = f"{cid}-{seg_idx}"
|
|
837
|
+
jb.setdefault("_tables", {})[tbl_key] = sanitize_table_html(text)
|
|
838
|
+
body_txt = f'<span class="sc-excerpt rich tbl-holder" data-tbl="{esc(tbl_key)}"></span>'
|
|
839
|
+
else:
|
|
840
|
+
body_txt = f'<span class="sc-excerpt">{esc(text)}</span>'
|
|
841
|
+
inner = f'<i class="jb-no">{esc(cid)}</i>{body_txt}'
|
|
842
|
+
item = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
843
|
+
quote += render_crumb(seg.get("chain") or []) + item
|
|
844
|
+
elif jb["excerpt"]:
|
|
845
|
+
inner = f'<i class="jb-no">{esc(cid)}</i><span>{esc(jb["excerpt"])}</span>'
|
|
846
|
+
quote = f'<span class="jb-quote" role="button" tabindex="0">{inner}</span>'
|
|
847
|
+
else:
|
|
848
|
+
quote = ""
|
|
849
|
+
site_html = (f'<span class="jb-site"><span class="dot"></span>{esc(jb.get("site") or "")}</span>'
|
|
850
|
+
if (jb.get("site") or "").strip() else "")
|
|
851
|
+
return (
|
|
852
|
+
f'<span class="jb" data-cite="{esc(cid)}">'
|
|
853
|
+
f'<button class="jb-name" type="button" aria-expanded="false">{CARET_SVG}'
|
|
854
|
+
f'<i class="jb-id">{esc(cid)}</i>'
|
|
855
|
+
f'<span class="jb-txt">{esc(jb["title"])}</span></button>'
|
|
856
|
+
f'<span class="jb-body"><span class="jb-head"><span class="jb-label">{SRC_ICO_SVG}溯源原文:</span>{link}</span>'
|
|
857
|
+
f'{site_html}'
|
|
858
|
+
f'{quote}</span></span>'
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
def make_block_repl(block_text: str):
|
|
862
|
+
"""按块构造角标替换器:同块同材料只保留最后一次出现的角标(前处整体删除),
|
|
863
|
+
最后一处挂 jb 胶囊——一块中同一材料只出现一次,杜绝重复引用刷屏。"""
|
|
864
|
+
remaining: Dict[str, int] = {}
|
|
865
|
+
for cid in re.findall(r"\[(\d+)\]", block_text):
|
|
866
|
+
remaining[cid] = remaining.get(cid, 0) + 1
|
|
867
|
+
|
|
868
|
+
def repl(match: re.Match[str]) -> str:
|
|
869
|
+
cid = match.group(1)
|
|
870
|
+
remaining[cid] = max(0, remaining.get(cid, 1) - 1)
|
|
871
|
+
if remaining[cid] > 0:
|
|
872
|
+
return ""
|
|
873
|
+
if cid in chip_map:
|
|
874
|
+
return jb_html(cid)
|
|
875
|
+
# 未绑定角标(无对应材料):红色数字警示,绝不按位置猜测
|
|
876
|
+
return f'<sup class="cite unresolved" data-cite="{esc(cid)}" title="核验依据 [{esc(cid)}?]">{esc(cid)}?</sup>'
|
|
877
|
+
|
|
878
|
+
return repl
|
|
680
879
|
|
|
681
880
|
blocks: List[Dict[str, Any]] = []
|
|
682
881
|
lines = answer.split("\n")
|
|
@@ -686,11 +885,17 @@ def parse_answer_blocks(answer: str, valid_ids: set, sources: Optional[List[Dict
|
|
|
686
885
|
if not block:
|
|
687
886
|
idx += 1
|
|
688
887
|
continue
|
|
888
|
+
# 引文胶囊位置规范:角标与后随标点换位——标点紧跟文字,胶囊放标点之后
|
|
889
|
+
# (避免胶囊把句号挤到下一行孤悬,对齐深知晓原型"…内容。~出处"形态)
|
|
890
|
+
# 连续角标序列整体换位(如 [13][14];→ ;[13][14]):只换单个角标会让标点
|
|
891
|
+
# 被夹在两个胶囊之间(实测截图反馈)。
|
|
892
|
+
block = re.sub(r"((?:\[\d+\])+)([。;,、!?:;,.])", r"\2\1", block)
|
|
689
893
|
ids = citation_ids(block)
|
|
894
|
+
repl = make_block_repl(block)
|
|
690
895
|
heading_match = re.match(r"^(#{1,4})\s+(.+)$", block)
|
|
691
896
|
if heading_match:
|
|
692
897
|
blocks.append({"kind": "heading", "level": len(heading_match.group(1)),
|
|
693
|
-
"text": heading_match.group(2).strip(), "cites": ids})
|
|
898
|
+
"text": heading_match.group(2).strip(), "cites": ids, "repl": repl})
|
|
694
899
|
idx += 1
|
|
695
900
|
elif "|" in block and idx + 1 < len(lines) and is_markdown_table_separator(lines[idx + 1]):
|
|
696
901
|
table_lines = [block, lines[idx + 1].strip()]
|
|
@@ -698,7 +903,8 @@ def parse_answer_blocks(answer: str, valid_ids: set, sources: Optional[List[Dict
|
|
|
698
903
|
while idx < len(lines) and "|" in lines[idx].strip() and lines[idx].strip():
|
|
699
904
|
table_lines.append(lines[idx].strip())
|
|
700
905
|
idx += 1
|
|
701
|
-
|
|
906
|
+
repl = make_block_repl("\n".join(table_lines))
|
|
907
|
+
blocks.append({"kind": "table", "html": render_markdown_table(table_lines, repl), "cites": citation_ids("\n".join(table_lines))})
|
|
702
908
|
elif block in {"---", "***"}:
|
|
703
909
|
blocks.append({"kind": "hr", "html": '<hr class="doc-divider">', "cites": []})
|
|
704
910
|
idx += 1
|
|
@@ -725,10 +931,10 @@ def split_heading_number(text: str) -> Tuple[Optional[str], str]:
|
|
|
725
931
|
|
|
726
932
|
|
|
727
933
|
def group_sections(blocks: List[Dict[str, Any]]) -> Tuple[Optional[str], List[Dict[str, Any]]]:
|
|
728
|
-
"""
|
|
934
|
+
"""按标题层级切分章节。返回(报告标题, 章节列表)。
|
|
729
935
|
|
|
730
|
-
|
|
731
|
-
|
|
936
|
+
规则:最浅层级标题若唯一且居文首,视为报告标题提出;其下一级为章节边界。
|
|
937
|
+
无标题的短正文整篇一节。
|
|
732
938
|
"""
|
|
733
939
|
if not blocks:
|
|
734
940
|
return None, [{"title": None, "blocks": []}]
|
|
@@ -766,38 +972,43 @@ def group_sections(blocks: List[Dict[str, Any]]) -> Tuple[Optional[str], List[Di
|
|
|
766
972
|
# 各部分渲染
|
|
767
973
|
# ============================================================
|
|
768
974
|
|
|
769
|
-
def
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
975
|
+
def build_chip_data(sources: List[Dict[str, str]]) -> Dict[str, Dict[str, Any]]:
|
|
976
|
+
"""行内引文胶囊数据:id → {title, site, url, excerpt, segments}。
|
|
977
|
+
|
|
978
|
+
角标后渲染原型式 jb(行内小胶囊,点击展开块级卡)。摘录展示完整
|
|
979
|
+
原文原段、不截断——块内去重后重复量可控,核对场景下就地读全文。
|
|
980
|
+
"""
|
|
981
|
+
chip_map: Dict[str, Dict[str, Any]] = {}
|
|
982
|
+
for source in sources:
|
|
983
|
+
cid = source["id"]
|
|
984
|
+
if cid in chip_map:
|
|
775
985
|
continue
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
)
|
|
792
|
-
if not chips:
|
|
793
|
-
return ""
|
|
794
|
-
return f'<div class="ev-row">{"".join(chips)}</div>'
|
|
986
|
+
meta_bits = [v for v in [source.get("agency"), source.get("date")] if v and v != "未知来源"]
|
|
987
|
+
url = source.get("url") if (source.get("url") and source["url"] != "接口未返回") else (source.get("policy_url") or "")
|
|
988
|
+
if source.get("link_dead"):
|
|
989
|
+
url = source.get("snapshot") or ""
|
|
990
|
+
site_bits = ([source["doc_number"]] if source.get("doc_number") else []) + meta_bits
|
|
991
|
+
chip_map[cid] = {
|
|
992
|
+
"title": short(source.get("title") or "未命名来源文章", 30),
|
|
993
|
+
"site": " · ".join(site_bits) or "来源站点",
|
|
994
|
+
"url": url,
|
|
995
|
+
"snapshot": source.get("snapshot") or "",
|
|
996
|
+
"dead": bool(source.get("link_dead")),
|
|
997
|
+
"excerpt": (source.get("excerpt") or "").strip(),
|
|
998
|
+
"segments": source.get("segments") or [],
|
|
999
|
+
}
|
|
1000
|
+
return chip_map
|
|
795
1001
|
|
|
796
1002
|
|
|
797
|
-
def render_source_links(url: str, policy_url: str = "") -> str:
|
|
1003
|
+
def render_source_links(url: str, policy_url: str = "", snapshot: str = "", link_dead: bool = False) -> str:
|
|
1004
|
+
"""链接区四态:原文可回看 / 原文失效改快照 / 原文失效无快照 / 无源网址有快照。
|
|
1005
|
+
快照是接口对原文的存档副本,文案如实标注,不冒充原文链接。"""
|
|
798
1006
|
links = []
|
|
799
|
-
if url and url != "接口未返回":
|
|
800
|
-
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener"
|
|
1007
|
+
if url and url != "接口未返回" and not link_dead:
|
|
1008
|
+
links.append(f'<a href="{esc(url)}" target="_blank" rel="noopener">查看全文 ↗</a>')
|
|
1009
|
+
if snapshot:
|
|
1010
|
+
# 有哪个显示哪个:快照统一展示"查看存档全文",不做原文失效的状态解释
|
|
1011
|
+
links.append(f'<a class="snap" href="{esc(snapshot)}" target="_blank" rel="noopener">查看存档全文 ↗</a>')
|
|
801
1012
|
if policy_url:
|
|
802
1013
|
links.append(f'<a href="{esc(policy_url)}" target="_blank" rel="noopener">知识专库原文 ↗</a>')
|
|
803
1014
|
if not links:
|
|
@@ -806,7 +1017,7 @@ def render_source_links(url: str, policy_url: str = "") -> str:
|
|
|
806
1017
|
|
|
807
1018
|
|
|
808
1019
|
def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
809
|
-
"""核验报告单:报告级核验结论 + 五项指标(
|
|
1020
|
+
"""核验报告单:报告级核验结论 + 五项指标(PPT 双版 + 提醒制口径)。"""
|
|
810
1021
|
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
811
1022
|
manual_checks_html = "".join("<br>· " + esc(x) for x in v.get("manual_checks", []))
|
|
812
1023
|
ov = v["overall"]
|
|
@@ -820,24 +1031,24 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
820
1031
|
n_missing = len(set(tr["missing_links"]) | set(tr["missing_excerpts"]))
|
|
821
1032
|
if not tr["total"]:
|
|
822
1033
|
tr_html = ('<div class="vi"><span class="s fail">✗ 依据溯源 0/0</span>'
|
|
823
|
-
'<span class="d"
|
|
1034
|
+
'<span class="d">未识别到来源文章</span></div>')
|
|
824
1035
|
elif n_missing:
|
|
825
|
-
#
|
|
1036
|
+
# PPT 提醒制:数据缺口恒绿,附温和提醒(缺口明细在材料卡上如实标注)
|
|
826
1037
|
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["total"]}/{tr["total"]}</span>'
|
|
827
|
-
f'<span class="d"
|
|
1038
|
+
f'<span class="d">每篇来源文章的摘录可比对;{n_missing} 篇原文链接或摘录待补,卡片已标注,汇报前请注意核对</span></div>')
|
|
828
1039
|
else:
|
|
829
|
-
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["
|
|
830
|
-
f'<span class="d"
|
|
1040
|
+
tr_html = (f'<div class="vi"><span class="s ok">✓ 依据溯源 {tr["passed"]}/{tr["total"]}</span>'
|
|
1041
|
+
f'<span class="d">每篇来源文章的摘录可比对,原文或存档快照可回看</span></div>')
|
|
831
1042
|
|
|
832
1043
|
bd = v["binding"]
|
|
833
1044
|
if bd.get("no_citation"):
|
|
834
1045
|
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 0/0</span>'
|
|
835
|
-
f'<span class="d">正文里没有来源角标,{v["traceability"]["total"]}
|
|
1046
|
+
f'<span class="d">正文里没有来源角标,{v["traceability"]["total"]} 篇来源文章对不上正文</span></div>')
|
|
836
1047
|
elif not bd["total"]:
|
|
837
1048
|
bd_html = '<div class="vi"><span class="s none">— 引用对应 0/0</span><span class="d">正文里没有来源角标</span></div>'
|
|
838
1049
|
elif not bd["unbound"]:
|
|
839
1050
|
bd_html = (f'<div class="vi"><span class="s ok">✓ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
840
|
-
f'<span class="d">正文每处 [n]
|
|
1051
|
+
f'<span class="d">正文每处 [n] 都能找到对应来源文章</span></div>')
|
|
841
1052
|
else:
|
|
842
1053
|
unbound_text = "、".join(f"[{esc(x)}]" for x in bd["unbound"][:8])
|
|
843
1054
|
bd_html = (f'<div class="vi"><span class="s fail">✗ 引用对应 {bd["bound"]}/{bd["total"]}</span>'
|
|
@@ -846,8 +1057,9 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
846
1057
|
fr = v["freshness"]
|
|
847
1058
|
if fr:
|
|
848
1059
|
rng = f"{fr['min'][0]}-{fr['min'][1]:02d}~{fr['max'][0]}-{fr['max'][1]:02d}"
|
|
849
|
-
|
|
850
|
-
|
|
1060
|
+
# 「N 条年头较久,按参考口径使用」半句已移除(长期有效的政策法规会被误判"年头较久",
|
|
1061
|
+
# 且"按参考口径使用"读者无从理解);old_count 仍在 freshness 中照常计算。
|
|
1062
|
+
fr_html = f'<div class="vi"><span class="s ok">✓ 材料新旧 已核</span><span class="d">材料日期 {esc(rng)}</span></div>'
|
|
851
1063
|
else:
|
|
852
1064
|
fr_html = '<div class="vi"><span class="s none">— 材料新旧 未记录</span><span class="d">材料没标发布日期</span></div>'
|
|
853
1065
|
|
|
@@ -862,12 +1074,14 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
862
1074
|
notes = ";".join(note for _, note in sc["items"].values() if note)
|
|
863
1075
|
title_attr = f' title="{esc(notes)}"' if notes else ""
|
|
864
1076
|
item_names = "、".join(sc["items"].keys()) if sc["items"] else "、".join(label for _, label in SELF_CHECK_ITEMS)
|
|
865
|
-
|
|
1077
|
+
none_count = sum(1 for status, _ in sc["items"].values() if status == "none")
|
|
1078
|
+
none_note = f"({none_count} 项未记录)" if none_count else ""
|
|
1079
|
+
sc_html = (f'<div class="vi"><span class="s ok"{title_attr}>✓ 交付前检查 {sc["passed"]}/{sc["total"]}{esc(none_note)}</span>'
|
|
866
1080
|
f'<span class="d">{esc(item_names)}{esc(" · 悬停查看说明" if notes else "")}</span></div>')
|
|
867
1081
|
elif sc["status"] == "fail":
|
|
868
1082
|
failed_parts = []
|
|
869
1083
|
for label, (status, note) in sc["items"].items():
|
|
870
|
-
if status
|
|
1084
|
+
if status == "fail":
|
|
871
1085
|
suffix = f"({note[:40]}…)" if len(note) > 40 else (f"({note})" if note else "")
|
|
872
1086
|
failed_parts.append(label + suffix)
|
|
873
1087
|
sc_html = (f'<div class="vi"><span class="s fail">✗ 交付前检查 {sc["passed"]}/{sc["total"]}</span>'
|
|
@@ -877,10 +1091,8 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
877
1091
|
sc_html = (f'<div class="vi"><span class="s none">— 交付前检查 未记录</span>'
|
|
878
1092
|
f'<span class="d">检索 JSON 没写入 self_check(默认查:{esc(default_names)})</span></div>')
|
|
879
1093
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
manual = (f'<div class="vi"><span class="s man">◐ 现行效力</span>'
|
|
883
|
-
f'<span class="d">{v["policy_count"]} 份政策文件建议按官方发布确认是否现行有效</span></div>')
|
|
1094
|
+
# 3.7.2 起「现行效力」提示行移除:该提示对用户无操作价值,policy_count
|
|
1095
|
+
# 保留在计算层不再展示(对齐公文写作 3.7.2 徐总产品要求)。
|
|
884
1096
|
|
|
885
1097
|
what = "提纲页面规划" if stage == "outline" else "页面级结论"
|
|
886
1098
|
return f"""
|
|
@@ -888,117 +1100,231 @@ def render_verify_panel(v: Dict[str, Any], stage: str = "final") -> str:
|
|
|
888
1100
|
<div class="v-head"><span class="v-shield">{'✓' if ov['passed'] else '!'}</span>{esc(ov['label'])}({esc(stage_label)}){stamp}</div>
|
|
889
1101
|
{reasons_html}
|
|
890
1102
|
<div class="v-grid">
|
|
891
|
-
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}
|
|
1103
|
+
{tr_html}{bd_html}{fr_html}{cov_html}{sc_html}
|
|
892
1104
|
</div>
|
|
893
|
-
<div class="v-note">核验方式:先用深知可信搜索找权威来源,再把{esc(what)}
|
|
1105
|
+
<div class="v-note">核验方式:先用深知可信搜索找权威来源,再把{esc(what)}的每处依据和原文逐条比对(都能点开原文回看),最后做了交付前五项检查。{manual_checks_html}</div>
|
|
894
1106
|
</div>"""
|
|
895
1107
|
|
|
896
1108
|
|
|
1109
|
+
SRC_ICO_SVG = ('<svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.8" '
|
|
1110
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">'
|
|
1111
|
+
'<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/>'
|
|
1112
|
+
'<path d="M9 13h6M9 17h4"/></svg>')
|
|
1113
|
+
ARROW_SVG = ('<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2.2" '
|
|
1114
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7 17 17 7M9 7h8v8"/></svg>')
|
|
1115
|
+
CARET_SVG = ('<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.4" '
|
|
1116
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>')
|
|
1117
|
+
|
|
1118
|
+
|
|
897
1119
|
def render_section_cards(sections: List[Dict[str, Any]], sources: List[Dict[str, str]]) -> str:
|
|
1120
|
+
"""正文渲染(原型复刻):chapter(h2)+ lead/para 段落文档流 + 句后 jb 引文胶囊。
|
|
1121
|
+
|
|
1122
|
+
同一块内同一材料只保留最后一处角标与胶囊(make_block_repl 去重);
|
|
1123
|
+
提纲页面规划表等 markdown 表格内角标同样就地变胶囊(证据在含角标的单元格内)。
|
|
1124
|
+
"""
|
|
1125
|
+
parts: List[str] = []
|
|
1126
|
+
first_para = True
|
|
898
1127
|
source_ids = {s["id"] for s in sources}
|
|
899
|
-
|
|
900
|
-
|
|
1128
|
+
for sec_idx, sec in enumerate(sections, 1):
|
|
1129
|
+
number, title_text = split_heading_number(sec["title"] or "")
|
|
1130
|
+
chapter_title = f"{number}、{title_text}" if (number and title_text) else (title_text or "")
|
|
901
1131
|
sec_cites: List[str] = []
|
|
902
1132
|
for b in sec["blocks"]:
|
|
903
1133
|
for cid in b.get("cites", []):
|
|
904
1134
|
if cid not in sec_cites:
|
|
905
1135
|
sec_cites.append(cid)
|
|
906
|
-
|
|
907
|
-
number, title_text = split_heading_number(sec["title"] or "")
|
|
908
|
-
no_html = f'<span class="sec-no">{esc(number)}</span>' if number else ""
|
|
909
|
-
title_html = f"<h3>{esc(title_text)}</h3>" if title_text else ""
|
|
910
|
-
if sec_cites:
|
|
911
|
-
badge_state = "bad" if unbound_count else ""
|
|
912
|
-
badge_text = f"本节引用 {len(sec_cites)} 处" + (f" · {unbound_count} 处未绑定" if unbound_count else " · 已核验")
|
|
913
|
-
badge_html = f'<span class="sec-badge {badge_state}">{esc(badge_text)}</span>'
|
|
914
|
-
else:
|
|
1136
|
+
if chapter_title:
|
|
915
1137
|
badge_html = ""
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1138
|
+
if sec_cites:
|
|
1139
|
+
unbound = sum(1 for cid in sec_cites if cid not in source_ids)
|
|
1140
|
+
state = "bad" if unbound else ""
|
|
1141
|
+
text = f"本章引用 {len(sec_cites)} 处" + (f" · {unbound} 处未绑定" if unbound else " · 已核验")
|
|
1142
|
+
badge_html = f'<span class="sec-badge {state}">{esc(text)}</span>'
|
|
1143
|
+
parts.append(f'<section class="chapter" id="sec-{sec_idx}">'
|
|
1144
|
+
f'<header class="ch-head"><h2>{esc(chapter_title)}</h2>{badge_html}</header>')
|
|
919
1145
|
for b in sec["blocks"]:
|
|
920
1146
|
if b["kind"] == "heading":
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1147
|
+
parts.append(f'<p class="para"><b class="kw">{esc(b["text"])}</b></p>')
|
|
1148
|
+
first_para = False
|
|
1149
|
+
continue
|
|
1150
|
+
cls = "lead" if first_para else "para"
|
|
1151
|
+
first_para = False
|
|
1152
|
+
if b["kind"] == "list_item":
|
|
924
1153
|
marker = f'{esc(b.get("number", "•"))}.' if b.get("numbered") else "•"
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
)
|
|
929
|
-
elif b["kind"] == "table":
|
|
930
|
-
body_parts.append(f'<div class="doc-block">{b["html"]}</div>')
|
|
1154
|
+
parts.append(f'<p class="{cls}"><b class="kw">{marker}</b> {b["html"]}</p>')
|
|
1155
|
+
elif b["kind"] == "hr":
|
|
1156
|
+
parts.append('<hr class="doc-divider">')
|
|
931
1157
|
else:
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1158
|
+
parts.append(f'<p class="{cls}">{b["html"]}</p>')
|
|
1159
|
+
if chapter_title:
|
|
1160
|
+
parts.append("</section>")
|
|
1161
|
+
return "\n".join(parts)
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
def strip_leading_chain(text: str, chain: List[str]) -> str:
|
|
1165
|
+
"""剥掉段落文本开头与标题链各级重复的前缀。
|
|
1166
|
+
|
|
1167
|
+
接口部分材料的"内容"字段自带段落标题前缀(个别还重复两遍),标题链已承载
|
|
1168
|
+
位置信息,摘录开头再出现同级文本即冗余;逐级最长匹配剥离,无重复则原样返回。
|
|
1169
|
+
"""
|
|
1170
|
+
t = (text or "").strip()
|
|
1171
|
+
cands = set()
|
|
1172
|
+
for lvl in chain:
|
|
1173
|
+
lvl = (lvl or "").strip()
|
|
1174
|
+
if lvl:
|
|
1175
|
+
cands.add(lvl)
|
|
1176
|
+
# 粘连标题(接口未给分隔符,如"建设交通强省5.民航和低空")拆出编号尾部子串
|
|
1177
|
+
parts = re.split(r"(?<=[一-鿿])(?=\d+[.、])", lvl)
|
|
1178
|
+
if len(parts) > 1 and parts[-1].strip():
|
|
1179
|
+
cands.add(parts[-1].strip())
|
|
1180
|
+
levels = sorted(cands, key=len, reverse=True)
|
|
1181
|
+
changed = True
|
|
1182
|
+
while changed and t:
|
|
1183
|
+
changed = False
|
|
1184
|
+
for lvl in levels:
|
|
1185
|
+
if t.startswith(lvl):
|
|
1186
|
+
t = t[len(lvl):].lstrip(" \n\r\t、。;;,,").strip()
|
|
1187
|
+
changed = True
|
|
1188
|
+
break
|
|
1189
|
+
return t
|
|
1190
|
+
|
|
1191
|
+
|
|
1192
|
+
def render_crumb(chain: List[str]) -> str:
|
|
1193
|
+
"""面包屑标题链:文章 › 章 › 节(标题链是模型生成的结构化位置,核验核心抓手)。
|
|
1194
|
+
|
|
1195
|
+
降级规则(对齐公文写作 3.7.2):段落本身无章节层级(链上只有文章名)时不显示
|
|
1196
|
+
标题链行——材料卡标题已是文章名,单独一行重复文章名对定位无增量。
|
|
1197
|
+
"""
|
|
1198
|
+
parts = [esc(level) for level in chain if level]
|
|
1199
|
+
if len(parts) <= 1:
|
|
1200
|
+
return ""
|
|
1201
|
+
return '<span class="crumb">' + ' <i>›</i> '.join(parts) + "</span>"
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
def render_segments(source: Dict[str, Any]) -> str:
|
|
1205
|
+
"""多段分块摘录:每段独立区块,各带自己的标题链——段落结构与位置直接可见。"""
|
|
1206
|
+
segments = source.get("segments") or []
|
|
1207
|
+
if not segments:
|
|
1208
|
+
return render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
1209
|
+
blocks = []
|
|
1210
|
+
for seg in segments:
|
|
1211
|
+
text = (seg.get("text") or "").strip()
|
|
1212
|
+
if not text:
|
|
1213
|
+
continue
|
|
1214
|
+
blocks.append(f'<div class="seg-block">{render_crumb(seg.get("chain") or [])}'
|
|
1215
|
+
f'{render_excerpt_html(text)}</div>')
|
|
1216
|
+
return "".join(blocks) if blocks else render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")
|
|
935
1217
|
|
|
936
1218
|
|
|
937
|
-
def render_source_card(source: Dict[str, str]) -> str:
|
|
1219
|
+
def render_source_card(source: Dict[str, str], for_print: bool = False) -> str:
|
|
938
1220
|
if not source.get("used", True):
|
|
939
1221
|
# 未引用召回材料:不标"已核验"(未进入正文核验流程),只标可否查看
|
|
940
|
-
vk = ('<span class="sc-vk" style="color:var(--muted)"
|
|
1222
|
+
vk = ('<span class="sc-vk" style="color:var(--muted)">可查看全文</span>' if source.get("has_link")
|
|
941
1223
|
else '<span class="sc-vk warn">待补链接</span>')
|
|
942
1224
|
note_html = ""
|
|
943
1225
|
elif source.get("verified"):
|
|
944
|
-
note = source.get("verify_note") or "
|
|
1226
|
+
note = source.get("verify_note") or "摘录可比对,可回看原文"
|
|
945
1227
|
if not source.get("has_link"):
|
|
1228
|
+
# PPT 提醒制:无原文链接不改变核验状态,卡片附温和提醒
|
|
946
1229
|
note = "摘录可比对;本条无原文链接,请留意核对"
|
|
947
1230
|
vk = f'<span class="sc-vk ok" title="{esc(note)}">✓ 已核验</span>'
|
|
948
1231
|
if not source.get("has_link"):
|
|
949
1232
|
vk += '<span class="sc-vk warn">◐ 无原文链接</span>'
|
|
950
1233
|
note_html = f'<div class="sc-vnote">{esc(short(note, 90))}</div>' if source.get("verify_note") else ""
|
|
951
1234
|
else:
|
|
952
|
-
reason = "
|
|
1235
|
+
reason = "待补原文链接" if not source.get("has_link") else "待补摘录"
|
|
953
1236
|
vk = f'<span class="sc-vk warn">◐ {reason}</span>'
|
|
954
1237
|
note_html = ""
|
|
955
|
-
links = render_source_links(source.get("url"), source.get("policy_url", ""))
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽);"较高"(门户抓取)不标
|
|
1238
|
+
links = render_source_links(source.get("url"), source.get("policy_url", ""), source.get("snapshot", ""), source.get("link_dead", False))
|
|
1239
|
+
# 关键性行:有文号(接口字段或合并 JSON)时"文号 · 数据源 · 日期",否则"数据源 · 日期"
|
|
1240
|
+
meta_parts = [v for v in [source.get("doc_number"), source.get("agency"), source.get("date"), source.get("area")]
|
|
1241
|
+
if v and v != "未知来源"]
|
|
1242
|
+
meta = " | ".join(meta_parts)
|
|
1243
|
+
# 高可信徽标:仅"发布日期可信度=高"(模型治理入库、标题模型精抽)的材料;"较高"(门户抓取)不标。
|
|
962
1244
|
conf_badge = ""
|
|
963
1245
|
if source.get("conf") == "高":
|
|
964
1246
|
conf_badge = ('<span class="sc-conf" title="发布日期可信度:高。内容经模型治理入库,'
|
|
965
1247
|
'标题为模型从原文动态抽取,非规则提取">高可信</span>')
|
|
966
|
-
excerpt_tag = '<div class="sc-extag">▍ 原文原段(非 AI 生成)</div>'
|
|
967
1248
|
# 已引用材料显示角标编号;未引用召回材料显示"未引用"灰标(不占正文角标号)
|
|
968
1249
|
id_html = f'<span class="sc-id">[{esc(source["id"])}]</span>' if source.get("used", True) else '<span class="sc-unused">未引用</span>'
|
|
1250
|
+
body_html = (f'<div class="sc-head">{id_html}'
|
|
1251
|
+
f'<span class="sc-type">{esc(source["type_label"])}</span>{conf_badge}{vk}</div>'
|
|
1252
|
+
f'<h4>{esc(source.get("title"))}</h4>'
|
|
1253
|
+
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
1254
|
+
f'{note_html}'
|
|
1255
|
+
f'{render_segments(source)}'
|
|
1256
|
+
f'{links}')
|
|
1257
|
+
if for_print:
|
|
1258
|
+
# 打印附录版:无交互属性,避免与专库卡片 id 冲突
|
|
1259
|
+
return f'<article class="scard print-only {source["type_css"]}">{body_html}</article>'
|
|
969
1260
|
unused_attr = "" if source.get("used", True) else ' data-unused="1"'
|
|
970
1261
|
return (
|
|
971
|
-
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}"
|
|
972
|
-
f'
|
|
973
|
-
f'<span class="sc-type">{esc(source["type_label"])}</span>{conf_badge}{vk}</div>'
|
|
974
|
-
f'<h4>{esc(source.get("title"))}</h4>'
|
|
975
|
-
f'<div class="sc-meta">{esc(meta)}</div>'
|
|
976
|
-
f'{chain_html}{section_html}{note_html}'
|
|
977
|
-
f'{excerpt_tag}'
|
|
978
|
-
f'{render_excerpt_html(source.get("excerpt") or "接口返回中未识别到可展示的摘录。")}'
|
|
979
|
-
f'<div class="sc-more" role="button" tabindex="0"></div>'
|
|
980
|
-
f'{links}</article>'
|
|
1262
|
+
f'<article class="scard {source["type_css"]}" id="src-{esc(source["id"])}" data-type="{esc(source["type_key"])}" '
|
|
1263
|
+
f'data-cite-id="{esc(source["id"])}" data-search="{esc(source.get("search_key", ""))}"{unused_attr}>{body_html}</article>'
|
|
981
1264
|
)
|
|
982
1265
|
|
|
983
1266
|
|
|
984
|
-
def
|
|
1267
|
+
def render_process_bar(stats: Dict[str, Any], verification: Dict[str, Any]) -> str:
|
|
1268
|
+
"""过程回顾条:静态回放真实流程。无思考流数据,不做"深度思考"步骤。"""
|
|
1269
|
+
ov = verification["overall"]
|
|
1270
|
+
tr = verification["traceability"]
|
|
1271
|
+
first_query = stats["conds"][0]["key"] if stats["conds"] else ""
|
|
1272
|
+
detail_rows = "".join(
|
|
1273
|
+
f'<div class="pd-row"><b>{esc(row["key"])}</b>'
|
|
1274
|
+
f'<span>召回 {row["total"]} 条 · 正文采用 {row["used"]} 条</span></div>'
|
|
1275
|
+
for row in stats["conds"]
|
|
1276
|
+
) or '<div class="pd-row"><span>本次溯源 JSON 未记录各次检索条件</span></div>'
|
|
1277
|
+
detail_hint = f'{esc(short(first_query, 26))}…' if (stats["n_searches"] > 1 and first_query) else "查看检索明细"
|
|
1278
|
+
if stats["n_searches"] > 1:
|
|
1279
|
+
step1_sub = f"共 {stats['n_searches']} 路检索 · {detail_hint}"
|
|
1280
|
+
elif first_query:
|
|
1281
|
+
step1_sub = esc(short(first_query, 26))
|
|
1282
|
+
else:
|
|
1283
|
+
step1_sub = "深知可信搜索"
|
|
1284
|
+
step4_state = "done" if ov["passed"] else "bad"
|
|
1285
|
+
step4_icon = "✓" if ov["passed"] else "!"
|
|
1286
|
+
step4_label = "核验完成" if ov["passed"] else "核验未完全通过"
|
|
1287
|
+
step4_sub = "结论:正文依据逐条对过原文" if ov["passed"] else esc(short(";".join(ov["reasons"]) or "见核验报告单", 30))
|
|
1288
|
+
return f"""
|
|
1289
|
+
<section class="process" aria-label="生成过程回顾">
|
|
1290
|
+
<div class="p-head"><b>过程回顾</b><span>数字来自本次任务的真实记录</span></div>
|
|
1291
|
+
<ol class="p-steps">
|
|
1292
|
+
<li class="p-step expandable" id="p-step-search" role="button" tabindex="0" title="展开各路检索明细">
|
|
1293
|
+
<span class="p-no">1</span>
|
|
1294
|
+
<div class="p-txt"><b>深知检索 {stats['n_searches']} 路</b><i>{step1_sub}</i></div>
|
|
1295
|
+
</li>
|
|
1296
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1297
|
+
<li class="p-step">
|
|
1298
|
+
<span class="p-no">2</span>
|
|
1299
|
+
<div class="p-txt"><b>来源文章入库 {stats['n_materials']} 篇</b><i>正文采用 {stats['used_count']} · 召回未采用 {stats['unused_count']}</i></div>
|
|
1300
|
+
</li>
|
|
1301
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1302
|
+
<li class="p-step">
|
|
1303
|
+
<span class="p-no">3</span>
|
|
1304
|
+
<div class="p-txt"><b>逐条比对原文</b><i>依据溯源 {tr['passed']}/{tr['total']} · 摘录可比对</i></div>
|
|
1305
|
+
</li>
|
|
1306
|
+
<li class="p-arrow" aria-hidden="true">›</li>
|
|
1307
|
+
<li class="p-step {step4_state}">
|
|
1308
|
+
<span class="p-no">{step4_icon}</span>
|
|
1309
|
+
<div class="p-txt"><b>{esc(step4_label)}</b><i>{step4_sub}</i></div>
|
|
1310
|
+
</li>
|
|
1311
|
+
</ol>
|
|
1312
|
+
<div class="p-detail" id="p-detail">{detail_rows}</div>
|
|
1313
|
+
</section>"""
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
def render_library_view(sources: List[Dict[str, str]], hot_terms: List[str]) -> str:
|
|
1317
|
+
"""知识专库全屏视图:大搜索 + 热词 + 检索分组 tabs + 材料卡列表。"""
|
|
985
1318
|
if not sources:
|
|
986
|
-
return '<
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
# 不用 <details> 折叠:部分宿主(WorkBuddy 等)的 HTML 预览服务会改写折叠区导致卡片丢失
|
|
993
|
-
uncited_html = (
|
|
994
|
-
'<div class="uncited-group"><div class="ug-title">未引用素材('
|
|
995
|
-
f'{len(uncited)} 条 · 接口召回但正文未采用,供比对参考)</div>'
|
|
996
|
-
f'<div class="uncited-list">{uncited_cards}</div></div>'
|
|
997
|
-
)
|
|
998
|
-
# 筛选维度 = 检索分组(多路检索时按每路 search_key 分组);类型不再作筛选维度(卡片徽章保留)
|
|
1319
|
+
return ('<section class="view" id="view-library" aria-label="知识专库">'
|
|
1320
|
+
'<div class="lib-empty">接口返回中未识别到可展示的来源文章。</div></section>')
|
|
1321
|
+
used_sources = [s for s in sources if s.get("used", True)]
|
|
1322
|
+
unused_sources = [s for s in sources if not s.get("used", True)]
|
|
1323
|
+
|
|
1324
|
+
# tabs = 检索分组(全部 / 各路检索 / 未引用),数字真实统计
|
|
999
1325
|
conds: List[Tuple[str, int]] = []
|
|
1000
1326
|
for s in sources:
|
|
1001
|
-
key = s.get("search_key"
|
|
1327
|
+
key = (s.get("search_key") or "").strip()
|
|
1002
1328
|
if not key:
|
|
1003
1329
|
continue
|
|
1004
1330
|
for i, (name, count) in enumerate(conds):
|
|
@@ -1007,48 +1333,83 @@ def render_sources_panel(sources: List[Dict[str, str]], used: List[str], kb_zone
|
|
|
1007
1333
|
break
|
|
1008
1334
|
else:
|
|
1009
1335
|
conds.append((key, 1))
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1336
|
+
tabs = [f'<button class="on" data-cond="" type="button">全部({len(sources)})</button>']
|
|
1337
|
+
for name, count in conds:
|
|
1338
|
+
tabs.append(f'<button data-cond="{esc(name)}" type="button">{esc(name)}({count})</button>')
|
|
1339
|
+
if unused_sources:
|
|
1340
|
+
tabs.append(f'<button data-cond="__unused__" type="button">未引用({len(unused_sources)})</button>')
|
|
1341
|
+
|
|
1342
|
+
hot_html = ""
|
|
1343
|
+
if hot_terms:
|
|
1344
|
+
hot_items = "".join(f'<button class="hot-term" type="button">{esc(term)}</button>' for term in hot_terms)
|
|
1345
|
+
hot_html = f'<div class="hot-terms" aria-label="热门搜索词"><span class="hot-label">大家都在搜</span>{hot_items}</div>'
|
|
1346
|
+
|
|
1347
|
+
cards_html = "".join(render_source_card(s) for s in used_sources)
|
|
1348
|
+
cards_html += "".join(render_source_card(s) for s in unused_sources)
|
|
1349
|
+
|
|
1350
|
+
cited_verified = sum(1 for s in used_sources if s.get("verified"))
|
|
1351
|
+
badge = "全部已核验" if used_sources and cited_verified == len(used_sources) else f"{cited_verified}/{len(used_sources)} 已核验"
|
|
1352
|
+
return f"""
|
|
1353
|
+
<section class="view" id="view-library" aria-label="知识专库">
|
|
1354
|
+
<div class="lib-head">
|
|
1355
|
+
<div class="lib-title"><b>知识专库</b>
|
|
1356
|
+
<span>共 {len(sources)} 条 · 已引用 {len(used_sources)} · {esc(badge)}</span>
|
|
1357
|
+
</div>
|
|
1358
|
+
<div class="lib-searchWrap">
|
|
1359
|
+
<span class="lib-searchIcon" aria-hidden="true">⌕</span>
|
|
1360
|
+
<input class="lib-search" type="search" placeholder="搜索标题 / 来源 / 摘录…" aria-label="搜索来源文章">
|
|
1361
|
+
</div>
|
|
1362
|
+
{hot_html}
|
|
1363
|
+
<div class="lib-tabs" role="tablist" aria-label="按检索分组筛选">{"".join(tabs)}</div>
|
|
1364
|
+
</div>
|
|
1365
|
+
<div class="lib-list" id="lib-list">{cards_html}</div>
|
|
1366
|
+
<div class="lib-empty hide" id="lib-empty">没有符合当前筛选的来源文章。</div>
|
|
1367
|
+
<div class="lib-foot">材料来源:深知可信搜索 · 每条摘录均取自原文原段</div>
|
|
1368
|
+
</section>"""
|
|
1369
|
+
|
|
1370
|
+
|
|
1371
|
+
def render_toc(sections: List[Dict[str, Any]]) -> str:
|
|
1372
|
+
"""章节目录(滚动 spy):长报告(≥6 个有标题的章节)显示,桌面端左侧浮动。"""
|
|
1373
|
+
items = []
|
|
1374
|
+
for i, sec in enumerate(sections, 1):
|
|
1375
|
+
title = (sec.get("title") or "").strip()
|
|
1376
|
+
if not title:
|
|
1377
|
+
# 无标题节=正文开头的导语/摘要段(第一个章节标题之前的内容),不是正式章节。
|
|
1378
|
+
# 此前会被兜底成「第 N 节」列进目录(一条读者看不懂的灰色占位项),且该节
|
|
1379
|
+
# 不生成 <section id="sec-i">、锚点根本不存在,点了没反应=死链。内容仍照常
|
|
1380
|
+
# 在正文里展示,只是不占目录条目、不参与滚动高亮。
|
|
1381
|
+
continue
|
|
1382
|
+
number, title_text = split_heading_number(title)
|
|
1383
|
+
label = f"{number} {title_text}" if (number and title_text) else title_text
|
|
1384
|
+
items.append(f'<a href="#sec-{i}">{esc(short(label, 16))}</a>')
|
|
1385
|
+
if len(items) < 6:
|
|
1386
|
+
return ""
|
|
1387
|
+
return f'<nav class="toc" aria-label="章节目录">{"".join(items)}</nav>'
|
|
1032
1388
|
|
|
1033
1389
|
|
|
1034
|
-
def
|
|
1035
|
-
|
|
1390
|
+
def render_print_appendix(sources: List[Dict[str, str]]) -> str:
|
|
1391
|
+
"""打印归档附录:全部材料卡全展开(屏幕不显示,仅打印)。"""
|
|
1392
|
+
if not sources:
|
|
1036
1393
|
return ""
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1394
|
+
cards = "".join(render_source_card(s, for_print=True) for s in sources)
|
|
1395
|
+
return (f'<section class="print-appendix" aria-label="来源文章附录(打印归档)">'
|
|
1396
|
+
f'<h3>来源文章(全 {len(sources)} 篇)</h3>{cards}</section>')
|
|
1397
|
+
|
|
1398
|
+
|
|
1399
|
+
def _next_version_path(path: Path) -> Path:
|
|
1400
|
+
"""输出文件已存在时不覆盖:自动改为 原名_v2 / _v3 … 另存。
|
|
1401
|
+
|
|
1402
|
+
追加修改后重跑渲染时,旧版本保留、新版本号递增——不覆盖已交付内容,
|
|
1403
|
+
也不会再靠宿主目录里的 "名字 (2)" 兜底。命名与 deliver_outputs.py 的重名规则一致。
|
|
1404
|
+
"""
|
|
1405
|
+
if not path.exists():
|
|
1406
|
+
return path
|
|
1407
|
+
for index in range(2, 100):
|
|
1408
|
+
candidate = path.with_name(f"{path.stem}_v{index}{path.suffix}")
|
|
1409
|
+
if not candidate.exists():
|
|
1410
|
+
print(f"提示:{path.name} 已存在,本次输出改为 {candidate.name}(不覆盖旧版)。")
|
|
1411
|
+
return candidate
|
|
1412
|
+
raise SystemExit(f"错误:{path.name} 的版本号 _v2~_v99 均已占用,请清理 {path.parent} 后重试。")
|
|
1052
1413
|
|
|
1053
1414
|
|
|
1054
1415
|
def safe_output_filename(question: str, timestamp: datetime, fallback: str = "dknowc_search_trace", suffix_ext: str = ".html") -> str:
|
|
@@ -1063,6 +1424,811 @@ def safe_output_filename(question: str, timestamp: datetime, fallback: str = "dk
|
|
|
1063
1424
|
return f"{stem}_{suffix}{suffix_ext}"
|
|
1064
1425
|
|
|
1065
1426
|
|
|
1427
|
+
# ============================================================
|
|
1428
|
+
# 链接活性检测与快照兜底(生成时真实检测,就地改写材料 dict)
|
|
1429
|
+
# ============================================================
|
|
1430
|
+
|
|
1431
|
+
# 软 404 关键词:政府站常以 HTTP 200 返回"页面不存在"错误页,状态码识别不了,
|
|
1432
|
+
# 需读页面标题嗅探。关键词取自实测样例,且仅匹配 <title>(政策正文不会出现在标题里),
|
|
1433
|
+
# 误杀风险极低。
|
|
1434
|
+
SOFT_404_KEYWORDS = ("页面不存在", "页面未找到", "您访问的页面", "已删除", "已下线", "无法找到", "not found", "404")
|
|
1435
|
+
|
|
1436
|
+
|
|
1437
|
+
def check_link_alive(url: str, timeout: int = 8) -> bool:
|
|
1438
|
+
"""检测原文链接是否仍然可达。失效判据(客观信号,与请求方无关):
|
|
1439
|
+
① HTTP 404/410;② 软 404——HTTP 200 但页面标题为典型失效页。
|
|
1440
|
+
连接失败、超时、403、5xx 等一律视为"无法确认"按有效处理——政府站
|
|
1441
|
+
常对脚本请求反爬,凭这些判死会误杀可用链接。
|
|
1442
|
+
"""
|
|
1443
|
+
for method in ("HEAD", "GET"):
|
|
1444
|
+
try:
|
|
1445
|
+
req = urllib.request.Request(
|
|
1446
|
+
url, method=method,
|
|
1447
|
+
headers={"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"},
|
|
1448
|
+
)
|
|
1449
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
1450
|
+
if resp.status in (404, 410):
|
|
1451
|
+
return False
|
|
1452
|
+
if method == "GET":
|
|
1453
|
+
chunk = resp.read(4096).decode("utf-8", errors="replace")
|
|
1454
|
+
title = re.search(r"<title>(.*?)</title>", chunk, re.I | re.S)
|
|
1455
|
+
text = title.group(1) if title else chunk[:200]
|
|
1456
|
+
lowered = text.lower()
|
|
1457
|
+
return not any(k in text or k in lowered for k in SOFT_404_KEYWORDS)
|
|
1458
|
+
except urllib.error.HTTPError as e:
|
|
1459
|
+
if method == "GET":
|
|
1460
|
+
return e.code not in (404, 410)
|
|
1461
|
+
except Exception:
|
|
1462
|
+
if method == "GET":
|
|
1463
|
+
return True
|
|
1464
|
+
return True
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
def normalize_snapshot_url(url: str) -> str:
|
|
1468
|
+
"""快照路径容错:接口部分返回值缺 /A/ 层级(实测拼接 bug),统一规范化为
|
|
1469
|
+
https://attach.dknowc.cn/snapshot/A/<2位>/<2位>/<哈希>.jpg。"""
|
|
1470
|
+
u = (url or "").strip()
|
|
1471
|
+
if u.startswith("https://attach.dknowc.cn/snapshot/") and "/snapshot/A/" not in u:
|
|
1472
|
+
return u.replace("/snapshot/", "/snapshot/A/", 1)
|
|
1473
|
+
return u
|
|
1474
|
+
|
|
1475
|
+
|
|
1476
|
+
def mark_dead_links(articles: List[Dict[str, Any]]) -> int:
|
|
1477
|
+
"""并发检测全部材料的原文链接,404/410(含软 404)的标记 链接失效=True。返回失效数。"""
|
|
1478
|
+
targets = [(i, a) for i, a in enumerate(articles) if (first_str(a.get("源网址"), a.get("sourceUrl"), a.get("source_url"), a.get("原文链接"), a.get("url")) or "").strip()]
|
|
1479
|
+
if not targets:
|
|
1480
|
+
return 0
|
|
1481
|
+
urls = [first_str(a.get("源网址"), a.get("sourceUrl"), a.get("source_url"), a.get("原文链接"), a.get("url")) for _, a in targets]
|
|
1482
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool:
|
|
1483
|
+
alive = dict(zip((i for i, _ in targets), pool.map(check_link_alive, urls)))
|
|
1484
|
+
dead = 0
|
|
1485
|
+
for i, _ in targets:
|
|
1486
|
+
if not alive.get(i, True):
|
|
1487
|
+
articles[i]["链接失效"] = True
|
|
1488
|
+
dead += 1
|
|
1489
|
+
return dead
|
|
1490
|
+
|
|
1491
|
+
|
|
1492
|
+
def apply_snapshots(articles: List[Dict[str, Any]]) -> Tuple[int, int]:
|
|
1493
|
+
"""快照兜底预处理:路径补全(/A/ 层级)+ 纯本地格式校验,非法路径弃用。
|
|
1494
|
+
|
|
1495
|
+
不做网络可达检测:attach 前置雷池 WAF 的拦截与请求方 IP 风控相关
|
|
1496
|
+
(检测机高频请求会被拦而普通用户正常),可达性实测会误杀好快照;
|
|
1497
|
+
快照文件本身的存在性由可信搜索侧的数据质量保障。
|
|
1498
|
+
"""
|
|
1499
|
+
fixed = dropped = 0
|
|
1500
|
+
for a in articles:
|
|
1501
|
+
raw = first_str(a.get("快照链接"), a.get("snapshot"), a.get("screenShotPath"), a.get("screenshot_path"))
|
|
1502
|
+
if not raw:
|
|
1503
|
+
continue
|
|
1504
|
+
normalized = normalize_snapshot_url(raw)
|
|
1505
|
+
if normalized != raw:
|
|
1506
|
+
fixed += 1
|
|
1507
|
+
if normalized.startswith("https://attach.dknowc.cn/snapshot/A/"):
|
|
1508
|
+
a["快照链接"] = normalized
|
|
1509
|
+
else:
|
|
1510
|
+
a["快照链接"] = ""
|
|
1511
|
+
dropped += 1
|
|
1512
|
+
return fixed, dropped
|
|
1513
|
+
# ============================================================
|
|
1514
|
+
# 样式与脚本(独立常量,避免模板转义)
|
|
1515
|
+
# ============================================================
|
|
1516
|
+
|
|
1517
|
+
PAGE_CSS = """
|
|
1518
|
+
:root{
|
|
1519
|
+
--navy:#20242c; --navy-2:#3a4152;
|
|
1520
|
+
--ink:#1f2328; --muted:#6b7280; --line:#e5e7eb; --line-strong:#cbd2dd;
|
|
1521
|
+
--brand:#6512ad; --brand-2:#8b5cf6; --brand-soft:#ede9fe;
|
|
1522
|
+
--grad:linear-gradient(135deg,#6512ad,#8b5cf6);
|
|
1523
|
+
--policy:#0f9d6e; --policy-soft:#e3f5ee;
|
|
1524
|
+
--case:#9a6700; --case-soft:#fdf3dc;
|
|
1525
|
+
--ref:#4b5563; --ref-soft:#f0f1f4;
|
|
1526
|
+
--warn:#9a6700; --danger:#e5484d; --ok:#0f9d6e;
|
|
1527
|
+
--shadow-1:0 1px 3px rgba(24,20,40,.04),0 8px 30px rgba(24,20,40,.08);
|
|
1528
|
+
--shadow-2:0 3px 9px rgba(101,18,173,.22),0 14px 36px rgba(24,20,40,.14);
|
|
1529
|
+
--primary-bright:#8b5cf6; --tint:#f3edfc; --tint-2:#faf7ff; --tint-bd:#e9dff9;
|
|
1530
|
+
--tint-strong:#e6d9f9; --tint-bd-strong:#d3bef0; --body-c:#3b4152; --card-bd:#e8e6f0;
|
|
1531
|
+
}
|
|
1532
|
+
*{box-sizing:border-box}
|
|
1533
|
+
html{scroll-behavior:smooth}
|
|
1534
|
+
body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,"PingFang SC","HarmonyOS Sans SC","Microsoft YaHei",sans-serif;
|
|
1535
|
+
color:var(--ink);background:#f4f5f7;line-height:1.75;font-size:14.5px}
|
|
1536
|
+
a{color:var(--brand)}
|
|
1537
|
+
|
|
1538
|
+
/* ===== 顶栏 ===== */
|
|
1539
|
+
.topbar{position:sticky;top:0;z-index:50;display:flex;justify-content:space-between;align-items:center;gap:10px;
|
|
1540
|
+
padding:9px 22px;background:rgba(255,255,255,.92);backdrop-filter:blur(10px);
|
|
1541
|
+
border-bottom:1px solid var(--line)}
|
|
1542
|
+
.tb-left{display:flex;align-items:center;gap:10px;min-width:0}
|
|
1543
|
+
.tb-stamp{flex:none;font-size:12.5px;font-weight:800;color:var(--navy);letter-spacing:4px;text-indent:4px}
|
|
1544
|
+
.tb-stamp::before,.tb-stamp::after{content:"";display:inline-block;width:22px;border-top:1px solid var(--line-strong);
|
|
1545
|
+
vertical-align:middle;margin:0 6px}
|
|
1546
|
+
.tb-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:13px}
|
|
1547
|
+
.tb-right{display:flex;align-items:center;gap:8px;flex:none}
|
|
1548
|
+
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:999px;overflow:hidden;background:#fff}
|
|
1549
|
+
.view-switch button{border:0;background:transparent;color:var(--muted);font-size:12.5px;font-weight:700;
|
|
1550
|
+
padding:5px 14px;cursor:pointer}
|
|
1551
|
+
.view-switch button.on{background:var(--grad);color:#fff}
|
|
1552
|
+
.tb-tools{display:flex;gap:6px}
|
|
1553
|
+
.tb-tools button{border:1px solid var(--line);border-radius:8px;background:#fff;color:#3b3550;
|
|
1554
|
+
font-size:12.5px;font-weight:700;padding:5px 11px;cursor:pointer}
|
|
1555
|
+
.tb-tools button:hover{border-color:var(--brand-2);color:var(--brand)}
|
|
1556
|
+
.tb-tools button[aria-pressed="true"]{background:var(--grad);border-color:var(--brand);color:#fff}
|
|
1557
|
+
.print-menu{position:relative;display:inline-flex}
|
|
1558
|
+
.print-drop{position:absolute;top:calc(100% + 6px);right:0;z-index:70;display:flex;flex-direction:column;gap:4px;
|
|
1559
|
+
min-width:190px;padding:6px;background:#fff;border:1px solid var(--tint-bd);border-radius:10px;
|
|
1560
|
+
box-shadow:var(--shadow-2);text-align:left}
|
|
1561
|
+
.print-drop[hidden]{display:none}
|
|
1562
|
+
.print-drop button{border:0;background:none;border-radius:7px;color:var(--ink);font-size:12.5px;font-weight:600;
|
|
1563
|
+
padding:8px 12px;cursor:pointer;text-align:left;font-family:inherit;white-space:nowrap}
|
|
1564
|
+
.print-drop button:hover{background:var(--tint);color:var(--brand)}
|
|
1565
|
+
.progress{position:absolute;left:0;right:0;bottom:-1px;height:2px;background:transparent}
|
|
1566
|
+
.progress i{display:block;height:100%;width:0;background:linear-gradient(90deg,#6512ad,#8b5cf6)}
|
|
1567
|
+
|
|
1568
|
+
/* ===== Hero ===== */
|
|
1569
|
+
.hero{position:relative;background:linear-gradient(180deg,#fbfaff 0%,#f7f4fd 100%);
|
|
1570
|
+
color:var(--ink);padding:32px 22px 58px;text-align:center;border-bottom:1px solid var(--line)}
|
|
1571
|
+
.r-badge{display:inline-flex;align-items:center;gap:14px;margin:0 0 8px;
|
|
1572
|
+
background:var(--grad);color:#fff;border-radius:999px;padding:4px 22px;
|
|
1573
|
+
font-size:15px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.6;
|
|
1574
|
+
box-shadow:0 2px 8px rgba(101,18,173,.22)}
|
|
1575
|
+
.hero h1{margin:0 0 10px;font-size:24px;line-height:1.5;max-width:860px;margin-left:auto;margin-right:auto;color:var(--ink)}
|
|
1576
|
+
.hero .meta{color:var(--muted);font-size:13px;letter-spacing:.5px}
|
|
1577
|
+
.hero-switch{margin-top:16px;display:flex;justify-content:center}
|
|
1578
|
+
.hero-switch .view-switch{border-color:#d9c9f4;background:#fff;box-shadow:0 1px 3px rgba(24,20,40,.04)}
|
|
1579
|
+
.hero-switch .view-switch button{color:#70678a;padding:6px 22px;font-size:13px}
|
|
1580
|
+
.hero-switch .view-switch button.on{background:var(--grad);color:#fff}
|
|
1581
|
+
|
|
1582
|
+
/* ===== 容器与视图 ===== */
|
|
1583
|
+
.container{max-width:1080px;margin:0 auto;padding:0 18px}
|
|
1584
|
+
.app[data-view="library"] #view-report{display:none}
|
|
1585
|
+
/* 专库视图下隐藏章节目录(toc 渲染在 .app 之外,视图切换只驱动 .app[data-view],
|
|
1586
|
+
此前切到专库后目录仍挂在左侧;兄弟选择器为主、括号内写法兼容目录日后移入 .app 内) */
|
|
1587
|
+
.app[data-view="library"] ~ .toc,.app[data-view="library"] .toc{display:none}
|
|
1588
|
+
#view-library{display:none}
|
|
1589
|
+
.app[data-view="library"] #view-library{display:block}
|
|
1590
|
+
|
|
1591
|
+
/* ===== 过程回顾条 ===== */
|
|
1592
|
+
.process{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow-1);
|
|
1593
|
+
padding:15px 20px 13px;margin:-36px auto 16px;position:relative}
|
|
1594
|
+
.p-head{display:flex;align-items:baseline;gap:10px;margin-bottom:10px}
|
|
1595
|
+
.p-head b{font-size:14.5px;color:var(--navy);letter-spacing:1px}
|
|
1596
|
+
.p-head span{font-size:11.5px;color:var(--muted)}
|
|
1597
|
+
.p-steps{list-style:none;display:flex;align-items:stretch;gap:8px;margin:0;padding:0;flex-wrap:wrap}
|
|
1598
|
+
.p-step{display:flex;gap:9px;align-items:center;min-width:0;flex:1 1 150px;
|
|
1599
|
+
border:1px solid var(--line);border-radius:10px;padding:8px 11px;background:#fafbfc}
|
|
1600
|
+
.p-no{flex:none;width:24px;height:24px;border-radius:50%;background:var(--grad);color:#fff;
|
|
1601
|
+
display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:800}
|
|
1602
|
+
.p-txt{min-width:0}
|
|
1603
|
+
.p-txt b{display:block;font-size:12.8px;color:var(--navy);line-height:1.5}
|
|
1604
|
+
.p-txt i{display:block;font-style:normal;font-size:11px;color:var(--muted);line-height:1.5;
|
|
1605
|
+
overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1606
|
+
.p-step.done{border-color:#bfe8da;background:#f2faf7}
|
|
1607
|
+
.p-step.done .p-no{background:var(--ok)}
|
|
1608
|
+
.p-step.bad{border-color:#f6c9cb;background:#fffafa}
|
|
1609
|
+
.p-step.bad .p-no{background:var(--danger)}
|
|
1610
|
+
.p-step.expandable{cursor:pointer}
|
|
1611
|
+
.p-step.expandable:hover{border-color:var(--brand)}
|
|
1612
|
+
.p-arrow{align-self:center;color:#b9c6d9;font-size:16px;font-weight:700;flex:none}
|
|
1613
|
+
.p-detail{display:none;margin-top:10px;border-top:1px dashed var(--line-strong);padding-top:9px}
|
|
1614
|
+
.p-detail.show{display:block}
|
|
1615
|
+
.pd-row{display:flex;justify-content:space-between;gap:14px;padding:3px 2px;font-size:12.3px;flex-wrap:wrap}
|
|
1616
|
+
.pd-row b{color:var(--navy);font-weight:700;min-width:0}
|
|
1617
|
+
.pd-row span{color:var(--muted)}
|
|
1618
|
+
|
|
1619
|
+
/* ===== 核验报告视图 ===== */
|
|
1620
|
+
#view-report{padding-bottom:26px}
|
|
1621
|
+
.warn-box{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1622
|
+
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}
|
|
1623
|
+
.verify{margin:0 0 16px;background:#fff;border:1px solid #bfe8da;border-left:4px solid var(--ok);
|
|
1624
|
+
border-radius:14px;padding:16px 20px;box-shadow:var(--shadow-1)}
|
|
1625
|
+
.verify.fail{border-color:#f6c9cb;border-left-color:var(--danger);background:#fffafa}
|
|
1626
|
+
.v-head{display:flex;align-items:center;gap:9px;font-size:15px;font-weight:800;color:var(--ok)}
|
|
1627
|
+
.verify.fail .v-head{color:var(--danger)}
|
|
1628
|
+
.v-shield{display:inline-flex;width:22px;height:22px;border-radius:50%;background:var(--ok);color:#fff;
|
|
1629
|
+
align-items:center;justify-content:center;font-size:12px;flex:none}
|
|
1630
|
+
.verify.fail .v-shield{background:var(--danger)}
|
|
1631
|
+
.v-stamp{margin-left:auto;font-size:11px;border:1.5px solid var(--ok);color:var(--ok);border-radius:5px;
|
|
1632
|
+
padding:1px 8px;letter-spacing:2px;flex:none}
|
|
1633
|
+
.v-stamp.bad{border-color:var(--danger);color:var(--danger)}
|
|
1634
|
+
.v-reasons{margin-top:6px;font-size:12.5px;color:var(--danger)}
|
|
1635
|
+
.v-grid{display:grid;grid-template-columns:1fr 1fr;gap:4px 20px;margin-top:10px}
|
|
1636
|
+
.vi{display:flex;gap:7px;align-items:baseline;font-size:12.5px;color:#3b3550;line-height:1.7;min-width:0}
|
|
1637
|
+
.vi .s{font-weight:800;flex:none}
|
|
1638
|
+
.vi .s.ok{color:var(--ok)}
|
|
1639
|
+
.vi .s.warn{color:var(--warn)}
|
|
1640
|
+
.vi .s.fail{color:var(--danger)}
|
|
1641
|
+
.vi .s.man{color:var(--case)}
|
|
1642
|
+
.vi .s.none{color:var(--muted)}
|
|
1643
|
+
.vi .d{color:var(--muted);min-width:0}
|
|
1644
|
+
.v-note{margin-top:11px;padding-top:9px;border-top:1px dashed var(--line);font-size:11.5px;color:var(--muted);line-height:1.7}
|
|
1645
|
+
|
|
1646
|
+
/* 正文(原型复刻):章节 / 段落 / 角标 / 句后引文胶囊 */
|
|
1647
|
+
.doc-paper{background:#fff;border-radius:14px;box-shadow:var(--shadow-1);padding:26px 34px 22px;margin:0 0 16px}
|
|
1648
|
+
.chapter{margin:40px 0 0}
|
|
1649
|
+
.chapter:first-child{margin-top:6px}
|
|
1650
|
+
.ch-head{display:flex;align-items:center;gap:14px;margin-bottom:18px;scroll-margin-top:86px}
|
|
1651
|
+
.ch-head h2{font-size:19.5px;font-weight:700;color:var(--ink);letter-spacing:.2px;line-height:1.4;flex:1;min-width:0}
|
|
1652
|
+
.ch-head::after{content:"";flex-basis:110px;height:1px;background:linear-gradient(90deg,#e9dff9,transparent);order:3;flex-grow:0;flex-shrink:0}
|
|
1653
|
+
.ch-head .sec-badge{order:4;flex:none;font-size:11.5px;color:var(--ok);background:var(--policy-soft);border-radius:6px;padding:2px 9px;font-weight:700}
|
|
1654
|
+
.ch-head .sec-badge.bad{color:var(--danger);background:#fdecec}
|
|
1655
|
+
@media(min-width:1000px){.ch-head::after{flex-basis:200px}}
|
|
1656
|
+
.lead{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1657
|
+
.para{font-size:15.5px;line-height:1.95;color:var(--body-c);margin:14px 0;padding:0 2px;word-break:break-word}
|
|
1658
|
+
.para b.kw,.lead b.kw{font-weight:600;color:var(--ink)}
|
|
1659
|
+
.doc-divider{border:0;border-top:1px solid var(--line);margin:18px 0}
|
|
1660
|
+
code{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#3f3d52;
|
|
1661
|
+
font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}
|
|
1662
|
+
.tbl-wrap{max-width:100%;overflow-x:auto;margin:8px 0}
|
|
1663
|
+
.data-tbl{width:100%;border-collapse:collapse;border:1px solid var(--line);font-size:13px}
|
|
1664
|
+
.data-tbl th,.data-tbl td{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top;line-height:1.65}
|
|
1665
|
+
.data-tbl th{background:#f5f6f8;font-weight:700;color:#3f3d52}
|
|
1666
|
+
.data-tbl.wide{min-width:560px}
|
|
1667
|
+
|
|
1668
|
+
/* 角标 */
|
|
1669
|
+
.cite{display:inline-flex;align-items:center;justify-content:center;min-width:19px;height:18px;padding:0 5px;margin:0 2px 2px 3px;font-size:10.5px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--brand);background:var(--tint);border:1px solid var(--tint-bd);border-radius:5px;cursor:pointer;vertical-align:super;line-height:1;transition:.14s;position:relative;top:-1px;user-select:none;font-family:inherit}
|
|
1670
|
+
.cite:hover{background:var(--brand);border-color:var(--brand);color:#fff}
|
|
1671
|
+
.cite.flash{background:var(--primary-bright);border-color:var(--primary-bright);color:#fff}
|
|
1672
|
+
.cite.unresolved{color:var(--danger);border-color:#f6c9cb;background:#fdf7f7}
|
|
1673
|
+
|
|
1674
|
+
/* 行内引文 jb(原型复刻):角标后小胶囊,点击展开块级卡(溯源原文+引文摘录) */
|
|
1675
|
+
.jb{display:inline-block;vertical-align:top;max-width:100%;margin:2px 4px 2px 0;position:relative}
|
|
1676
|
+
.jb.active{display:block;margin:12px 0 2px;max-width:none}
|
|
1677
|
+
.jb-name{display:inline-flex;align-items:center;gap:6px;max-width:380px;min-height:26px;padding:4px 13px;border-radius:13px;border:1px solid var(--tint-bd);background:var(--tint);color:#540e8f;font-family:inherit;font-size:12px;font-weight:600;line-height:18px;cursor:pointer;transition:.16s;white-space:nowrap}
|
|
1678
|
+
.jb-name:hover{background:#fff;border-color:var(--brand)}
|
|
1679
|
+
.jb-name .jb-id{flex:none;width:18px;height:18px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-style:normal;font-size:10.5px;font-weight:800;font-variant-numeric:tabular-nums;color:#fff;background:linear-gradient(135deg,#6512ad,#8b5cf6);box-shadow:0 1px 3px rgba(101,18,173,.28)}
|
|
1680
|
+
.jb-name .jb-txt{overflow:hidden;text-overflow:ellipsis}
|
|
1681
|
+
.jb-name svg{flex:none;transition:transform .2s}
|
|
1682
|
+
.jb.active .jb-name{max-width:100%;white-space:normal;line-height:20px;color:var(--ink);background:#fff;font-size:13.5px;font-weight:700;text-align:left}
|
|
1683
|
+
.jb.active .jb-name svg{transform:rotate(180deg)}
|
|
1684
|
+
.jb-src{display:inline-flex;align-items:center;gap:5px;min-height:26px;padding:4px 13px;border-radius:13px;background:linear-gradient(135deg,#6512ad,#8b5cf6);color:#fff;font-size:11px;font-weight:600;text-decoration:none;box-shadow:0 2px 8px rgba(101,18,173,.22);transition:.15s;flex-shrink:0}
|
|
1685
|
+
.jb-src:hover{filter:brightness(1.1)}
|
|
1686
|
+
.jb-src span{max-width:210px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1687
|
+
.jb-body{display:none}
|
|
1688
|
+
.jb.active .jb-body{position:relative;display:block;margin-top:13px;background:#fff;border:1px solid var(--card-bd);border-radius:12px;padding:13px 15px;box-shadow:var(--shadow-1)}
|
|
1689
|
+
.jb-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}
|
|
1690
|
+
.jb-label{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:700;color:var(--brand);letter-spacing:.5px}
|
|
1691
|
+
.jb-label svg{flex:none}
|
|
1692
|
+
.jb-site{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:#70678a;background:#f6f4fa;
|
|
1693
|
+
border:1px solid var(--line);border-radius:999px;padding:3.5px 10px;max-width:100%;overflow:hidden;
|
|
1694
|
+
text-overflow:ellipsis;white-space:nowrap;margin:0 0 2px}
|
|
1695
|
+
.jb-site .dot{width:6px;height:6px;border-radius:50%;background:linear-gradient(135deg,#6512ad,#8b5cf6);flex-shrink:0}
|
|
1696
|
+
.jb-quote{display:flex;gap:9px;align-items:flex-start;margin-top:9px;padding:10px 12px;background:#faf9fd;border:1px solid var(--line);border-radius:9px;text-decoration:none;transition:.15s;cursor:pointer}
|
|
1697
|
+
.jb-quote:hover{border-color:var(--brand);background:#f7f4fc}
|
|
1698
|
+
.jb-no{flex:none;width:17px;height:17px;margin-top:4px;border-radius:4px;background:var(--tint);border:1px solid var(--tint-bd);color:var(--brand);font-size:10px;font-weight:700;font-style:normal;display:flex;align-items:center;justify-content:center}
|
|
1699
|
+
.jb-quote span{font-size:12.5px;line-height:1.95;color:#4b4658;word-break:break-word;text-align:justify}
|
|
1700
|
+
.jb-quote .sc-excerpt{flex:1;min-width:0;display:block}
|
|
1701
|
+
a.jb-quote{text-decoration:none}
|
|
1702
|
+
.jb.flash{animation:cardFlash 1.6s ease}
|
|
1703
|
+
@keyframes cardFlash{0%,100%{box-shadow:none}30%{box-shadow:0 0 0 3px rgba(139,92,246,.45)}}
|
|
1704
|
+
.sc-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}
|
|
1705
|
+
.sc-links span{display:inline-flex}
|
|
1706
|
+
.sc-links a{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:6px;
|
|
1707
|
+
background:var(--brand-soft);color:var(--brand);font-weight:700;text-decoration:none;font-size:12px}
|
|
1708
|
+
|
|
1709
|
+
/* ===== 知识专库视图 ===== */
|
|
1710
|
+
#view-library{padding:26px 0 30px}
|
|
1711
|
+
.lib-head{max-width:860px;margin:0 auto 16px;text-align:center}
|
|
1712
|
+
.lib-title{margin-bottom:14px}
|
|
1713
|
+
.lib-title b{font-size:17px;color:var(--navy);letter-spacing:2px}
|
|
1714
|
+
.lib-title span{display:block;font-size:12px;color:var(--muted);margin-top:2px}
|
|
1715
|
+
.lib-searchWrap{position:relative;max-width:620px;margin:0 auto}
|
|
1716
|
+
.lib-searchIcon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#a6adbd;font-size:16px;font-weight:700}
|
|
1717
|
+
.lib-search{width:100%;padding:11px 16px 11px 38px;border:1.5px solid var(--line-strong);border-radius:999px;
|
|
1718
|
+
font-size:14px;background:#fff;box-shadow:var(--shadow-1);outline:none}
|
|
1719
|
+
.lib-search:focus{border-color:var(--brand-2);box-shadow:0 0 0 3px rgba(139,92,246,.18)}
|
|
1720
|
+
.hot-terms{display:flex;flex-wrap:wrap;justify-content:center;gap:7px;margin-top:12px;align-items:center}
|
|
1721
|
+
.hot-label{font-size:12px;color:var(--muted)}
|
|
1722
|
+
.hot-term{border:0;border-radius:999px;background:var(--brand-soft);color:var(--brand);
|
|
1723
|
+
font-size:12.3px;font-weight:700;padding:3px 13px;cursor:pointer}
|
|
1724
|
+
.hot-term:hover{background:var(--grad);color:#fff}
|
|
1725
|
+
.lib-tabs{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;margin-top:14px}
|
|
1726
|
+
.lib-tabs button{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1727
|
+
padding:4px 13px;font-size:12.3px;cursor:pointer}
|
|
1728
|
+
.lib-tabs button.on{background:var(--grad);border-color:var(--brand);color:#fff;font-weight:700}
|
|
1729
|
+
.lib-list{max-width:860px;margin:0 auto;display:grid;grid-template-columns:1fr;gap:14px}
|
|
1730
|
+
.lib-empty{max-width:860px;margin:30px auto;text-align:center;color:var(--muted);font-size:13.5px}
|
|
1731
|
+
.lib-empty.hide{display:none}
|
|
1732
|
+
.lib-foot{text-align:center;color:var(--muted);font-size:11.5px;padding:18px 0 0;line-height:1.8}
|
|
1733
|
+
|
|
1734
|
+
/* ===== 材料卡 ===== */
|
|
1735
|
+
.scard{border:1px solid var(--line);border-left-width:3px;border-radius:12px;padding:14px 18px;
|
|
1736
|
+
background:#fff;box-shadow:var(--shadow-1);transition:box-shadow .25s}
|
|
1737
|
+
.scard:hover{box-shadow:var(--shadow-2)}
|
|
1738
|
+
.scard.pol{border-left-color:var(--policy)}
|
|
1739
|
+
.scard.dat{border-left-color:var(--brand-2)}
|
|
1740
|
+
.scard.cas{border-left-color:var(--case)}
|
|
1741
|
+
.scard.ref,.scard.mat{border-left-color:var(--ref)}
|
|
1742
|
+
.scard.hl{box-shadow:0 0 0 3px rgba(139,92,246,.35),var(--shadow-2)}
|
|
1743
|
+
.scard.hide{display:none}
|
|
1744
|
+
.sc-head{display:flex;align-items:center;gap:7px;margin-bottom:6px}
|
|
1745
|
+
.sc-id{font-family:monospace;font-weight:800;font-size:11px;color:#fff;background:var(--grad);
|
|
1746
|
+
border-radius:5px;padding:1px 8px}
|
|
1747
|
+
.sc-type{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px;background:var(--ref-soft);color:var(--ref)}
|
|
1748
|
+
.scard.pol .sc-type{background:var(--policy-soft);color:var(--policy)}
|
|
1749
|
+
.scard.dat .sc-type{background:var(--brand-soft);color:var(--brand)}
|
|
1750
|
+
.scard.cas .sc-type{background:var(--case-soft);color:var(--case)}
|
|
1751
|
+
.sc-vk{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}
|
|
1752
|
+
.sc-vk + .sc-vk{margin-left:0}
|
|
1753
|
+
.sc-vk.warn{color:var(--warn)}
|
|
1754
|
+
.sc-unused{font-size:10.5px;font-weight:800;color:var(--muted);background:#efedf4;border-radius:4px;
|
|
1755
|
+
padding:1px 7px;flex:none}
|
|
1756
|
+
.sc-conf{font-size:10.5px;font-weight:800;color:#8a5a00;background:var(--case-soft);border:1px solid #e6cf8f;
|
|
1757
|
+
border-radius:4px;padding:0 7px;flex:none}
|
|
1758
|
+
.scard h4{margin:0 0 5px;font-size:14.5px;color:var(--ink);line-height:1.55}
|
|
1759
|
+
.sc-meta{font-size:11.5px;color:var(--muted)}
|
|
1760
|
+
/* 标题链面包屑(模型生成的结构化位置,核验核心抓手)与多段分块 */
|
|
1761
|
+
.crumb{font-size:11.5px;color:var(--brand);margin:10px 0 4px;font-weight:600;line-height:1.6;
|
|
1762
|
+
padding:3px 9px;background:var(--tint);border-radius:7px;display:inline-block;max-width:100%;
|
|
1763
|
+
overflow-wrap:break-word}
|
|
1764
|
+
.crumb i{font-style:normal;color:#c9b3ec;margin:0 2px;font-weight:400}
|
|
1765
|
+
.seg-block{margin-top:8px}
|
|
1766
|
+
.seg-block:first-child{margin-top:2px}
|
|
1767
|
+
.seg-block .sc-excerpt{margin-top:5px}
|
|
1768
|
+
.sc-vnote{margin-top:5px;font-size:11.3px;color:var(--ok);line-height:1.6}
|
|
1769
|
+
.sc-excerpt{margin:8px 0 0;padding:10px 12px;border:1px solid #eceaf2;border-radius:9px;
|
|
1770
|
+
background:#faf9fd;color:#4a4260;font-size:12.3px;line-height:1.75}
|
|
1771
|
+
.sc-excerpt.rich{overflow-x:auto}
|
|
1772
|
+
.sc-excerpt.rich table{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}
|
|
1773
|
+
.sc-excerpt.rich td,.sc-excerpt.rich th{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
1774
|
+
vertical-align:top;word-break:break-word}
|
|
1775
|
+
.sc-excerpt.rich thead td,.sc-excerpt.rich th{background:#f3f4f6;color:#3f3d52;font-weight:700}
|
|
1776
|
+
.scard .sc-links a{font-size:12px}
|
|
1777
|
+
.scard .sc-links{margin-top:4px}
|
|
1778
|
+
.no-link{font-size:11.5px;color:var(--muted)}
|
|
1779
|
+
.sc-links a.snap{background:#faf5ff;border-color:#d9c9f4;color:#5b21b6}
|
|
1780
|
+
.dead-link{font-size:11.5px;color:var(--warn)}
|
|
1781
|
+
|
|
1782
|
+
/* ===== 章节目录(spy,长报告) ===== */
|
|
1783
|
+
.toc{position:fixed;left:calc((100vw - 1080px)/2 - 168px);top:120px;width:140px;max-height:60vh;overflow:auto;
|
|
1784
|
+
display:flex;flex-direction:column;gap:2px;font-size:12px}
|
|
1785
|
+
.toc a{color:var(--muted);text-decoration:none;padding:4px 10px;border-left:2px solid var(--line);
|
|
1786
|
+
line-height:1.5;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
1787
|
+
.toc a.on{color:var(--brand);border-left-color:var(--brand);font-weight:700}
|
|
1788
|
+
@media (max-width:1460px){.toc{display:none}}
|
|
1789
|
+
|
|
1790
|
+
.foot{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}
|
|
1791
|
+
|
|
1792
|
+
/* ===== 只看正文(纯净阅读态) ===== */
|
|
1793
|
+
body.reading .process,body.reading .verify,body.reading .jb,body.reading .sec-badge,
|
|
1794
|
+
body.reading .cite,body.reading .toc,body.reading .p-detail{display:none!important}
|
|
1795
|
+
|
|
1796
|
+
/* ===== 打印附录 ===== */
|
|
1797
|
+
.print-appendix{display:none}
|
|
1798
|
+
|
|
1799
|
+
/* ===== 移动端 ===== */
|
|
1800
|
+
.sheet-mask{display:none}
|
|
1801
|
+
.sheet{display:none}
|
|
1802
|
+
@media (max-width:680px){
|
|
1803
|
+
body{font-size:14px;line-height:1.8}
|
|
1804
|
+
.topbar{padding:7px 10px;gap:6px}
|
|
1805
|
+
.tb-stamp{font-size:11px;letter-spacing:2px;text-indent:2px}
|
|
1806
|
+
.tb-stamp::before,.tb-stamp::after{width:12px;margin:0 4px}
|
|
1807
|
+
.tb-title{display:none}
|
|
1808
|
+
.topbar .view-switch{display:none}
|
|
1809
|
+
.tb-tools button{font-size:11.5px;padding:4px 8px}
|
|
1810
|
+
.hero{padding:24px 14px 50px}
|
|
1811
|
+
.ch-head{gap:8px;margin-bottom:14px;flex-wrap:nowrap}
|
|
1812
|
+
.ch-head h2{font-size:17px;line-height:1.45}
|
|
1813
|
+
.ch-head::after{display:none}
|
|
1814
|
+
.ch-head .sec-badge{font-size:10.5px;padding:2px 7px;white-space:nowrap}
|
|
1815
|
+
.jb-name{max-width:calc(100vw - 72px)}
|
|
1816
|
+
.r-badge{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}
|
|
1817
|
+
.hero h1{font-size:18.5px}
|
|
1818
|
+
.hero .meta{font-size:11.5px;line-height:1.7}
|
|
1819
|
+
.hero-switch .view-switch button{padding:6px 16px;font-size:12.5px}
|
|
1820
|
+
.process{margin-top:-30px;padding:12px 12px 11px}
|
|
1821
|
+
.p-step{flex:1 1 100%}
|
|
1822
|
+
.p-arrow{display:none}
|
|
1823
|
+
.verify{padding:13px 14px}
|
|
1824
|
+
.v-head{font-size:14px}
|
|
1825
|
+
.v-grid{grid-template-columns:1fr;gap:2px 0}
|
|
1826
|
+
.vi{flex-wrap:wrap;gap:4px 8px}
|
|
1827
|
+
.vi .d{min-width:0}
|
|
1828
|
+
.warn-box{font-size:12.5px;padding:11px 12px}
|
|
1829
|
+
.doc-paper{padding:16px 14px 10px;border-radius:10px}
|
|
1830
|
+
.data-tbl{font-size:12px}
|
|
1831
|
+
.data-tbl th,.data-tbl td{padding:6px 7px;line-height:1.55}
|
|
1832
|
+
.cite{font-size:11px;padding:0 4px}
|
|
1833
|
+
#view-library{padding:18px 0 24px}
|
|
1834
|
+
.lib-search{padding:10px 14px 10px 34px;font-size:13.5px}
|
|
1835
|
+
.lib-tabs{justify-content:flex-start;flex-wrap:nowrap;overflow-x:auto;padding-bottom:4px;
|
|
1836
|
+
-webkit-overflow-scrolling:touch;scrollbar-width:none}
|
|
1837
|
+
.lib-tabs::-webkit-scrollbar{display:none}
|
|
1838
|
+
.lib-tabs button{flex:none}
|
|
1839
|
+
.lib-list{grid-template-columns:1fr;gap:10px}
|
|
1840
|
+
.scard{padding:10px 11px}
|
|
1841
|
+
.crumb{font-size:11px}
|
|
1842
|
+
.sc-excerpt{font-size:11.5px}
|
|
1843
|
+
/* 移动端材料底部弹层:点角标就地弹出材料卡,不跳转打断阅读 */
|
|
1844
|
+
.sheet-mask{display:block;position:fixed;inset:0;background:rgba(11,31,58,.45);z-index:99;opacity:0;
|
|
1845
|
+
pointer-events:none;transition:opacity .2s}
|
|
1846
|
+
.sheet-mask.show{opacity:1;pointer-events:auto}
|
|
1847
|
+
.sheet{display:block;position:fixed;left:0;right:0;bottom:0;z-index:100;background:#fff;
|
|
1848
|
+
border-radius:14px 14px 0 0;box-shadow:0 -8px 30px rgba(11,31,58,.25);
|
|
1849
|
+
max-height:68vh;overflow-y:auto;-webkit-overflow-scrolling:touch;
|
|
1850
|
+
padding:10px 16px 22px;transform:translateY(105%);transition:transform .25s ease}
|
|
1851
|
+
.sheet.show{transform:translateY(0)}
|
|
1852
|
+
.sheet-grab{width:38px;height:4px;border-radius:2px;background:#c9d4e2;margin:2px auto 8px}
|
|
1853
|
+
.sheet-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
|
|
1854
|
+
.sheet-head b{font-size:13.5px;color:var(--navy)}
|
|
1855
|
+
.sheet-close{border:1px solid var(--line);background:#f5f3fa;border-radius:8px;color:#3b4a61;
|
|
1856
|
+
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}
|
|
1857
|
+
.sheet .scard{box-shadow:none;margin-bottom:0}
|
|
1858
|
+
.sheet .sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
1859
|
+
/* 正文表述 ↔ 原文原段 对照区(弹层顶部) */
|
|
1860
|
+
.cmp{margin:0 0 10px;border:1px solid var(--line);border-radius:10px;overflow:hidden}
|
|
1861
|
+
.cmp-tag{font-size:11px;font-weight:800;padding:3px 10px}
|
|
1862
|
+
.cmp-side{padding:9px 12px;font-size:12.8px;line-height:1.7}
|
|
1863
|
+
.cmp-side p{margin:0}
|
|
1864
|
+
.cmp-ai{background:#fbfaff;color:#3f3d52}
|
|
1865
|
+
.cmp-ai .cmp-tag{background:#eef1f6;color:var(--ref)}
|
|
1866
|
+
.cmp-src{background:#f4faf7;color:#2f4a3e;border-top:1px dashed var(--line-strong)}
|
|
1867
|
+
.cmp-src .cmp-tag{background:var(--policy-soft);color:#0b6e4f}
|
|
1868
|
+
.cmp-src .sc-excerpt{display:block;-webkit-line-clamp:unset;background:#fff;cursor:auto;font-size:12px;padding:8px 10px;margin:0}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
/* ===== 打印归档 ===== */
|
|
1872
|
+
@media print{
|
|
1873
|
+
.topbar,.process .p-detail,.hero-switch,.tb-tools,.view-switch,.lib-head,.toc,.sheet,.sheet-mask,
|
|
1874
|
+
.progress{display:none!important}
|
|
1875
|
+
#view-library{display:none!important}
|
|
1876
|
+
#view-report{display:block!important}
|
|
1877
|
+
.app[data-view="library"] #view-report{display:block!important}
|
|
1878
|
+
.hero{background:none;border:0;color:var(--ink);padding:10px 0 4px}
|
|
1879
|
+
.hero .meta{color:var(--muted)}
|
|
1880
|
+
*{-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
1881
|
+
.process{box-shadow:none;margin:6px 0 12px}
|
|
1882
|
+
.verify{border-color:#bbb;box-shadow:none;break-inside:avoid}
|
|
1883
|
+
.doc-paper{box-shadow:none;border-radius:0;padding:0}
|
|
1884
|
+
body{background:#fff;font-size:12.5px}
|
|
1885
|
+
.sc-excerpt{display:block;-webkit-line-clamp:unset;cursor:auto}
|
|
1886
|
+
.scard{break-inside:avoid}
|
|
1887
|
+
.cite{background:none!important;color:#333!important;text-decoration:none!important}
|
|
1888
|
+
.cite::before{content:"["}.cite::after{content:"]"}
|
|
1889
|
+
.jb{display:inline!important}
|
|
1890
|
+
.jb .jb-name{border:0;background:none;padding:0;color:#333;font-weight:600}
|
|
1891
|
+
.jb .jb-name .jb-id{color:#333;background:none;border:1px solid #999;border-radius:3px}
|
|
1892
|
+
.jb .jb-body{display:none!important}
|
|
1893
|
+
.jb.active{break-inside:avoid}
|
|
1894
|
+
.jb.active .jb-body{display:block!important}
|
|
1895
|
+
.jb.active .jb-body .jb-quote{break-inside:avoid}
|
|
1896
|
+
body.reading .verify,body.reading .process,body.reading .ev-row,body.reading .sec-badge,
|
|
1897
|
+
body.reading .cite{display:none!important}
|
|
1898
|
+
.print-appendix{display:block;break-before:page}
|
|
1899
|
+
body.print-body-only .verify,body.print-body-only .process,body.print-body-only .print-appendix,
|
|
1900
|
+
body.print-body-only .jb,body.print-body-only .foot{display:none!important}
|
|
1901
|
+
.print-appendix h3{font-size:15px;color:var(--navy);border-bottom:1px solid #999;padding-bottom:6px;margin:0 0 12px}
|
|
1902
|
+
.print-appendix .scard{margin-bottom:10px}
|
|
1903
|
+
}
|
|
1904
|
+
"""
|
|
1905
|
+
|
|
1906
|
+
PAGE_JS = """
|
|
1907
|
+
(function () {
|
|
1908
|
+
"use strict";
|
|
1909
|
+
function $(sel, root) { return (root || document).querySelector(sel); }
|
|
1910
|
+
function $$(sel, root) { return Array.prototype.slice.call((root || document).querySelectorAll(sel)); }
|
|
1911
|
+
|
|
1912
|
+
var app = $(".app");
|
|
1913
|
+
var isMobile = function () { return window.matchMedia("(max-width:680px)").matches; };
|
|
1914
|
+
|
|
1915
|
+
/* ===== 1. 双视图切换(保存/恢复各自滚动位置) ===== */
|
|
1916
|
+
var savedScroll = { report: 0, library: 0 };
|
|
1917
|
+
function setView(view) {
|
|
1918
|
+
if (!app || app.getAttribute("data-view") === view) return;
|
|
1919
|
+
savedScroll[app.getAttribute("data-view") || "report"] = window.scrollY;
|
|
1920
|
+
app.setAttribute("data-view", view);
|
|
1921
|
+
$$(".view-switch button").forEach(function (b) {
|
|
1922
|
+
b.classList.toggle("on", b.getAttribute("data-view") === view);
|
|
1923
|
+
});
|
|
1924
|
+
window.scrollTo(0, Math.max(0, savedScroll[view] || 0));
|
|
1925
|
+
}
|
|
1926
|
+
$$(".view-switch button").forEach(function (b) {
|
|
1927
|
+
b.addEventListener("click", function () { setView(b.getAttribute("data-view")); });
|
|
1928
|
+
});
|
|
1929
|
+
|
|
1930
|
+
/* ===== 2. 阅读进度条 ===== */
|
|
1931
|
+
var progress = $(".progress i");
|
|
1932
|
+
function updateProgress() {
|
|
1933
|
+
if (!progress) return;
|
|
1934
|
+
var h = document.documentElement;
|
|
1935
|
+
var max = h.scrollHeight - h.clientHeight;
|
|
1936
|
+
progress.style.width = (max > 0 ? Math.min(100, (h.scrollTop / max) * 100) : 0) + "%";
|
|
1937
|
+
}
|
|
1938
|
+
window.addEventListener("scroll", updateProgress, { passive: true });
|
|
1939
|
+
updateProgress();
|
|
1940
|
+
|
|
1941
|
+
/* ===== 3. 只看正文(纯净阅读态切换) ===== */
|
|
1942
|
+
var readBtn = $("#btn-reading");
|
|
1943
|
+
if (readBtn) {
|
|
1944
|
+
readBtn.addEventListener("click", function () {
|
|
1945
|
+
var on = document.body.classList.toggle("reading");
|
|
1946
|
+
readBtn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
1947
|
+
readBtn.textContent = on ? "显示核验" : "只看正文";
|
|
1948
|
+
/* 只看正文只作用于核验报告视图:正在知识专库时切回报告,专库不受影响 */
|
|
1949
|
+
if (on && app && app.getAttribute("data-view") !== "report") setView("report");
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/* ===== 4. 复制全文(章节标题 + 段落 + 表格,去角标) ===== */
|
|
1954
|
+
var copyBtn = $("#btn-copy");
|
|
1955
|
+
if (copyBtn) {
|
|
1956
|
+
copyBtn.addEventListener("click", function () {
|
|
1957
|
+
var parts = [];
|
|
1958
|
+
/* 按文档流顺序收集章节标题/段落/表格;克隆后剔除引文胶囊与角标,
|
|
1959
|
+
只复制正文本身(胶囊标题/展开摘录/编号数字均不带出) */
|
|
1960
|
+
var nodes = $$("#view-report .ch-head h2, #view-report .lead, #view-report .para, #view-report .tbl-wrap");
|
|
1961
|
+
nodes.sort(function (a, b) { return (a.compareDocumentPosition(b) & 4) ? -1 : 1; });
|
|
1962
|
+
nodes.forEach(function (el) {
|
|
1963
|
+
var clone = el.cloneNode(true);
|
|
1964
|
+
clone.querySelectorAll(".jb, sup.cite").forEach(function (x) { x.remove(); });
|
|
1965
|
+
var t = clone.textContent.replace(/[ \\t]+/g, " ").trim();
|
|
1966
|
+
if (t) parts.push(t);
|
|
1967
|
+
});
|
|
1968
|
+
var text = parts.filter(Boolean).join("\\n\\n");
|
|
1969
|
+
function done(ok) {
|
|
1970
|
+
var old = copyBtn.textContent;
|
|
1971
|
+
copyBtn.textContent = ok ? "已复制 ✓" : "复制失败";
|
|
1972
|
+
setTimeout(function () { copyBtn.textContent = old; }, 1600);
|
|
1973
|
+
}
|
|
1974
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1975
|
+
navigator.clipboard.writeText(text).then(function () { done(true); }, function () { done(fallback(text)); });
|
|
1976
|
+
} else {
|
|
1977
|
+
done(fallback(text));
|
|
1978
|
+
}
|
|
1979
|
+
function fallback(value) {
|
|
1980
|
+
try {
|
|
1981
|
+
var ta = document.createElement("textarea");
|
|
1982
|
+
ta.value = value;
|
|
1983
|
+
ta.style.position = "fixed";
|
|
1984
|
+
ta.style.opacity = "0";
|
|
1985
|
+
document.body.appendChild(ta);
|
|
1986
|
+
ta.select();
|
|
1987
|
+
var ok = document.execCommand("copy");
|
|
1988
|
+
document.body.removeChild(ta);
|
|
1989
|
+
return ok;
|
|
1990
|
+
} catch (e) { return false; }
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
/* ===== 5. 打印归档(PDF):下拉双选项——只打印正文 / 完整归档 ===== */
|
|
1996
|
+
var printBtn = $("#btn-print");
|
|
1997
|
+
var printDrop = $("#print-drop");
|
|
1998
|
+
function printBy(mode) {
|
|
1999
|
+
if (mode === "body") document.body.classList.add("print-body-only");
|
|
2000
|
+
if (printDrop) printDrop.hidden = true;
|
|
2001
|
+
window.print();
|
|
2002
|
+
}
|
|
2003
|
+
if (printBtn && printDrop) {
|
|
2004
|
+
printBtn.addEventListener("click", function (e) {
|
|
2005
|
+
e.stopPropagation();
|
|
2006
|
+
printDrop.hidden = !printDrop.hidden;
|
|
2007
|
+
});
|
|
2008
|
+
printDrop.addEventListener("click", function (e) {
|
|
2009
|
+
e.stopPropagation();
|
|
2010
|
+
var t = e.target.closest("button");
|
|
2011
|
+
if (!t) return;
|
|
2012
|
+
printBy(t.id === "print-body" ? "body" : "full");
|
|
2013
|
+
});
|
|
2014
|
+
document.addEventListener("click", function () { printDrop.hidden = true; });
|
|
2015
|
+
/* 打印结束移除临时模式(浏览器打印窗口关闭后触发) */
|
|
2016
|
+
window.addEventListener("afterprint", function () { document.body.classList.remove("print-body-only"); });
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
/* ===== 6. 材料卡索引(专库列表内,不含打印附录) ===== */
|
|
2020
|
+
var cards = $$("#lib-list .scard");
|
|
2021
|
+
var byId = {};
|
|
2022
|
+
cards.forEach(function (c) {
|
|
2023
|
+
var id = c.getAttribute("data-cite-id");
|
|
2024
|
+
if (id) byId[id] = c;
|
|
2025
|
+
});
|
|
2026
|
+
|
|
2027
|
+
/* 移动端底部弹层:正文表述 ↔ 原文原段 对照 + 材料卡 */
|
|
2028
|
+
var sheet = $(".sheet");
|
|
2029
|
+
var mask = $(".sheet-mask");
|
|
2030
|
+
function escHtml(s) {
|
|
2031
|
+
var d = document.createElement("div");
|
|
2032
|
+
d.textContent = s;
|
|
2033
|
+
return d.innerHTML;
|
|
2034
|
+
}
|
|
2035
|
+
function sentenceOf(el) {
|
|
2036
|
+
var para = el && el.closest ? el.closest(".para,.lead") : null;
|
|
2037
|
+
return para ? para.innerText.trim() : "";
|
|
2038
|
+
}
|
|
2039
|
+
function openSheet(card, sentence) {
|
|
2040
|
+
if (!sheet) return;
|
|
2041
|
+
var body = sheet.querySelector(".sheet-body");
|
|
2042
|
+
body.innerHTML = "";
|
|
2043
|
+
if (sentence) {
|
|
2044
|
+
var excerpt = card.querySelector(".sc-excerpt");
|
|
2045
|
+
var cmp = document.createElement("div");
|
|
2046
|
+
cmp.className = "cmp";
|
|
2047
|
+
cmp.innerHTML =
|
|
2048
|
+
'<div class="cmp-side cmp-ai"><div class="cmp-tag">正文表述</div><p>' + escHtml(sentence) + '</p></div>' +
|
|
2049
|
+
'<div class="cmp-side cmp-src"><div class="cmp-tag">原文原段</div>' +
|
|
2050
|
+
'<div class="sc-excerpt">' + (excerpt ? excerpt.innerHTML : "") + '</div></div>';
|
|
2051
|
+
body.appendChild(cmp);
|
|
2052
|
+
}
|
|
2053
|
+
var clone = card.cloneNode(true);
|
|
2054
|
+
clone.removeAttribute("id");
|
|
2055
|
+
clone.classList.remove("hide");
|
|
2056
|
+
clone.classList.add("open");
|
|
2057
|
+
body.appendChild(clone);
|
|
2058
|
+
sheet.classList.add("show");
|
|
2059
|
+
mask.classList.add("show");
|
|
2060
|
+
document.body.style.overflow = "hidden";
|
|
2061
|
+
sheet.scrollTop = 0;
|
|
2062
|
+
}
|
|
2063
|
+
function closeSheet() {
|
|
2064
|
+
if (!sheet) return;
|
|
2065
|
+
sheet.classList.remove("show");
|
|
2066
|
+
mask.classList.remove("show");
|
|
2067
|
+
document.body.style.overflow = "";
|
|
2068
|
+
}
|
|
2069
|
+
if (sheet && mask) {
|
|
2070
|
+
mask.addEventListener("click", closeSheet);
|
|
2071
|
+
var closeBtn = sheet.querySelector(".sheet-close");
|
|
2072
|
+
if (closeBtn) closeBtn.addEventListener("click", closeSheet);
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
/* 行内引文 jb(原型行为):点小胶囊 toggle 展开卡;展开卡内引文条目点击进专库。
|
|
2076
|
+
未绑定角标红色警示,绝不按位置猜测。 */
|
|
2077
|
+
var JB_TABLES = {};
|
|
2078
|
+
try {
|
|
2079
|
+
var jbTablesEl = document.getElementById("jb-tables");
|
|
2080
|
+
if (jbTablesEl) JB_TABLES = JSON.parse(jbTablesEl.textContent || "{}");
|
|
2081
|
+
} catch (e) { JB_TABLES = {}; }
|
|
2082
|
+
function fillTableHolders(jb) {
|
|
2083
|
+
jb.querySelectorAll(".tbl-holder[data-tbl]").forEach(function (h) {
|
|
2084
|
+
if (h.getAttribute("data-filled")) return;
|
|
2085
|
+
var html = JB_TABLES[h.getAttribute("data-tbl")];
|
|
2086
|
+
if (html) h.innerHTML = html;
|
|
2087
|
+
h.setAttribute("data-filled", "1");
|
|
2088
|
+
});
|
|
2089
|
+
}
|
|
2090
|
+
function toggleJb(jb, forceOpen) {
|
|
2091
|
+
var open = forceOpen === true ? true : !jb.classList.contains("active");
|
|
2092
|
+
document.querySelectorAll(".jb.active").forEach(function (x) { if (x !== jb) x.classList.remove("active"); });
|
|
2093
|
+
jb.classList.toggle("active", open);
|
|
2094
|
+
if (open) fillTableHolders(jb);
|
|
2095
|
+
var name = jb.querySelector(".jb-name");
|
|
2096
|
+
if (name) name.setAttribute("aria-expanded", open ? "true" : "false");
|
|
2097
|
+
return open;
|
|
2098
|
+
}
|
|
2099
|
+
document.querySelectorAll(".jb-name").forEach(function (name) {
|
|
2100
|
+
name.addEventListener("click", function () { toggleJb(name.closest(".jb")); });
|
|
2101
|
+
});
|
|
2102
|
+
|
|
2103
|
+
/* 引文条目点击 → 知识专库定位对应卡:库内导航看完整材料;
|
|
2104
|
+
外部原文跳转只保留 jb-head 的"查看全文"按钮,动线分离 */
|
|
2105
|
+
function jumpToLibrary(id) {
|
|
2106
|
+
var card = byId[id];
|
|
2107
|
+
if (!card) return;
|
|
2108
|
+
setView("library");
|
|
2109
|
+
card.classList.remove("hide", "open");
|
|
2110
|
+
card.classList.add("hl", "open");
|
|
2111
|
+
requestAnimationFrame(function () {
|
|
2112
|
+
requestAnimationFrame(function () { card.scrollIntoView({ block: "center", behavior: "smooth" }); });
|
|
2113
|
+
});
|
|
2114
|
+
setTimeout(function () { card.classList.remove("hl"); }, 2200);
|
|
2115
|
+
}
|
|
2116
|
+
document.querySelectorAll(".jb-quote").forEach(function (q) {
|
|
2117
|
+
function go() {
|
|
2118
|
+
var jbEl = q.closest(".jb");
|
|
2119
|
+
var id = jbEl && jbEl.getAttribute("data-cite");
|
|
2120
|
+
if (isMobile()) {
|
|
2121
|
+
/* 移动端不跳视图(跳转会打断阅读),就地展开/收起当前 jb */
|
|
2122
|
+
var card = id && byId[id];
|
|
2123
|
+
if (card) { openSheet(card, sentenceOf(q)); return; }
|
|
2124
|
+
}
|
|
2125
|
+
if (id) jumpToLibrary(id);
|
|
2126
|
+
}
|
|
2127
|
+
q.addEventListener("click", go);
|
|
2128
|
+
q.addEventListener("keydown", function (e) {
|
|
2129
|
+
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); go(); }
|
|
2130
|
+
});
|
|
2131
|
+
});
|
|
2132
|
+
document.querySelectorAll("sup.cite").forEach(function (btn) {
|
|
2133
|
+
/* 仅剩未绑定角标(红色数字)走到这里:点击控制台留痕 */
|
|
2134
|
+
btn.addEventListener("click", function () {
|
|
2135
|
+
if (console.error) console.error("[核验] 未绑定角标:", btn.getAttribute("data-cite"));
|
|
2136
|
+
});
|
|
2137
|
+
});
|
|
2138
|
+
|
|
2139
|
+
/* ===== 7. 知识专库:tabs + 搜索 + 热词 ===== */
|
|
2140
|
+
var cond = "";
|
|
2141
|
+
var kw = "";
|
|
2142
|
+
function applyFilter() {
|
|
2143
|
+
var visible = 0;
|
|
2144
|
+
cards.forEach(function (c) {
|
|
2145
|
+
var okCond = !cond;
|
|
2146
|
+
if (cond === "__unused__") okCond = c.getAttribute("data-unused") === "1";
|
|
2147
|
+
else if (cond) okCond = c.getAttribute("data-search") === cond;
|
|
2148
|
+
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
2149
|
+
var show = okCond && okKw;
|
|
2150
|
+
c.classList.toggle("hide", !show);
|
|
2151
|
+
if (show) visible++;
|
|
2152
|
+
});
|
|
2153
|
+
var empty = $("#lib-empty");
|
|
2154
|
+
if (empty) empty.classList.toggle("hide", visible !== 0);
|
|
2155
|
+
}
|
|
2156
|
+
$$(".lib-tabs button").forEach(function (b) {
|
|
2157
|
+
b.addEventListener("click", function () {
|
|
2158
|
+
$$(".lib-tabs button").forEach(function (x) { x.classList.remove("on"); });
|
|
2159
|
+
b.classList.add("on");
|
|
2160
|
+
cond = b.getAttribute("data-cond") || "";
|
|
2161
|
+
applyFilter();
|
|
2162
|
+
});
|
|
2163
|
+
});
|
|
2164
|
+
var search = $(".lib-search");
|
|
2165
|
+
if (search) search.addEventListener("input", function () { kw = search.value.trim().toLowerCase(); applyFilter(); });
|
|
2166
|
+
$$(".hot-term").forEach(function (t) {
|
|
2167
|
+
t.addEventListener("click", function () {
|
|
2168
|
+
if (!search) return;
|
|
2169
|
+
search.value = t.textContent.trim();
|
|
2170
|
+
kw = search.value.toLowerCase();
|
|
2171
|
+
applyFilter();
|
|
2172
|
+
if (search.focus) search.focus();
|
|
2173
|
+
});
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2176
|
+
/* ===== 8. 过程回顾条:检索步骤展开 ===== */
|
|
2177
|
+
var pStep = $("#p-step-search");
|
|
2178
|
+
var pDetail = $("#p-detail");
|
|
2179
|
+
if (pStep && pDetail) {
|
|
2180
|
+
function toggleDetail() { pDetail.classList.toggle("show"); }
|
|
2181
|
+
pStep.addEventListener("click", toggleDetail);
|
|
2182
|
+
pStep.addEventListener("keydown", function (e) {
|
|
2183
|
+
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggleDetail(); }
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
/* ===== 9. 章节目录(spy) ===== */
|
|
2188
|
+
var toc = $(".toc");
|
|
2189
|
+
if (toc) {
|
|
2190
|
+
var links = $$("a", toc);
|
|
2191
|
+
var secs = links.map(function (a) { return document.querySelector(a.getAttribute("href")); });
|
|
2192
|
+
links.forEach(function (a) {
|
|
2193
|
+
a.addEventListener("click", function (e) {
|
|
2194
|
+
e.preventDefault();
|
|
2195
|
+
var target = document.querySelector(a.getAttribute("href"));
|
|
2196
|
+
if (!target) return;
|
|
2197
|
+
/* 手动定位而非 scrollIntoView({block:"start"}):后者把标题顶到视口 y=0,
|
|
2198
|
+
会被 sticky 顶栏盖住。偏移量与目录吸顶位置同一基准(顶栏高 + 20px)。 */
|
|
2199
|
+
var bar = document.querySelector(".topbar");
|
|
2200
|
+
var offset = (bar ? bar.offsetHeight : 0) + 20;
|
|
2201
|
+
var y = target.getBoundingClientRect().top + window.scrollY - offset;
|
|
2202
|
+
window.scrollTo({ top: Math.max(0, y), behavior: "smooth" });
|
|
2203
|
+
});
|
|
2204
|
+
});
|
|
2205
|
+
function spy() {
|
|
2206
|
+
var pos = window.scrollY + 130;
|
|
2207
|
+
var current = -1;
|
|
2208
|
+
secs.forEach(function (s, i) { if (s && s.offsetTop <= pos) current = i; });
|
|
2209
|
+
links.forEach(function (a, i) { a.classList.toggle("on", i === current); });
|
|
2210
|
+
}
|
|
2211
|
+
window.addEventListener("scroll", spy, { passive: true });
|
|
2212
|
+
spy();
|
|
2213
|
+
/* 目录纵向定位:此前 CSS 写死 top:120px,目录顶部与页头齐平、离正文很远。
|
|
2214
|
+
改为——初始与正文首节对齐,滚动时吸附在顶栏下方(正文首节上方还有页头、
|
|
2215
|
+
过程回顾与核验报告单,首屏内看不到目录属正常,滚动后自然吸附)。 */
|
|
2216
|
+
var topbar = document.querySelector(".topbar");
|
|
2217
|
+
function placeToc() {
|
|
2218
|
+
var first = secs[0];
|
|
2219
|
+
if (!first) return;
|
|
2220
|
+
var stick = (topbar ? topbar.offsetHeight : 0) + 20;
|
|
2221
|
+
var want = Math.round(first.getBoundingClientRect().top);
|
|
2222
|
+
toc.style.top = Math.max(stick, want) + "px";
|
|
2223
|
+
}
|
|
2224
|
+
window.addEventListener("scroll", placeToc, { passive: true });
|
|
2225
|
+
window.addEventListener("resize", placeToc);
|
|
2226
|
+
placeToc();
|
|
2227
|
+
}
|
|
2228
|
+
})();
|
|
2229
|
+
"""
|
|
2230
|
+
|
|
2231
|
+
|
|
1066
2232
|
def render_html(payload: Dict[str, Any], title: str, answer_override: str = "", question_override: str = "",
|
|
1067
2233
|
generated_at: Optional[datetime] = None, stage: str = "final") -> str:
|
|
1068
2234
|
# unwrap 会取出 content 包装;self_check / verification_checks / knowledgeBase 等
|
|
@@ -1070,47 +2236,59 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
1070
2236
|
raw_payload = payload
|
|
1071
2237
|
payload = unwrap(payload)
|
|
1072
2238
|
for key in ("selfCheck", "self_check", "verificationChecks", "verification_checks",
|
|
1073
|
-
"
|
|
2239
|
+
"recalled_materials", "召回材料", "检索文章"):
|
|
1074
2240
|
if key in raw_payload and key not in payload:
|
|
1075
2241
|
payload[key] = raw_payload[key]
|
|
1076
2242
|
answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(payload)
|
|
1077
2243
|
sources = align_sources_to_answer(answer, extract_sources(payload))
|
|
1078
2244
|
used = citation_ids(answer)
|
|
1079
|
-
#
|
|
1080
|
-
#
|
|
2245
|
+
# 未引用判定双通道 = JSON 标记(recalled_materials)∪ 正文角标未引用:
|
|
2246
|
+
# 进「未引用」分组,不占角标语义,不参与核验统计。
|
|
1081
2247
|
for s in sources:
|
|
1082
2248
|
if s["id"] not in used:
|
|
1083
2249
|
s["used"] = False
|
|
1084
|
-
|
|
1085
|
-
|
|
2250
|
+
# 3.7.2 起知识专库原始召回存档(kb_zone)移除:并行检索下接口返回的
|
|
2251
|
+
# knowledgeBase 链接会错乱不可靠,且未引用召回材料已在专库全量展示,
|
|
2252
|
+
# 对齐公文写作「知识专库链接不进报告」的前提(检索并行化的前置)。
|
|
1086
2253
|
generated_at = generated_at or datetime.now()
|
|
1087
2254
|
generated = generated_at.strftime("%Y-%m-%d %H:%M")
|
|
1088
2255
|
stage_label = STAGE_LABELS.get(stage, "成稿版")
|
|
1089
2256
|
|
|
1090
2257
|
verification = compute_verification(answer, sources, payload, generated_at)
|
|
2258
|
+
process_stats = compute_process_stats(sources, answer)
|
|
2259
|
+
hot_terms = extract_hot_terms(answer, sources)
|
|
1091
2260
|
citation_warning = ""
|
|
1092
2261
|
if sources and not used:
|
|
1093
2262
|
citation_warning = (
|
|
1094
2263
|
'<div class="warn-box"><b>生成检查未通过:正文没有来源角标。</b>'
|
|
1095
|
-
'本报告无法建立"
|
|
2264
|
+
'本报告无法建立"结论-来源文章"核验对应,仅作来源文章清单参考。'
|
|
1096
2265
|
'请修正答案文件(提纲版 _outline.md / 成稿版 _answer.txt):在关键事实后标注 [1]、[2] 等角标'
|
|
1097
2266
|
'并逐条对应素材清单,然后重新运行 render_trace_html.py 生成核验报告。</div>'
|
|
1098
2267
|
)
|
|
1099
|
-
|
|
2268
|
+
chip_map = build_chip_data(sources)
|
|
2269
|
+
blocks, _ = parse_answer_blocks(answer, {s["id"] for s in sources}, chip_map)
|
|
2270
|
+
# 胶囊内表格数据汇总(span 内静态表格会被解析器拆散,改为页尾 JSON + 展开时 JS 注入)
|
|
2271
|
+
jb_tables: Dict[str, str] = {}
|
|
2272
|
+
for cid, jb in chip_map.items():
|
|
2273
|
+
for key, tbl_html in (jb.pop("_tables", {}) or {}).items():
|
|
2274
|
+
jb_tables[key] = tbl_html
|
|
1100
2275
|
doc_title, sections = group_sections(blocks)
|
|
1101
2276
|
display_title = doc_title or title
|
|
1102
2277
|
report_label = f"{REPORT_NAME}({stage_label})"
|
|
1103
|
-
kb_zone = render_kb_zone(kb_urls, kb_labels, len(sources))
|
|
1104
2278
|
|
|
1105
|
-
|
|
2279
|
+
jb_tables_json = json.dumps(jb_tables, ensure_ascii=False).replace("</", "<\\/")
|
|
2280
|
+
jb_tables_script = (f'<script type="application/json" id="jb-tables">{jb_tables_json}</script>\n'
|
|
2281
|
+
if jb_tables else "")
|
|
2282
|
+
|
|
1106
2283
|
meta_bits = []
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
meta_bits.append("素材:" + " · ".join(cov_bits))
|
|
2284
|
+
if process_stats["n_searches"]:
|
|
2285
|
+
meta_bits.append(f"深知检索 {process_stats['n_searches']} 路")
|
|
1110
2286
|
if sources:
|
|
1111
|
-
meta_bits.append(f"
|
|
1112
|
-
|
|
1113
|
-
|
|
2287
|
+
meta_bits.append(f"来源文章 {len(sources)} 篇")
|
|
2288
|
+
if process_stats["n_cite_marks"]:
|
|
2289
|
+
meta_bits.append(f"正文引用 {process_stats['n_cite_marks']} 处")
|
|
2290
|
+
meta_bits.append(f"生成于 {generated}")
|
|
2291
|
+
meta_line = " · ".join(meta_bits)
|
|
1114
2292
|
|
|
1115
2293
|
return f"""<!doctype html>
|
|
1116
2294
|
<html lang="zh-CN">
|
|
@@ -1118,449 +2296,74 @@ def render_html(payload: Dict[str, Any], title: str, answer_override: str = "",
|
|
|
1118
2296
|
<meta charset="utf-8">
|
|
1119
2297
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1120
2298
|
<title>{esc(display_title)} · {esc(report_label)}</title>
|
|
1121
|
-
<style>
|
|
1122
|
-
:root{{
|
|
1123
|
-
--navy:#0b1f3a; --ink:#172236; --muted:#667085; --line:#dce4ef; --line-strong:#b9c6d9;
|
|
1124
|
-
--brand:#1559c7; --brand-soft:#e8f0ff;
|
|
1125
|
-
--policy:#0c9b78; --policy-soft:#e2f6ef;
|
|
1126
|
-
--case:#b26a00; --case-soft:#fff4e0;
|
|
1127
|
-
--ref:#4b5563; --ref-soft:#eef1f6;
|
|
1128
|
-
--warn:#b26a00; --danger:#b93939; --ok:#0c9b78;
|
|
1129
|
-
}}
|
|
1130
|
-
*{{box-sizing:border-box}}
|
|
1131
|
-
body{{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;
|
|
1132
|
-
color:var(--ink);background:#f4f7fb;line-height:1.75;font-size:14.5px}}
|
|
1133
|
-
a{{color:var(--brand)}}
|
|
1134
|
-
.topbar{{position:sticky;top:0;z-index:10;display:flex;justify-content:space-between;align-items:center;gap:10px;
|
|
1135
|
-
padding:10px 22px;background:var(--navy);color:#fff;font-size:13px}}
|
|
1136
|
-
.topbar .tb-title{{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
|
|
1137
|
-
.topbar .tags{{display:flex;align-items:center;gap:6px;flex:none}}
|
|
1138
|
-
.topbar .tags span{{padding:2px 10px;border:1px solid rgba(255,255,255,.3);border-radius:999px;font-size:11.5px}}
|
|
1139
|
-
.layout{{display:grid;grid-template-columns:minmax(0,760px) minmax(340px,420px);gap:26px;
|
|
1140
|
-
max-width:1240px;margin:0 auto;padding:26px 18px 60px}}
|
|
1141
|
-
/* 左栏 */
|
|
1142
|
-
.report{{min-width:0}}
|
|
1143
|
-
.r-head{{padding:22px 26px;background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:16px;text-align:center}}
|
|
1144
|
-
.r-badge{{display:inline-flex;align-items:center;gap:14px;margin:0 0 6px;color:var(--navy);
|
|
1145
|
-
font-size:16px;font-weight:800;letter-spacing:7px;text-indent:7px;line-height:1.5}}
|
|
1146
|
-
.r-badge::before,.r-badge::after{{content:"";width:64px;border-top:1px solid var(--line-strong)}}
|
|
1147
|
-
.r-head h1{{margin:0 0 8px;font-size:22px;color:var(--navy);line-height:1.5}}
|
|
1148
|
-
.r-head .sub{{color:var(--muted);font-size:12.5px}}
|
|
1149
|
-
.warn-box{{margin:0 0 16px;padding:13px 16px;border:1.5px solid var(--danger);border-radius:10px;
|
|
1150
|
-
background:#fdf3f3;color:#8f2626;font-size:13.5px;line-height:1.7}}
|
|
1151
|
-
.verify{{margin:0 0 16px;background:#fff;border:1px solid #bfe5d6;border-radius:12px;padding:16px 20px}}
|
|
1152
|
-
.verify.fail{{border-color:#f2c4c4;background:#fffafa}}
|
|
1153
|
-
.v-head{{display:flex;align-items:center;gap:9px;font-size:15px;font-weight:800;color:var(--ok)}}
|
|
1154
|
-
.verify.fail .v-head{{color:var(--danger)}}
|
|
1155
|
-
.v-shield{{display:inline-flex;width:22px;height:22px;border-radius:50%;background:var(--ok);color:#fff;
|
|
1156
|
-
align-items:center;justify-content:center;font-size:12px;flex:none}}
|
|
1157
|
-
.verify.fail .v-shield{{background:var(--danger)}}
|
|
1158
|
-
.v-stamp{{margin-left:auto;font-size:11px;border:1.5px solid var(--ok);color:var(--ok);border-radius:5px;
|
|
1159
|
-
padding:1px 8px;letter-spacing:2px;flex:none}}
|
|
1160
|
-
.v-stamp.bad{{border-color:var(--danger);color:var(--danger)}}
|
|
1161
|
-
.v-reasons{{margin-top:6px;font-size:12.5px;color:var(--danger)}}
|
|
1162
|
-
.v-grid{{display:grid;grid-template-columns:1fr 1fr;gap:4px 20px;margin-top:10px}}
|
|
1163
|
-
.vi{{display:flex;gap:7px;align-items:baseline;font-size:12.5px;color:#35445c;line-height:1.7;min-width:0}}
|
|
1164
|
-
.vi .s{{font-weight:800;flex:none}}
|
|
1165
|
-
.vi .s.ok{{color:var(--ok)}}
|
|
1166
|
-
.vi .s.warn{{color:var(--warn)}}
|
|
1167
|
-
.vi .s.fail{{color:var(--danger)}}
|
|
1168
|
-
.vi .s.man{{color:var(--case)}}
|
|
1169
|
-
.vi .s.none{{color:var(--muted)}}
|
|
1170
|
-
.vi .d{{color:var(--muted);min-width:0}}
|
|
1171
|
-
.v-note{{margin-top:11px;padding-top:9px;border-top:1px dashed var(--line);font-size:11.5px;color:var(--muted);line-height:1.7}}
|
|
1172
|
-
/* 正文章节卡 */
|
|
1173
|
-
.doc-sec{{background:#fff;border:1px solid var(--line);border-radius:12px;padding:20px 24px;margin-bottom:16px}}
|
|
1174
|
-
.sec-head{{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin-bottom:10px;
|
|
1175
|
-
padding-bottom:10px;border-bottom:1px solid var(--line)}}
|
|
1176
|
-
.sec-no{{display:inline-flex;width:26px;height:26px;border-radius:7px;background:var(--brand);color:#fff;
|
|
1177
|
-
align-items:center;justify-content:center;font-size:13.5px;font-weight:700;flex:none}}
|
|
1178
|
-
.sec-head h3{{margin:0;font-size:16.5px;color:var(--navy);line-height:1.5}}
|
|
1179
|
-
.sec-badge{{margin-left:auto;font-size:11.5px;color:var(--ok);background:var(--policy-soft);
|
|
1180
|
-
border-radius:6px;padding:2px 9px;font-weight:700;flex:none}}
|
|
1181
|
-
.sec-badge.bad{{color:var(--danger);background:#fdecea}}
|
|
1182
|
-
.doc-sub{{margin:16px 0 8px;color:var(--navy);font-size:14.5px;font-weight:700}}
|
|
1183
|
-
h5.doc-sub{{font-size:13.5px}}
|
|
1184
|
-
.doc-block,.doc-item{{margin:0 0 12px}}
|
|
1185
|
-
.doc-block p,.doc-item p{{margin:0;font-size:14px;line-height:1.9}}
|
|
1186
|
-
.doc-item{{display:grid;grid-template-columns:22px minmax(0,1fr);gap:8px}}
|
|
1187
|
-
.doc-item.numbered{{grid-template-columns:28px minmax(0,1fr)}}
|
|
1188
|
-
.doc-bullet{{padding-top:1px;color:#111827;font-size:15px;line-height:1.85}}
|
|
1189
|
-
.doc-divider{{border:0;border-top:1px solid var(--line);margin:18px 0}}
|
|
1190
|
-
code{{padding:1px 5px;border-radius:4px;background:#f3f4f6;color:#374151;
|
|
1191
|
-
font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}}
|
|
1192
|
-
.tbl-wrap{{max-width:100%;overflow-x:auto;margin:8px 0}}
|
|
1193
|
-
.data-tbl{{width:100%;border-collapse:collapse;border:1px solid var(--line);font-size:13px}}
|
|
1194
|
-
.data-tbl th,.data-tbl td{{border:1px solid var(--line);padding:8px 10px;text-align:left;vertical-align:top;line-height:1.65}}
|
|
1195
|
-
.data-tbl th{{background:#f2f5fb;font-weight:700;color:#374151;white-space:nowrap}}
|
|
1196
|
-
.data-tbl tbody tr:nth-child(even) td{{background:#fafbfd}}
|
|
1197
|
-
.data-tbl.wide{{min-width:560px}}
|
|
1198
|
-
.data-tbl td .ev-row{{margin:4px 0 0}}
|
|
1199
|
-
/* 角标 */
|
|
1200
|
-
.cite{{margin:0 1px;padding:0 5px;border:0;border-radius:4px;background:var(--brand-soft);color:var(--brand);
|
|
1201
|
-
font-weight:800;font-size:10.5px;cursor:pointer;vertical-align:super;font-family:monospace}}
|
|
1202
|
-
.cite:hover,.cite:focus-visible{{background:var(--brand);color:#fff;outline:none}}
|
|
1203
|
-
.cite.unresolved{{background:#fdecea;color:var(--danger)}}
|
|
1204
|
-
/* 段落级证据 chips */
|
|
1205
|
-
.ev-row{{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0 2px}}
|
|
1206
|
-
.ev-chip{{max-width:100%}}
|
|
1207
|
-
.ev-chip summary{{display:inline-flex;align-items:center;max-width:100%;border-radius:999px;padding:3px 10px;
|
|
1208
|
-
color:#4b5563;background:#f3f4f6;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
|
|
1209
|
-
list-style:none;font-size:11.5px}}
|
|
1210
|
-
.ev-chip summary::-webkit-details-marker{{display:none}}
|
|
1211
|
-
.ev-chip summary::after{{content:"核验";margin-left:7px;color:#9ca3af;font-size:10.5px}}
|
|
1212
|
-
.ev-chip[open] summary::after{{content:"收起"}}
|
|
1213
|
-
.ev-chip summary b{{color:var(--brand);margin-right:5px}}
|
|
1214
|
-
.ev-panel{{margin:7px 0 6px;padding:12px 14px;border:1px solid var(--line);border-radius:9px;background:#fbfcfe;
|
|
1215
|
-
box-shadow:0 8px 24px rgba(15,23,42,.06)}}
|
|
1216
|
-
.ev-title{{font-weight:700;font-size:13.5px;margin-bottom:4px;color:var(--navy)}}
|
|
1217
|
-
.ev-meta{{color:var(--muted);font-size:12px;margin-bottom:6px}}
|
|
1218
|
-
.ev-panel p{{margin:0 0 8px;color:#374151;font-size:12.8px;line-height:1.7}}
|
|
1219
|
-
.sc-links{{display:flex;flex-wrap:wrap;gap:8px;margin-top:6px}}
|
|
1220
|
-
.sc-links span{{display:inline-flex}}
|
|
1221
|
-
.sc-links a{{display:inline-flex;align-items:center;min-height:24px;padding:3px 9px;border-radius:6px;
|
|
1222
|
-
background:var(--brand-soft);color:var(--brand);font-weight:700;text-decoration:none;font-size:12px}}
|
|
1223
|
-
/* 右栏 核验材料 */
|
|
1224
|
-
.sources{{position:sticky;top:56px;align-self:start;max-height:calc(100vh - 76px);overflow:auto;
|
|
1225
|
-
background:#fff;border:1px solid var(--line);border-radius:12px;padding:16px 18px}}
|
|
1226
|
-
.sources h3{{margin:0 0 3px;font-size:15px;color:var(--navy)}}
|
|
1227
|
-
.src-tip{{font-size:11.5px;color:var(--muted);margin-bottom:10px}}
|
|
1228
|
-
.filters{{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}}
|
|
1229
|
-
.filters button{{border:1px solid var(--line);border-radius:999px;background:#fff;color:var(--muted);
|
|
1230
|
-
padding:3px 11px;font-size:12px;cursor:pointer}}
|
|
1231
|
-
.filters button.on{{background:var(--brand);border-color:var(--brand);color:#fff;font-weight:700}}
|
|
1232
|
-
.src-search{{width:100%;padding:7px 10px;border:1px solid var(--line);border-radius:7px;font-size:12.5px;margin-bottom:12px}}
|
|
1233
|
-
.scard{{border:1px solid var(--line);border-left-width:3px;border-radius:10px;padding:11px 13px;margin-bottom:10px;
|
|
1234
|
-
background:#fff;transition:box-shadow .25s}}
|
|
1235
|
-
.scard.pol{{border-left-color:var(--policy)}}
|
|
1236
|
-
.scard.dat{{border-left-color:var(--brand)}}
|
|
1237
|
-
.scard.cas{{border-left-color:var(--case)}}
|
|
1238
|
-
.scard.ref,.scard.mat{{border-left-color:var(--ref)}}
|
|
1239
|
-
.scard.hl{{box-shadow:0 0 0 3px var(--brand)}}
|
|
1240
|
-
.scard.hide{{display:none}}
|
|
1241
|
-
.sc-head{{display:flex;align-items:center;gap:7px;margin-bottom:4px}}
|
|
1242
|
-
.sc-id{{font-family:monospace;font-weight:800;font-size:11px;color:var(--brand);background:var(--brand-soft);
|
|
1243
|
-
border-radius:4px;padding:1px 7px}}
|
|
1244
|
-
.sc-type{{font-size:11px;font-weight:700;border-radius:4px;padding:1px 8px;background:var(--ref-soft);color:var(--ref)}}
|
|
1245
|
-
.scard.pol .sc-type{{background:var(--policy-soft);color:var(--policy)}}
|
|
1246
|
-
.scard.dat .sc-type{{background:var(--brand-soft);color:var(--brand)}}
|
|
1247
|
-
.scard.cas .sc-type{{background:var(--case-soft);color:var(--case)}}
|
|
1248
|
-
.sc-vk{{margin-left:auto;font-size:11px;font-weight:800;color:var(--ok)}}
|
|
1249
|
-
.sc-vk.warn{{color:var(--warn)}}
|
|
1250
|
-
.scard h4{{margin:0 0 4px;font-size:13px;color:var(--navy);line-height:1.55}}
|
|
1251
|
-
.sc-meta{{font-size:11.5px;color:var(--muted)}}
|
|
1252
|
-
.sc-section{{font-size:11.5px;color:var(--brand);margin-top:3px;font-weight:600}}
|
|
1253
|
-
.sc-vnote{{margin-top:5px;font-size:11.3px;color:var(--ok);line-height:1.6}}
|
|
1254
|
-
.sc-excerpt{{margin:7px 0;padding:9px 10px;border-radius:7px;background:#f8fafc;color:#42566f;font-size:12px;line-height:1.7;
|
|
1255
|
-
display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;cursor:pointer}}
|
|
1256
|
-
.scard.open .sc-excerpt{{display:block;-webkit-line-clamp:unset}}
|
|
1257
|
-
.sc-excerpt.rich{{overflow-x:auto}}
|
|
1258
|
-
.sc-excerpt.rich table{{width:max-content;min-width:100%;border-collapse:collapse;background:#fff;font-size:12px}}
|
|
1259
|
-
.sc-excerpt.rich td,.sc-excerpt.rich th{{min-width:92px;max-width:220px;padding:7px 8px;border:1px solid var(--line);
|
|
1260
|
-
vertical-align:top;word-break:break-word}}
|
|
1261
|
-
.sc-excerpt.rich thead td,.sc-excerpt.rich th{{background:#f3f4f6;color:#374151;font-weight:700}}
|
|
1262
|
-
.scard .sc-links a{{font-size:12px}}
|
|
1263
|
-
.scard .sc-links{{margin-top:4px}}
|
|
1264
|
-
.no-link{{font-size:11.5px;color:var(--muted)}}
|
|
1265
|
-
.sc-unused{{font-size:10.5px;font-weight:800;color:var(--muted);background:#eef1f6;border-radius:4px;
|
|
1266
|
-
padding:1px 7px;flex:none}}
|
|
1267
|
-
.sc-conf{{font-size:10.5px;font-weight:800;color:#8a5a00;background:var(--case-soft);border:1px solid #e8c98a;
|
|
1268
|
-
border-radius:4px;padding:0 7px;flex:none}}
|
|
1269
|
-
.sc-extag{{margin-top:8px;padding-top:7px;border-top:1px dashed var(--line-strong);font-size:11px;color:#0b6e4f;font-weight:700}}
|
|
1270
|
-
.sc-chain{{font-size:11.5px;color:var(--brand);margin-top:3px;font-weight:600;line-height:1.6;cursor:help}}
|
|
1271
|
-
.sc-more{{display:none;margin:-3px 2px 4px;text-align:right;font-size:11px;color:var(--brand);font-weight:700;cursor:pointer;user-select:none}}
|
|
1272
|
-
.scard.clampable .sc-more{{display:block}}
|
|
1273
|
-
.scard.clampable .sc-more::before{{content:"展开全文 ▾"}}
|
|
1274
|
-
.scard.clampable.open .sc-more::before{{content:"收起 ▴"}}
|
|
1275
|
-
.uncited-group{{margin-top:12px;border-top:1px dashed var(--line-strong);padding-top:10px}}
|
|
1276
|
-
.ug-title{{font-size:12.5px;color:var(--muted);font-weight:700;line-height:1.6}}
|
|
1277
|
-
.uncited-group .uncited-list{{margin-top:10px}}
|
|
1278
|
-
/* 知识专库 */
|
|
1279
|
-
.kb-zone{{margin-top:14px;border-top:1px dashed var(--line-strong);padding-top:12px}}
|
|
1280
|
-
.kb-title{{font-size:12.5px;font-weight:800;color:var(--navy)}}
|
|
1281
|
-
.kb-desc{{font-size:11.3px;color:var(--muted);line-height:1.65;margin:3px 0 8px}}
|
|
1282
|
-
.kb-list{{display:flex;flex-direction:column;gap:7px}}
|
|
1283
|
-
.kb-chip{{display:flex;align-items:center;gap:8px;padding:7px 10px;border:1px solid var(--line);border-radius:8px;
|
|
1284
|
-
background:#fbfcfe;text-decoration:none;font-size:11.5px}}
|
|
1285
|
-
.kb-chip:hover{{border-color:var(--brand);background:var(--brand-soft)}}
|
|
1286
|
-
.kb-label{{font-weight:700;color:#374151;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}}
|
|
1287
|
-
.kb-count{{padding-left:8px;border-left:1px solid var(--line);color:var(--muted);white-space:nowrap}}
|
|
1288
|
-
.kb-arrow{{margin-left:auto;color:var(--brand);font-weight:700;white-space:nowrap}}
|
|
1289
|
-
.empty{{color:var(--muted)}}
|
|
1290
|
-
.foot{{text-align:center;color:var(--muted);font-size:11.5px;padding:16px 0 4px;line-height:1.8}}
|
|
1291
|
-
.mobile-nav{{display:none}}
|
|
1292
|
-
.back-doc{{display:none}}
|
|
1293
|
-
/* 移动端材料底部弹层:点角标就地弹出材料卡,不跳转打断阅读 */
|
|
1294
|
-
.sheet-mask{{display:none}}
|
|
1295
|
-
.sheet{{display:none}}
|
|
1296
|
-
@media (max-width:680px){{
|
|
1297
|
-
body{{font-size:14px;line-height:1.8}}
|
|
1298
|
-
.layout{{grid-template-columns:1fr;padding:12px 10px 40px;gap:14px}}
|
|
1299
|
-
.topbar{{padding:8px 12px;font-size:12px;gap:4px;flex-wrap:wrap}}
|
|
1300
|
-
.topbar .tags span{{font-size:10.5px;padding:1px 8px;margin-left:4px}}
|
|
1301
|
-
.r-head{{padding:16px 14px;border-radius:10px}}
|
|
1302
|
-
.r-badge{{font-size:13.5px;letter-spacing:6px;text-indent:6px;gap:10px}}
|
|
1303
|
-
.r-badge::before,.r-badge::after{{width:40px}}
|
|
1304
|
-
.r-head h1{{font-size:18px}}
|
|
1305
|
-
.r-head .sub{{font-size:11.5px;line-height:1.6}}
|
|
1306
|
-
.verify{{padding:13px 14px;border-radius:10px}}
|
|
1307
|
-
.v-head{{font-size:14px}}
|
|
1308
|
-
.v-grid{{grid-template-columns:1fr;gap:2px 0}}
|
|
1309
|
-
.vi{{flex-wrap:wrap;gap:4px 8px}}
|
|
1310
|
-
.vi .d{{min-width:0}}
|
|
1311
|
-
.warn-box{{font-size:12.5px;padding:11px 12px}}
|
|
1312
|
-
.doc-sec{{padding:14px;border-radius:10px}}
|
|
1313
|
-
.sec-no{{width:22px;height:22px;font-size:12px;border-radius:6px}}
|
|
1314
|
-
.sec-head{{gap:7px;padding-bottom:8px;margin-bottom:8px}}
|
|
1315
|
-
.sec-head h3{{font-size:15px}}
|
|
1316
|
-
.sec-badge{{margin-left:0;font-size:11px}}
|
|
1317
|
-
.doc-block p,.doc-item p{{font-size:13.5px;line-height:1.95}}
|
|
1318
|
-
.doc-sub{{font-size:14px;margin:12px 0 6px}}
|
|
1319
|
-
.data-tbl{{font-size:12px}}
|
|
1320
|
-
.data-tbl th,.data-tbl td{{padding:6px 7px;line-height:1.55}}
|
|
1321
|
-
.cite{{font-size:11px;padding:0 4px}}
|
|
1322
|
-
.ev-chip summary{{font-size:11px}}
|
|
1323
|
-
.sources{{padding:12px;border-radius:10px}}
|
|
1324
|
-
.scard{{padding:10px 11px}}
|
|
1325
|
-
.sc-excerpt{{font-size:11.5px}}
|
|
1326
|
-
.kb-chip{{flex-wrap:wrap}}
|
|
1327
|
-
.kb-label{{white-space:normal}}
|
|
1328
|
-
.mobile-nav{{display:block;margin:0 0 14px;padding:11px 14px;border:1.5px solid var(--brand);
|
|
1329
|
-
border-radius:10px;background:var(--brand-soft);color:var(--brand);font-weight:800;
|
|
1330
|
-
font-size:13.5px;text-decoration:none;text-align:center}}
|
|
1331
|
-
.back-doc{{display:inline-block;margin:0 0 8px;font-size:12px;color:var(--brand);
|
|
1332
|
-
font-weight:700;text-decoration:none}}
|
|
1333
|
-
.sheet-mask{{display:block;position:fixed;inset:0;background:rgba(11,31,58,.45);z-index:99;opacity:0;
|
|
1334
|
-
pointer-events:none;transition:opacity .2s}}
|
|
1335
|
-
.sheet-mask.show{{opacity:1;pointer-events:auto}}
|
|
1336
|
-
.sheet{{display:block;position:fixed;left:0;right:0;bottom:0;z-index:100;background:#fff;
|
|
1337
|
-
border-radius:14px 14px 0 0;box-shadow:0 -8px 30px rgba(11,31,58,.25);
|
|
1338
|
-
max-height:68vh;overflow-y:auto;-webkit-overflow-scrolling:touch;
|
|
1339
|
-
padding:10px 16px 22px;transform:translateY(105%);transition:transform .25s ease}}
|
|
1340
|
-
.sheet.show{{transform:translateY(0)}}
|
|
1341
|
-
.sheet-grab{{width:38px;height:4px;border-radius:2px;background:#c9d4e2;margin:2px auto 8px}}
|
|
1342
|
-
.sheet-head{{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}}
|
|
1343
|
-
.sheet-head b{{font-size:13.5px;color:var(--navy)}}
|
|
1344
|
-
.sheet-close{{border:1px solid var(--line);background:#f5f8fc;border-radius:8px;color:#3b4a61;
|
|
1345
|
-
font-size:12.5px;font-weight:700;padding:5px 14px;cursor:pointer}}
|
|
1346
|
-
.sheet .scard{{box-shadow:none;margin-bottom:0}}
|
|
1347
|
-
.sheet .sc-excerpt{{display:block;-webkit-line-clamp:unset;cursor:auto}}
|
|
1348
|
-
/* 正文表述 ↔ 原文原段 对照区(弹层顶部) */
|
|
1349
|
-
.cmp{{margin:0 0 10px;border:1px solid var(--line);border-radius:10px;overflow:hidden}}
|
|
1350
|
-
.cmp-tag{{font-size:11px;font-weight:800;padding:3px 10px}}
|
|
1351
|
-
.cmp-side{{padding:9px 12px;font-size:12.8px;line-height:1.7}}
|
|
1352
|
-
.cmp-side p{{margin:0}}
|
|
1353
|
-
.cmp-ai{{background:#fbfcfe;color:#374151}}
|
|
1354
|
-
.cmp-ai .cmp-tag{{background:#eef1f6;color:var(--ref)}}
|
|
1355
|
-
.cmp-src{{background:#f4faf7;color:#2f4a3e;border-top:1px dashed var(--line-strong)}}
|
|
1356
|
-
.cmp-src .cmp-tag{{background:var(--policy-soft);color:#0b6e4f}}
|
|
1357
|
-
.cmp-src .sc-excerpt{{display:block;-webkit-line-clamp:unset;background:#fff;cursor:auto;font-size:12px;padding:8px 10px;margin:0}}
|
|
1358
|
-
}}
|
|
1359
|
-
@media (max-width:1020px){{
|
|
1360
|
-
.layout{{grid-template-columns:1fr}}
|
|
1361
|
-
.sources{{position:static;max-height:none}}
|
|
1362
|
-
}}
|
|
1363
|
-
@media print{{
|
|
1364
|
-
.topbar,.filters,.src-search{{display:none!important}}
|
|
1365
|
-
.layout{{grid-template-columns:1fr;max-width:none;padding:0;gap:14px}}
|
|
1366
|
-
body{{background:#fff;font-size:12.5px}}
|
|
1367
|
-
.sources{{position:static;max-height:none;border:0;padding:0;overflow:visible}}
|
|
1368
|
-
.r-head,.verify,.doc-sec{{border-color:#bbb;box-shadow:none;break-inside:avoid}}
|
|
1369
|
-
.sc-excerpt{{display:block;-webkit-line-clamp:unset;cursor:auto}}
|
|
1370
|
-
.uncited-group[open] .uncited-list,.uncited-group{{break-inside:avoid}}
|
|
1371
|
-
.scard{{break-inside:avoid}}
|
|
1372
|
-
.cite{{background:#eee;color:#333}}
|
|
1373
|
-
}}
|
|
1374
|
-
</style>
|
|
2299
|
+
<style>{PAGE_CSS}</style>
|
|
1375
2300
|
</head>
|
|
1376
2301
|
<body>
|
|
1377
2302
|
|
|
1378
2303
|
<header class="topbar">
|
|
1379
|
-
<div class="tb-
|
|
1380
|
-
|
|
1381
|
-
<span
|
|
1382
|
-
|
|
2304
|
+
<div class="tb-left">
|
|
2305
|
+
<span class="tb-stamp">{esc(REPORT_NAME)}</span>
|
|
2306
|
+
<span class="tb-title">{esc(display_title)}</span>
|
|
2307
|
+
</div>
|
|
2308
|
+
<div class="tb-right">
|
|
2309
|
+
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2310
|
+
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2311
|
+
<button data-view="library" type="button">知识专库</button>
|
|
2312
|
+
</div>
|
|
2313
|
+
<div class="tb-tools">
|
|
2314
|
+
<button id="btn-reading" type="button" aria-pressed="false" title="隐藏核验元素,纯阅读正文">只看正文</button>
|
|
2315
|
+
<button id="btn-copy" type="button" title="复制正文纯文本">复制全文</button>
|
|
2316
|
+
<span class="print-menu">
|
|
2317
|
+
<button id="btn-print" type="button" aria-haspopup="true" title="浏览器打印/另存为 PDF">打印归档 ▾</button>
|
|
2318
|
+
<span class="print-drop" id="print-drop" hidden>
|
|
2319
|
+
<button id="print-body" type="button">只打印正文</button>
|
|
2320
|
+
<button id="print-full" type="button">完整归档(含核验材料)</button>
|
|
2321
|
+
</span>
|
|
2322
|
+
</span>
|
|
2323
|
+
</div>
|
|
1383
2324
|
</div>
|
|
2325
|
+
<div class="progress" aria-hidden="true"><i></i></div>
|
|
1384
2326
|
</header>
|
|
1385
2327
|
|
|
1386
|
-
<div class="
|
|
1387
|
-
<
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
2328
|
+
<div class="hero">
|
|
2329
|
+
<div class="r-badge">{esc(report_label)}</div>
|
|
2330
|
+
<h1>{esc(display_title)}</h1>
|
|
2331
|
+
<div class="meta">{esc(meta_line)} | 素材来源:深知可信搜索</div>
|
|
2332
|
+
<div class="hero-switch">
|
|
2333
|
+
<div class="view-switch" role="tablist" aria-label="视图切换">
|
|
2334
|
+
<button class="on" data-view="report" type="button">核验报告</button>
|
|
2335
|
+
<button data-view="library" type="button">知识专库({len(sources)})</button>
|
|
1392
2336
|
</div>
|
|
2337
|
+
</div>
|
|
2338
|
+
</div>
|
|
2339
|
+
|
|
2340
|
+
<div class="app container" data-view="report">
|
|
2341
|
+
{render_process_bar(process_stats, verification)}
|
|
2342
|
+
|
|
2343
|
+
<main class="view" id="view-report" aria-label="核验报告正文">
|
|
1393
2344
|
{citation_warning}
|
|
1394
2345
|
{render_verify_panel(verification, stage)}
|
|
1395
|
-
<
|
|
2346
|
+
<div class="doc-paper">
|
|
1396
2347
|
{render_section_cards(sections, sources)}
|
|
1397
|
-
|
|
2348
|
+
</div>
|
|
2349
|
+
<div class="foot">深知可信PPT · 溯源核验报告 | 内容由 AI 生成,仅供参考</div>
|
|
1398
2350
|
</main>
|
|
1399
|
-
|
|
2351
|
+
|
|
2352
|
+
{render_library_view(sources, hot_terms)}
|
|
2353
|
+
{render_print_appendix(sources)}
|
|
1400
2354
|
</div>
|
|
1401
2355
|
|
|
1402
|
-
|
|
2356
|
+
{render_toc(sections)}
|
|
2357
|
+
|
|
2358
|
+
<div class="ev-panel" id="ev-pop" hidden></div>
|
|
2359
|
+
{jb_tables_script}<div class="sheet-mask" aria-hidden="true"></div>
|
|
1403
2360
|
<div class="sheet" role="dialog" aria-label="核验材料">
|
|
1404
2361
|
<div class="sheet-grab"></div>
|
|
1405
2362
|
<div class="sheet-head"><b>依据对照</b><button class="sheet-close" type="button">收起</button></div>
|
|
1406
2363
|
<div class="sheet-body"></div>
|
|
1407
2364
|
</div>
|
|
1408
2365
|
|
|
1409
|
-
<script>
|
|
1410
|
-
(function () {{
|
|
1411
|
-
"use strict";
|
|
1412
|
-
var cards = Array.prototype.slice.call(document.querySelectorAll(".scard"));
|
|
1413
|
-
var byId = {{}};
|
|
1414
|
-
cards.forEach(function (c) {{
|
|
1415
|
-
var id = c.getAttribute("data-cite-id");
|
|
1416
|
-
if (id) byId[id] = c;
|
|
1417
|
-
}});
|
|
1418
|
-
|
|
1419
|
-
/* 移动端底部弹层:点角标就地展示材料卡,不打断正文阅读 */
|
|
1420
|
-
var sheet = document.querySelector(".sheet");
|
|
1421
|
-
var mask = document.querySelector(".sheet-mask");
|
|
1422
|
-
function isMobile() {{
|
|
1423
|
-
return window.matchMedia("(max-width:680px)").matches;
|
|
1424
|
-
}}
|
|
1425
|
-
function escHtml(s) {{
|
|
1426
|
-
var d = document.createElement("div");
|
|
1427
|
-
d.textContent = s;
|
|
1428
|
-
return d.innerHTML;
|
|
1429
|
-
}}
|
|
1430
|
-
function sentenceOf(el) {{
|
|
1431
|
-
var para = el && el.closest ? el.closest(".doc-block,.doc-item") : null;
|
|
1432
|
-
return para && para.querySelector("p") ? para.querySelector("p").innerText.trim() : "";
|
|
1433
|
-
}}
|
|
1434
|
-
function openSheet(card, sentence) {{
|
|
1435
|
-
if (!sheet) return;
|
|
1436
|
-
var body = sheet.querySelector(".sheet-body");
|
|
1437
|
-
body.innerHTML = "";
|
|
1438
|
-
if (sentence) {{
|
|
1439
|
-
var excerpt = card.querySelector(".sc-excerpt");
|
|
1440
|
-
var cmp = document.createElement("div");
|
|
1441
|
-
cmp.className = "cmp";
|
|
1442
|
-
cmp.innerHTML =
|
|
1443
|
-
'<div class="cmp-side cmp-ai"><div class="cmp-tag">正文表述(AI 生成)</div><p>' + escHtml(sentence) + '</p></div>' +
|
|
1444
|
-
'<div class="cmp-side cmp-src"><div class="cmp-tag">原文原段(非 AI 生成)</div>' +
|
|
1445
|
-
'<div class="sc-excerpt">' + (excerpt ? excerpt.innerHTML : "") + '</div></div>';
|
|
1446
|
-
body.appendChild(cmp);
|
|
1447
|
-
}}
|
|
1448
|
-
var clone = card.cloneNode(true);
|
|
1449
|
-
clone.removeAttribute("id");
|
|
1450
|
-
clone.classList.remove("hide");
|
|
1451
|
-
clone.classList.add("open");
|
|
1452
|
-
var sheetMore = clone.querySelector(".sc-more");
|
|
1453
|
-
if (sheetMore) sheetMore.remove();
|
|
1454
|
-
body.appendChild(clone);
|
|
1455
|
-
sheet.classList.add("show");
|
|
1456
|
-
mask.classList.add("show");
|
|
1457
|
-
document.body.style.overflow = "hidden";
|
|
1458
|
-
sheet.scrollTop = 0;
|
|
1459
|
-
}}
|
|
1460
|
-
function closeSheet() {{
|
|
1461
|
-
if (!sheet) return;
|
|
1462
|
-
sheet.classList.remove("show");
|
|
1463
|
-
mask.classList.remove("show");
|
|
1464
|
-
document.body.style.overflow = "";
|
|
1465
|
-
}}
|
|
1466
|
-
if (sheet && mask) {{
|
|
1467
|
-
mask.addEventListener("click", closeSheet);
|
|
1468
|
-
var closeBtn = sheet.querySelector(".sheet-close");
|
|
1469
|
-
if (closeBtn) closeBtn.addEventListener("click", closeSheet);
|
|
1470
|
-
}}
|
|
1471
|
-
|
|
1472
|
-
/* 角标 → 来源卡:精确 ID 匹配,缺失即红色警示,绝不按位置猜测。
|
|
1473
|
-
手机单栏下不滚动定位(会跳到页面底部打断阅读),改为底部弹层就地查看。 */
|
|
1474
|
-
document.querySelectorAll(".data-cite,[data-cite]").forEach(function (btn) {{
|
|
1475
|
-
if (btn.classList.contains("sheet-close")) return;
|
|
1476
|
-
btn.addEventListener("click", function () {{
|
|
1477
|
-
var card = byId[btn.getAttribute("data-cite")];
|
|
1478
|
-
if (!card) {{
|
|
1479
|
-
btn.classList.add("unresolved");
|
|
1480
|
-
if (console.error) console.error("[核验] 未绑定角标:", btn.getAttribute("data-cite"));
|
|
1481
|
-
return;
|
|
1482
|
-
}}
|
|
1483
|
-
if (isMobile()) {{
|
|
1484
|
-
openSheet(card, sentenceOf(btn));
|
|
1485
|
-
return;
|
|
1486
|
-
}}
|
|
1487
|
-
card.classList.remove("hide", "open");
|
|
1488
|
-
card.classList.add("hl", "open");
|
|
1489
|
-
card.scrollIntoView({{ block: "center", behavior: "smooth" }});
|
|
1490
|
-
setTimeout(function () {{ card.classList.remove("hl"); }}, 2200);
|
|
1491
|
-
}});
|
|
1492
|
-
}});
|
|
1493
|
-
|
|
1494
|
-
/* 摘录折叠:按渲染实测高度判断是否截断(超 4 行),仅实际截断的卡片显示「展开全文」;
|
|
1495
|
-
点摘录或「展开全文」切换;展开时滚动回卡片顶部。 */
|
|
1496
|
-
cards.forEach(function (c) {{
|
|
1497
|
-
var ex = c.querySelector(".sc-excerpt");
|
|
1498
|
-
if (!ex) return;
|
|
1499
|
-
if (ex.scrollHeight > ex.clientHeight + 4) c.classList.add("clampable");
|
|
1500
|
-
function toggleExcerpt() {{ c.classList.toggle("open"); }}
|
|
1501
|
-
ex.addEventListener("click", function (e) {{
|
|
1502
|
-
if (e.target.closest("a")) return;
|
|
1503
|
-
toggleExcerpt();
|
|
1504
|
-
}});
|
|
1505
|
-
var more = c.querySelector(".sc-more");
|
|
1506
|
-
if (more) {{
|
|
1507
|
-
more.addEventListener("click", toggleExcerpt);
|
|
1508
|
-
more.addEventListener("keydown", function (e) {{
|
|
1509
|
-
if (e.key === "Enter" || e.key === " ") {{ e.preventDefault(); toggleExcerpt(); }}
|
|
1510
|
-
}});
|
|
1511
|
-
}}
|
|
1512
|
-
}});
|
|
1513
|
-
|
|
1514
|
-
/* 证据 chips(灰框):桌面端点击就地展开并高亮右栏来源卡;手机端不就地展开,点击直接弹出底部材料弹层 */
|
|
1515
|
-
document.querySelectorAll(".ev-chip").forEach(function (chip) {{
|
|
1516
|
-
var summary = chip.querySelector("summary");
|
|
1517
|
-
if (summary) {{
|
|
1518
|
-
summary.addEventListener("click", function (e) {{
|
|
1519
|
-
if (isMobile()) {{
|
|
1520
|
-
e.preventDefault();
|
|
1521
|
-
var card = byId[chip.getAttribute("data-cite")];
|
|
1522
|
-
if (card) openSheet(card, sentenceOf(chip));
|
|
1523
|
-
return;
|
|
1524
|
-
}}
|
|
1525
|
-
var y = window.scrollY;
|
|
1526
|
-
var restore = function () {{ window.scrollTo(0, y); }};
|
|
1527
|
-
requestAnimationFrame(function () {{ restore(); requestAnimationFrame(restore); }});
|
|
1528
|
-
}});
|
|
1529
|
-
}}
|
|
1530
|
-
chip.addEventListener("toggle", function () {{
|
|
1531
|
-
if (!chip.open || isMobile()) return;
|
|
1532
|
-
var card = byId[chip.getAttribute("data-cite")];
|
|
1533
|
-
if (!card) return;
|
|
1534
|
-
cards.forEach(function (c) {{ c.classList.remove("hl"); }});
|
|
1535
|
-
card.classList.add("hl");
|
|
1536
|
-
setTimeout(function () {{ card.classList.remove("hl"); }}, 2200);
|
|
1537
|
-
}});
|
|
1538
|
-
}});
|
|
1539
|
-
|
|
1540
|
-
/* 检索分组筛选(单选 + 全部 + 未引用,胶囊样式)+ 关键字搜索叠加 */
|
|
1541
|
-
var cond = "";
|
|
1542
|
-
var kw = "";
|
|
1543
|
-
function apply() {{
|
|
1544
|
-
cards.forEach(function (c) {{
|
|
1545
|
-
var okCond = !cond;
|
|
1546
|
-
if (cond === "__unused__") okCond = c.getAttribute("data-unused") === "1";
|
|
1547
|
-
else if (cond) okCond = c.getAttribute("data-search") === cond;
|
|
1548
|
-
var okKw = !kw || (c.textContent || "").toLowerCase().indexOf(kw) !== -1;
|
|
1549
|
-
c.classList.toggle("hide", !(okCond && okKw));
|
|
1550
|
-
}});
|
|
1551
|
-
}}
|
|
1552
|
-
document.querySelectorAll(".filters button").forEach(function (b) {{
|
|
1553
|
-
b.addEventListener("click", function () {{
|
|
1554
|
-
document.querySelectorAll(".filters button").forEach(function (x) {{ x.classList.remove("on"); }});
|
|
1555
|
-
b.classList.add("on");
|
|
1556
|
-
cond = b.getAttribute("data-cond") || "";
|
|
1557
|
-
apply();
|
|
1558
|
-
}});
|
|
1559
|
-
}});
|
|
1560
|
-
var search = document.querySelector(".src-search");
|
|
1561
|
-
if (search) search.addEventListener("input", function () {{ kw = search.value.trim().toLowerCase(); apply(); }});
|
|
1562
|
-
}})();
|
|
1563
|
-
</script>
|
|
2366
|
+
<script>{PAGE_JS}</script>
|
|
1564
2367
|
</body>
|
|
1565
2368
|
</html>"""
|
|
1566
2369
|
|
|
@@ -1593,17 +2396,37 @@ def main() -> None:
|
|
|
1593
2396
|
parser.add_argument("--question", default="", help="用户需求,用于自动生成文件名。")
|
|
1594
2397
|
parser.add_argument("--stage", choices=["outline", "final"], default="final",
|
|
1595
2398
|
help="报告版本:outline 提纲版(确认门前事前核验)/ final 成稿版(交付时事后溯源),默认 final。")
|
|
2399
|
+
parser.add_argument("--skip-link-check", action="store_true",
|
|
2400
|
+
help="跳过原文链接活性检测(默认检测:404/410 含软 404 标记失效)")
|
|
2401
|
+
parser.add_argument("--disable-snapshot", action="store_true",
|
|
2402
|
+
help="关闭快照兜底展示(默认启用:原文失效时以存档快照回看)")
|
|
1596
2403
|
args = parser.parse_args()
|
|
2404
|
+
if args.disable_snapshot:
|
|
2405
|
+
global SNAPSHOT_ENABLED
|
|
2406
|
+
SNAPSHOT_ENABLED = False
|
|
1597
2407
|
|
|
1598
2408
|
payload = load_json(_safe_input_path(args.input_json, {".json"}))
|
|
1599
2409
|
answer_override = ""
|
|
1600
2410
|
if args.answer_file:
|
|
1601
2411
|
answer_override = _safe_input_path(args.answer_file, {".txt", ".md"}).read_text(encoding="utf-8")
|
|
1602
2412
|
question = args.question.strip() or extract_question(unwrap(payload))
|
|
2413
|
+
unwrapped = unwrap(payload)
|
|
2414
|
+
|
|
2415
|
+
# 原文链接活性检测 + 快照兜底(就地改写原始材料 dict:链接失效=True / 快照链接 规范化)
|
|
2416
|
+
raw_articles = collect_raw_articles(unwrapped)
|
|
2417
|
+
if not args.skip_link_check and raw_articles:
|
|
2418
|
+
dead = mark_dead_links(raw_articles)
|
|
2419
|
+
if dead:
|
|
2420
|
+
print(f"链接检测:{dead} 条原文链接已失效(404/410),将改用存档快照或如实标注")
|
|
2421
|
+
if SNAPSHOT_ENABLED and raw_articles:
|
|
2422
|
+
fixed, dropped = apply_snapshots(raw_articles)
|
|
2423
|
+
total_snap = sum(1 for a in raw_articles if (a.get("快照链接") or "").strip())
|
|
2424
|
+
if total_snap or fixed or dropped:
|
|
2425
|
+
print(f"快照校验:{total_snap} 条路径合法放行(补全 /A/ {fixed} 条)/ 弃用 {dropped} 条非法路径(不做网络检测)")
|
|
1603
2426
|
|
|
1604
2427
|
# 生成前硬校验:有素材而正文无角标时拒绝生成,杜绝产出无核验对应的报告
|
|
1605
|
-
pre_answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(
|
|
1606
|
-
pre_sources = extract_sources(
|
|
2428
|
+
pre_answer = normalize_citations(answer_override) if answer_override.strip() else extract_answer(unwrapped)
|
|
2429
|
+
pre_sources = extract_sources(unwrapped)
|
|
1607
2430
|
if pre_sources and not citation_ids(pre_answer):
|
|
1608
2431
|
print("生成检查未通过:答案正文没有任何 [N] 来源角标,无法建立\"结论-素材\"核验对应。", file=sys.stderr)
|
|
1609
2432
|
print(f"请修正答案文件({'提纲版 _outline.md:页面规划表事实要点' if args.stage == 'outline' else '成稿版 _answer.txt:页面级结论文本'}"
|
|
@@ -1614,7 +2437,7 @@ def main() -> None:
|
|
|
1614
2437
|
if citation_ids(pre_answer) and not pre_sources:
|
|
1615
2438
|
print("生成检查未通过:输入 JSON 未识别到任何素材,但正文包含 [N] 角标。", file=sys.stderr)
|
|
1616
2439
|
print("请检查合并 JSON 结构:素材数组须为顶层 {\"检索文章\": [...]} 或原始接口的 content.data.检索文章 形态;"
|
|
1617
|
-
"
|
|
2440
|
+
"self_check/verification_checks 放顶层。修正后重新运行本脚本。", file=sys.stderr)
|
|
1618
2441
|
raise SystemExit(2)
|
|
1619
2442
|
|
|
1620
2443
|
generated_at = datetime.now()
|
|
@@ -1622,6 +2445,7 @@ def main() -> None:
|
|
|
1622
2445
|
output = _safe_output_path(args.output, {".html", ".htm"}, ".html")
|
|
1623
2446
|
else:
|
|
1624
2447
|
output = _safe_output_path(safe_output_filename(question, generated_at), {".html", ".htm"}, ".html")
|
|
2448
|
+
output = _next_version_path(output)
|
|
1625
2449
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
1626
2450
|
output.write_text(render_html(payload, args.title, answer_override=answer_override,
|
|
1627
2451
|
question_override=args.question, generated_at=generated_at, stage=args.stage), encoding="utf-8")
|
|
@@ -1630,6 +2454,7 @@ def main() -> None:
|
|
|
1630
2454
|
clean_output = _safe_output_path(args.clean_md_output, {".md"}, ".md")
|
|
1631
2455
|
else:
|
|
1632
2456
|
clean_output = _safe_output_path(output.with_suffix(".clean.md").name, {".md"}, ".md")
|
|
2457
|
+
clean_output = _next_version_path(clean_output)
|
|
1633
2458
|
clean_output.parent.mkdir(parents=True, exist_ok=True)
|
|
1634
2459
|
clean_answer = strip_citation_markers(answer_override or extract_answer(unwrap(payload)))
|
|
1635
2460
|
clean_output.write_text(clean_answer, encoding="utf-8")
|