@illusions-lab/mdi-to-docx 2.0.6 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +13 -7
- package/dist/index.js +14 -8
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -28,12 +28,9 @@ var import_docx = require("docx");
|
|
|
28
28
|
var import_mdi_export_profile = require("@illusions-lab/mdi-export-profile");
|
|
29
29
|
var MDI_SPEC_VERSION = "2.0";
|
|
30
30
|
async function mdiToDocx(tree, profile) {
|
|
31
|
-
const options = (0, import_mdi_export_profile.
|
|
32
|
-
profile
|
|
33
|
-
|
|
34
|
-
writingMode: tree.data?.frontmatter?.writingMode === "vertical" ? "vertical" : "horizontal"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
31
|
+
const options = (0, import_mdi_export_profile.resolvePrintProfile)(
|
|
32
|
+
profile,
|
|
33
|
+
tree.data?.frontmatter?.writingMode
|
|
37
34
|
);
|
|
38
35
|
const children = tree.children.flatMap((node) => block(node, options));
|
|
39
36
|
const dimensions = import_mdi_export_profile.PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
@@ -57,7 +54,13 @@ async function mdiToDocx(tree, profile) {
|
|
|
57
54
|
size: fontSizeHalfPoints
|
|
58
55
|
},
|
|
59
56
|
paragraph: { spacing: { line: lineTwips } }
|
|
60
|
-
}
|
|
57
|
+
},
|
|
58
|
+
heading1: { run: headingRun(options) },
|
|
59
|
+
heading2: { run: headingRun(options) },
|
|
60
|
+
heading3: { run: headingRun(options) },
|
|
61
|
+
heading4: { run: headingRun(options) },
|
|
62
|
+
heading5: { run: headingRun(options) },
|
|
63
|
+
heading6: { run: headingRun(options) }
|
|
61
64
|
}
|
|
62
65
|
},
|
|
63
66
|
sections: [
|
|
@@ -84,6 +87,9 @@ async function mdiToDocx(tree, profile) {
|
|
|
84
87
|
});
|
|
85
88
|
return import_docx.Packer.toBuffer(document);
|
|
86
89
|
}
|
|
90
|
+
function headingRun(options) {
|
|
91
|
+
return { font: options.typesetting.fontFamily, color: "000000" };
|
|
92
|
+
}
|
|
87
93
|
function pageNumberSection(options, size) {
|
|
88
94
|
const page = options.pagination.pageNumbers;
|
|
89
95
|
if (!page.enabled) return {};
|
package/dist/index.js
CHANGED
|
@@ -15,16 +15,13 @@ import {
|
|
|
15
15
|
} from "docx";
|
|
16
16
|
import {
|
|
17
17
|
PAGE_DIMENSIONS,
|
|
18
|
-
|
|
18
|
+
resolvePrintProfile
|
|
19
19
|
} from "@illusions-lab/mdi-export-profile";
|
|
20
20
|
var MDI_SPEC_VERSION = "2.0";
|
|
21
21
|
async function mdiToDocx(tree, profile) {
|
|
22
|
-
const options =
|
|
23
|
-
profile
|
|
24
|
-
|
|
25
|
-
writingMode: tree.data?.frontmatter?.writingMode === "vertical" ? "vertical" : "horizontal"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
22
|
+
const options = resolvePrintProfile(
|
|
23
|
+
profile,
|
|
24
|
+
tree.data?.frontmatter?.writingMode
|
|
28
25
|
);
|
|
29
26
|
const children = tree.children.flatMap((node) => block(node, options));
|
|
30
27
|
const dimensions = PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
@@ -48,7 +45,13 @@ async function mdiToDocx(tree, profile) {
|
|
|
48
45
|
size: fontSizeHalfPoints
|
|
49
46
|
},
|
|
50
47
|
paragraph: { spacing: { line: lineTwips } }
|
|
51
|
-
}
|
|
48
|
+
},
|
|
49
|
+
heading1: { run: headingRun(options) },
|
|
50
|
+
heading2: { run: headingRun(options) },
|
|
51
|
+
heading3: { run: headingRun(options) },
|
|
52
|
+
heading4: { run: headingRun(options) },
|
|
53
|
+
heading5: { run: headingRun(options) },
|
|
54
|
+
heading6: { run: headingRun(options) }
|
|
52
55
|
}
|
|
53
56
|
},
|
|
54
57
|
sections: [
|
|
@@ -75,6 +78,9 @@ async function mdiToDocx(tree, profile) {
|
|
|
75
78
|
});
|
|
76
79
|
return Packer.toBuffer(document);
|
|
77
80
|
}
|
|
81
|
+
function headingRun(options) {
|
|
82
|
+
return { font: options.typesetting.fontFamily, color: "000000" };
|
|
83
|
+
}
|
|
78
84
|
function pageNumberSection(options, size) {
|
|
79
85
|
const page = options.pagination.pageNumbers;
|
|
80
86
|
if (!page.enabled) return {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@illusions-lab/mdi-to-docx",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Render MDI (.mdi) documents to DOCX",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"docx": "^9.0.0",
|
|
27
27
|
"@types/mdast": "^4.0.0",
|
|
28
|
-
"@illusions-lab/mdi-export-profile": "2.0.
|
|
29
|
-
"mdast-util-mdi": "2.0.
|
|
28
|
+
"@illusions-lab/mdi-export-profile": "2.0.3",
|
|
29
|
+
"mdast-util-mdi": "2.0.7"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"remark-parse": "^11.0.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"typescript": "^5.6.0",
|
|
37
37
|
"vitest": "^2.1.0",
|
|
38
38
|
"@types/node": "^20.0.0",
|
|
39
|
-
"@illusions-lab/mdi-remark": "2.0.
|
|
39
|
+
"@illusions-lab/mdi-remark": "2.0.8"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|