feat: 完成 DOCX 通用结构映射与严格收口

This commit is contained in:
SkyJourney
2026-07-31 15:19:34 +08:00
parent 6e40374200
commit f3847f3e4b
31 changed files with 3175 additions and 64 deletions
@@ -11,6 +11,7 @@ import {
PandocRuntime,
inspectDocxAcceptance
} from "@md-to-pdf/docx-engine";
import { DOCX_STYLE_SLOT_NAMES } from "@md-to-pdf/docx-theme-engine";
const directory = path.dirname(fileURLToPath(import.meta.url));
const packageDirectory = path.resolve(directory, "..");
@@ -95,6 +96,23 @@ function createMedia() {
};
}
function createThemeTokens(theme) {
return {
schemaVersion: 1,
themeId: theme.id,
themeFingerprint: "c".repeat(64),
mode: "auto-with-overrides",
basePreset: theme.docxStyle?.preset ?? "general",
slots: DOCX_STYLE_SLOT_NAMES.map((slot) => ({
slot,
source: "preset-fallback",
confidence: "fallback",
style: { fontCandidates: [] }
})),
diagnostics: []
};
}
const technicalTheme = loadTheme("typora-like");
const officialTheme = loadTheme("gov-red-standard");
const commonExpectation = {
@@ -287,6 +305,7 @@ for (const variant of variants) {
language: "zh-CN",
exportConfig: variant.exportConfig,
theme: variant.theme,
themeTokens: createThemeTokens(variant.theme),
metadata: {
title: "v0.6.0 DOCX 自动验收",
author: "Markdown PDF 导出器研发组",
@@ -294,6 +313,14 @@ for (const variant of variants) {
keywords: ["DOCX", "Pandoc", "OOXML"],
language: "zh-CN"
},
semanticDocument: {
schemaVersion: 1,
titlePolicy: {
metadataTitle: "emit",
firstBodyHeading: "keep"
},
regions: []
},
media: createMedia()
});
const report = inspectDocxAcceptance(