release: 发布 v0.6.2 DOCX 真实文档修复

新增能力:将 DOCX 发布验收拆分为四套独立 140,支持真实语料冻结、指纹复用、失败与基础设施错误独立统计,并为表格换行、全 JSON 围栏、代码连续性和长文档分页建立通用门禁。

问题修复:冻结 Paged.js 分片前的逻辑表格列轨并传递打印几何,统一 Markdown 表格换行、代码、段落与 OOXML 翻译;改进 PDF 文本流排序、语义块映射、颜色与栅格比较,消除窄字符重叠和跨行范围符号误报。

兼容与部署:版本统一为 0.6.2;正式 Docker 镜像内置固定 Chromium、Pandoc 3.9.0.2 和 Serif/Sans/Mono 字体;Desktop NSIS 与 ZIP 继续直接内置字体,无需系统字体安装。

验证结果:合成基线与长庆严格 280/280,M4N 140/140;健康数据残余误报 6/115(5.22%),均核查为重复表头自动对齐/取样误报且基础设施错误为 0。全项目测试、类型检查、生产构建和 git diff --check 通过;正式 Docker、NSIS、ZIP、离线镜像、部署包、清单及 SHA-256 均已生成并校验。
This commit is contained in:
SkyJourney
2026-08-26 10:50:20 +08:00
parent 01b06abc2c
commit 64445322eb
75 changed files with 9255 additions and 298 deletions
@@ -41,6 +41,9 @@ export function readDocxComputedStyle(
fontStyle: style.fontStyle,
color: style.color,
backgroundColor: style.backgroundColor,
...(style.backgroundImage
? { backgroundImage: style.backgroundImage }
: {}),
lineHeight: style.lineHeight,
letterSpacing: style.letterSpacing,
textAlign: style.textAlign,
@@ -79,6 +79,25 @@ export function parseCssColor(
);
}
export function parseCssLinearGradientFallbackColor(
input: string
): string | undefined {
const value = input.trim();
if (!/^(?:repeating-)?linear-gradient\(/iu.test(value)) {
return undefined;
}
const colorValues = value.match(
/rgba?\([^)]*\)|#[\da-f]{3,8}/giu
) ?? [];
for (const colorValue of colorValues) {
const parsed = parseCssColor(colorValue);
if (parsed) {
return parsed;
}
}
return undefined;
}
function parseAlpha(value: string | undefined): number | undefined {
if (value === undefined) {
return undefined;
@@ -7,6 +7,7 @@ import {
millimetersToPoints,
parseCssBorder,
parseCssColor,
parseCssLinearGradientFallbackColor,
parseCssFontFamilies,
parseCssLengthToPt,
roundDocxValue
@@ -292,6 +293,20 @@ function normalizeComputedSlot(
);
if (background) {
style.backgroundColor = background;
} else if (computed.backgroundImage) {
const gradientBackground = parseCssLinearGradientFallbackColor(
computed.backgroundImage
);
if (gradientBackground) {
style.backgroundColor = gradientBackground;
diagnostic(context, {
severity: "info",
code: "layout-approximated",
property: "background-image",
message: "CSS 线性渐变已使用首个非透明色近似为 Word 段落底纹"
});
context.approximate = true;
}
}
const letterSpacing = computed.letterSpacing.toLowerCase() === "normal"
? 0
+1 -1
View File
@@ -35,7 +35,7 @@ export function createDocxStyleProbeMarkup(): string {
<ul ${attribute("unordered-list")}><li ${attribute("list-item")}>无序列表</li></ul>
<ol ${attribute("ordered-list")}><li>有序列表</li></ol>
<blockquote ${attribute("block-quote")}><p ${attribute("block-quote-text")}>引用内容</p></blockquote>
<pre class="md-fences" ${attribute("code-block")}><code class="language-javascript" ${attribute("code-block-text")}><span class="hljs-keyword" ${attribute("code-token-keyword")}>const</span> <span class="hljs-attr" ${attribute("code-token-attribute")}>key</span> <span class="hljs-operator" ${attribute("code-token-operator")}>=</span> <span class="hljs-string" ${attribute("code-token-string")}>&quot;value&quot;</span>; <span class="hljs-literal" ${attribute("code-token-literal")}>true</span> <span class="hljs-title" ${attribute("code-token-title")}>title</span> <span class="hljs-number" ${attribute("code-token-number")}>1</span> <span class="hljs-comment" ${attribute("code-token-comment")}>// comment</span> <span class="hljs-built_in" ${attribute("code-token-built-in")}>Array</span> <span class="hljs-meta" ${attribute("code-token-meta")}>@meta</span> <span class="hljs-variable" ${attribute("code-token-variable")}>value</span> <span class="hljs-regexp" ${attribute("code-token-regexp")}>/x/</span> <span class="hljs-punctuation" ${attribute("code-token-punctuation")}>{}</span></code></pre>
<pre class="md-fences" ${attribute("code-block")}><code class="language-javascript" ${attribute("code-block-text")}><span class="hljs-keyword" ${attribute("code-token-keyword")}>const</span> <span class="hljs-attr" ${attribute("code-token-attribute")}>key</span> <span class="hljs-operator" ${attribute("code-token-operator")}>=</span> <span class="hljs-string" ${attribute("code-token-string")}>&quot;value&quot;</span>; <span class="hljs-literal" ${attribute("code-token-literal")}>true</span> <span class="hljs-title" ${attribute("code-token-title")}>title</span> <span class="hljs-number" ${attribute("code-token-number")}>1</span> <span class="hljs-comment" ${attribute("code-token-comment")}>// comment</span> <span class="hljs-built_in" ${attribute("code-token-built-in")}>Array</span> <span class="hljs-meta" ${attribute("code-token-meta")}>@meta</span> <span class="hljs-variable" ${attribute("code-token-variable")}>value</span> <span class="hljs-regexp" ${attribute("code-token-regexp")}>/x/</span> <span class="hljs-punctuation" ${attribute("code-token-punctuation")}>{}</span> <span class="hljs-name" ${attribute("code-token-name")}>section</span></code></pre>
<table ${attribute("table")}>
<thead><tr><th ${attribute("table-header")}>表头</th></tr></thead>
<tbody><tr><td ${attribute("table-cell")}>单元格</td></tr></tbody>
@@ -55,6 +55,7 @@ const computedProperties = [
"fontStyle",
"color",
"backgroundColor",
"backgroundImage",
"lineHeight",
"letterSpacing",
"textAlign",
+2
View File
@@ -35,6 +35,7 @@ export const DOCX_STYLE_SLOT_NAMES = [
"code-token-operator",
"code-token-regexp",
"code-token-punctuation",
"code-token-name",
"table",
"table-header",
"table-cell",
@@ -153,6 +154,7 @@ const kinds: Record<DocxStyleSlotName, DocxStyleSlotKind> = {
"code-token-operator": "inline",
"code-token-regexp": "inline",
"code-token-punctuation": "inline",
"code-token-name": "inline",
table: "table",
"table-header": "table",
"table-cell": "table",
@@ -10,6 +10,7 @@ export const docxComputedStyleSchema = z.object({
fontStyle: cssValueSchema,
color: cssValueSchema,
backgroundColor: cssValueSchema,
backgroundImage: cssValueSchema.optional(),
lineHeight: cssValueSchema,
letterSpacing: cssValueSchema,
textAlign: cssValueSchema,
@@ -4,6 +4,7 @@ import {
millimetersToPoints,
parseCssBorder,
parseCssColor,
parseCssLinearGradientFallbackColor,
parseCssFontFamilies,
parseCssLengthToPt,
resolveDocxThemeTokens,
@@ -106,6 +107,12 @@ describe("CSS 到 Word 基础值归一化", () => {
expect(parseCssColor("rgba(0, 0, 0, 0)")).toBeUndefined();
expect(parseCssColor("rgba(255, 0, 0, 0.5)")).toBe("#ff8080");
expect(parseCssColor("#00000080")).toBe("#7f7f7f");
expect(parseCssLinearGradientFallbackColor(
"linear-gradient(90deg, rgb(239, 246, 255), rgba(0, 0, 0, 0))"
)).toBe("#eff6ff");
expect(parseCssLinearGradientFallbackColor(
"radial-gradient(rgb(239, 246, 255), transparent)"
)).toBeUndefined();
expect(
parseCssFontFamilies(
'"Source Han Serif SC", "Microsoft YaHei", serif'
@@ -185,6 +192,32 @@ describe("DOCX 主题令牌归一化", () => {
expect(tokens.slots).toHaveLength(DOCX_STYLE_SLOT_NAMES.length);
});
it("将线性渐变首个实色近似为 Word 段落底纹", () => {
const tokens = resolveDocxThemeTokens({
snapshot: createSnapshot({
"heading-2": {
backgroundColor: "rgba(0, 0, 0, 0)",
backgroundImage:
"linear-gradient(90deg, rgb(239, 246, 255), rgba(0, 0, 0, 0))"
}
}),
config: {
mode: "auto",
basePreset: "general",
overrides: {},
legacyPreset: false
}
});
expect(findSlot(tokens, "heading-2").style.backgroundColor)
.toBe("#eff6ff");
expect(tokens.diagnostics).toContainEqual(expect.objectContaining({
slot: "heading-2",
code: "layout-approximated",
property: "background-image"
}));
});
it("按 border-box 文档的内容区宽度归一化全宽表格", () => {
const tokens = resolveDocxThemeTokens({
snapshot: createSnapshot({