feat: 新增报告协作页,并强化 Deep Research 运行诊断与报告兜底
支持浏览器侧素材快照撰写、拒绝报告读时修复、Mermaid PNG 导出与 Word 导出加固。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
65d6b61d5d
commit
f109a95535
65 files changed
+10342
-245
No files matched your search
@@ -1,7 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import io
|
||||
import re
|
||||
import sys
|
||||
import zipfile
|
||||
@@ -115,6 +117,41 @@ def test_formal_docx_contains_required_layout_numbering_and_embedded_font(tmp_pa
|
||||
assert " PAGE " in default_footer and " PAGE " in even_footer
|
||||
|
||||
|
||||
_TINY_PNG = base64.b64decode(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
|
||||
)
|
||||
|
||||
|
||||
def test_embedded_png_is_written_into_docx_media() -> None:
|
||||
markdown = "正文前\n\n\n\n正文后"
|
||||
payload = word_export.build_markdown_docx(
|
||||
markdown,
|
||||
embedded_images={"mermaid-1": base64.b64encode(_TINY_PNG).decode("ascii")},
|
||||
)
|
||||
|
||||
with zipfile.ZipFile(io.BytesIO(payload)) as archive:
|
||||
assert archive.read("word/media/image1.png") == _TINY_PNG
|
||||
document = archive.read("word/document.xml").decode("utf-8")
|
||||
rels = archive.read("word/_rels/document.xml.rels").decode("utf-8")
|
||||
types = archive.read("[Content_Types].xml").decode("utf-8")
|
||||
assert "<w:drawing>" in document
|
||||
assert 'w:lineRule="auto"' in document
|
||||
assert "flowchart TB" not in document
|
||||
assert 'Target="media/image1.png"' in rels
|
||||
assert 'Extension="png"' in types
|
||||
|
||||
|
||||
def test_mermaid_fence_without_image_stays_code() -> None:
|
||||
markdown = "```mermaid\nflowchart TB\nA-->B\n```"
|
||||
payload = word_export.build_markdown_docx(markdown)
|
||||
|
||||
with zipfile.ZipFile(io.BytesIO(payload)) as archive:
|
||||
document = archive.read("word/document.xml").decode("utf-8")
|
||||
assert "flowchart TB" in document
|
||||
assert "<w:drawing>" not in document
|
||||
assert "word/media/image1.png" not in archive.namelist()
|
||||
|
||||
|
||||
def test_export_rejects_wrong_font(tmp_path: Path) -> None:
|
||||
wrong_font = tmp_path / "wrong.ttf"
|
||||
wrong_font.write_bytes(b"not-a-font")
|
||||
|
||||
Reference in new issue
Block a user