feat: 实现动态 DOCX 模板与样式映射

This commit is contained in:
SkyJourney
2026-07-30 14:10:43 +08:00
parent fe5d67fb6d
commit fa159d916f
41 changed files with 3610 additions and 7 deletions
@@ -1,6 +1,7 @@
import { readFile, readdir } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
import { docxThemeStyleSchema } from "@md-to-pdf/core";
const bundledThemeNames = {
"typora-github": "Typora Github",
@@ -83,6 +84,22 @@ describe("内置主题清单", () => {
}
});
it("每个内置主题声明可校验的 DOCX 样式预设", async () => {
const themesRoot = fileURLToPath(
new URL("../../../themes/", import.meta.url)
);
for (const id of Object.keys(bundledThemeNames)) {
const manifest = JSON.parse(
await readFile(`${themesRoot}${id}/theme.json`, "utf8")
) as { docxStyle?: unknown };
expect(
docxThemeStyleSchema.safeParse(manifest.docxStyle).success
).toBe(true);
}
});
it("为红头主题声明分类与兼容的结构化文档", async () => {
const themesRoot = fileURLToPath(
new URL("../../../themes/", import.meta.url)