release: 发布 v0.6.1 DOCX 视觉一致性修复
新增通用 CSS 到 OOXML 翻译修复,统一字体、字距、精确行距、段落、列表、表格、引用、代码块与行内代码连续性,不引入按主题 ID 分支。 新增 MdTP Mono 并统一 Serif、Sans、Mono 三字体包的 Chromium 与 DOCX 使用链;字体声明、嵌入部件和 Word/WPS 实际采用均进入硬门禁。 重建封面整页及正文语义块视觉差分,14 套主题、纵横两个方向、五组页边距共 140 个真实场景全部通过,阻断失败和诊断失败均为零。 源码服务、Docker Web API 与实际安装 Desktop 的 red-briefing 导出均包含 5 个字体部件;Word/WPS 原生渲染和逐页复核通过。修复 Docker 构建上下文与运行层复用软链接,并完善 v0.6.1 版本、发行说明和发布归集。 验证:npm test(116 个文件、616 项测试)、npm run typecheck、npm run build、git diff --check 全部通过。Desktop 安装器与 ZIP、Docker v0.6.1 镜像已生成;Windows 产物仍为未签名内部发行。
This commit is contained in:
@@ -59,6 +59,95 @@ function expectation(
|
||||
}
|
||||
|
||||
describe("PDF 内容感知段落版式门禁", () => {
|
||||
it("同一物理行中的表格单元格分别保留自己的视觉边界", () => {
|
||||
const tableLine = line("建设内容 主要能力", 220, 320, 72);
|
||||
tableLine.items = [
|
||||
{
|
||||
text: "建设内容",
|
||||
normalizedText: "建设内容",
|
||||
bounds: { x: 72, y: 210, width: 48, height: 12 },
|
||||
baselineY: 220,
|
||||
fontFamily: "Test Serif",
|
||||
hasEol: false,
|
||||
},
|
||||
{
|
||||
text: "主要能力",
|
||||
normalizedText: "主要能力",
|
||||
bounds: { x: 240, y: 210, width: 48, height: 12 },
|
||||
baselineY: 220,
|
||||
fontFamily: "Test Serif",
|
||||
hasEol: true,
|
||||
},
|
||||
];
|
||||
const paragraphs = [
|
||||
expectation("建设内容", { index: 0, blockKind: "table-header" }),
|
||||
expectation("主要能力", { index: 1, blockKind: "table-header" }),
|
||||
];
|
||||
const results = comparePdfEditableParagraphLayouts(
|
||||
snapshot("baseline", [[tableLine]]),
|
||||
snapshot("candidate", [[tableLine]]),
|
||||
paragraphs,
|
||||
);
|
||||
|
||||
expect(results[0]?.baseline.visualLines[0]?.bounds).toEqual(
|
||||
tableLine.items[0]?.bounds,
|
||||
);
|
||||
expect(results[1]?.baseline.visualLines[0]?.bounds).toEqual(
|
||||
tableLine.items[1]?.bounds,
|
||||
);
|
||||
});
|
||||
|
||||
it("按字符类别估算合并文本项中的有序列表正文边界", () => {
|
||||
const listLine = line("3.系统联调", 220, 100, 100);
|
||||
listLine.items = [
|
||||
{
|
||||
text: "3. 系统联调",
|
||||
normalizedText: "3. 系统联调",
|
||||
bounds: { x: 100, y: 210, width: 100, height: 12 },
|
||||
baselineY: 220,
|
||||
fontFamily: "Test Serif",
|
||||
hasEol: true,
|
||||
},
|
||||
];
|
||||
const [result] = comparePdfEditableParagraphLayouts(
|
||||
snapshot("baseline", [[listLine]]),
|
||||
snapshot("candidate", [[listLine]]),
|
||||
[expectation("系统联调", { blockKind: "list-item" })],
|
||||
);
|
||||
|
||||
expect(result?.baseline.visualLines[0]?.bounds.x).toBeCloseTo(117.18, 1);
|
||||
expect(result?.baseline.visualLines[0]?.bounds.width).toBeCloseTo(82.82, 1);
|
||||
});
|
||||
|
||||
it("跳过被无关字符打断的相似文本并匹配后续完整段落", () => {
|
||||
const [result] = comparePdfEditableParagraphLayouts(
|
||||
snapshot("baseline", [[
|
||||
line("甲X乙", 180),
|
||||
line("甲乙", 220),
|
||||
]]),
|
||||
snapshot("candidate", [[
|
||||
line("甲X乙", 180),
|
||||
line("甲乙", 220),
|
||||
]]),
|
||||
[expectation("甲乙")],
|
||||
);
|
||||
|
||||
expect(result?.status).toBe("passed");
|
||||
expect(result?.baseline.firstLineBaselineYPt).toBe(220);
|
||||
expect(result?.candidate.firstLineBaselineYPt).toBe(220);
|
||||
});
|
||||
|
||||
it("连续段落可以自然跨越多个 PDF 视觉行", () => {
|
||||
const [result] = comparePdfEditableParagraphLayouts(
|
||||
snapshot("baseline", [[line("甲乙", 180), line("丙丁", 204)]]),
|
||||
snapshot("candidate", [[line("甲乙", 180), line("丙丁", 204)]]),
|
||||
[expectation("甲乙丙丁")],
|
||||
);
|
||||
|
||||
expect(result?.status).toBe("passed");
|
||||
expect(result?.baseline.lineTexts).toEqual(["甲乙", "丙丁"]);
|
||||
});
|
||||
|
||||
it("允许正文段落整体移动到下一物理页", () => {
|
||||
const baseline = snapshot("baseline", [
|
||||
[line("建立月度调度机制及时协调", 700), line("解决项目中的问题", 728)],
|
||||
@@ -123,6 +212,30 @@ describe("PDF 内容感知段落版式门禁", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("正文块行数不变时允许三个字符以内的流式行内重排", () => {
|
||||
const baseline = snapshot("baseline", [[
|
||||
line("甲乙丙丁", 220),
|
||||
line("戊己庚辛", 244),
|
||||
]]);
|
||||
const candidate = snapshot("candidate", [[
|
||||
line("甲乙丙丁戊己", 220),
|
||||
line("庚辛", 244),
|
||||
]]);
|
||||
const [result] = comparePdfEditableParagraphLayouts(
|
||||
baseline,
|
||||
candidate,
|
||||
[expectation("甲乙丙丁戊己庚辛", { blockKind: "paragraph" })],
|
||||
);
|
||||
|
||||
expect(result?.status).toBe("warning");
|
||||
expect(result?.issues).toContainEqual(
|
||||
expect.objectContaining({
|
||||
code: "PARAGRAPH_LINE_BREAK_MISMATCH",
|
||||
severity: "warning",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("拒绝短正文或非极短末行的行数差异", () => {
|
||||
const text = "项目建设内容需要严格控制质量进度投资安全风险";
|
||||
const baseline = snapshot("baseline", [
|
||||
|
||||
Reference in New Issue
Block a user