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
@@ -9,6 +9,7 @@ import {
PandocDocxConverter,
PandocRuntime
} from "@md-to-pdf/docx-engine";
import { DOCX_STYLE_SLOT_NAMES } from "@md-to-pdf/docx-theme-engine";
import { unzipSync } from "fflate";
const directory = path.dirname(fileURLToPath(import.meta.url));
@@ -76,6 +77,20 @@ const runtime = new PandocRuntime(
: {}
);
const converter = new PandocDocxConverter({ runtime });
const themeTokens = {
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 conversionInput = {
markdown,
fileName: "Pandoc 媒体转换验收.md",
@@ -85,6 +100,7 @@ const conversionInput = {
themeId: theme.id
},
theme,
themeTokens,
metadata: {
title: "Pandoc 媒体转换验收",
author: "Markdown PDF 导出器研发组",
@@ -92,6 +108,14 @@ const conversionInput = {
keywords: [],
language: "zh-CN"
},
semanticDocument: {
schemaVersion: 1,
titlePolicy: {
metadataTitle: "emit",
firstBodyHeading: "keep"
},
regions: []
},
media: {
resources: [
resource("image", 1, { width: 384, height: 192 }),