@illusions-lab/mdi-to-docx 2.0.4 → 2.0.6
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 +140 -15
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +157 -16
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -25,37 +25,162 @@ __export(index_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
var import_docx = require("docx");
|
|
28
|
+
var import_mdi_export_profile = require("@illusions-lab/mdi-export-profile");
|
|
28
29
|
var MDI_SPEC_VERSION = "2.0";
|
|
29
|
-
async function mdiToDocx(tree) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
async function mdiToDocx(tree, profile) {
|
|
31
|
+
const options = (0, import_mdi_export_profile.resolveExportProfile)(
|
|
32
|
+
profile ?? {
|
|
33
|
+
typesetting: {
|
|
34
|
+
writingMode: tree.data?.frontmatter?.writingMode === "vertical" ? "vertical" : "horizontal"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
const children = tree.children.flatMap((node) => block(node, options));
|
|
39
|
+
const dimensions = import_mdi_export_profile.PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
40
|
+
const widthMm = options.pagination.landscape ? dimensions.height : dimensions.width;
|
|
41
|
+
const heightMm = options.pagination.landscape ? dimensions.width : dimensions.height;
|
|
42
|
+
const primary = options.typesetting.writingMode === "vertical" ? heightMm - options.pagination.margins.top - options.pagination.margins.bottom : widthMm - options.pagination.margins.left - options.pagination.margins.right;
|
|
43
|
+
const cross = options.typesetting.writingMode === "vertical" ? widthMm - options.pagination.margins.left - options.pagination.margins.right : heightMm - options.pagination.margins.top - options.pagination.margins.bottom;
|
|
44
|
+
const fontSizeMm = primary / options.pagination.charactersPerLine;
|
|
45
|
+
const fontSizeHalfPoints = Math.round(fontSizeMm / 25.4 * 72 * 2);
|
|
46
|
+
const lineTwips = Math.round(
|
|
47
|
+
cross / options.pagination.linesPerPage / 25.4 * 1440
|
|
48
|
+
);
|
|
49
|
+
const document = new import_docx.Document({
|
|
50
|
+
title: options.metadata.title ?? tree.data?.frontmatter?.title,
|
|
51
|
+
creator: options.metadata.author ?? tree.data?.frontmatter?.author,
|
|
52
|
+
styles: {
|
|
53
|
+
default: {
|
|
54
|
+
document: {
|
|
55
|
+
run: {
|
|
56
|
+
font: options.typesetting.fontFamily,
|
|
57
|
+
size: fontSizeHalfPoints
|
|
58
|
+
},
|
|
59
|
+
paragraph: { spacing: { line: lineTwips } }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
sections: [
|
|
64
|
+
{
|
|
65
|
+
...pageNumberSection(options, fontSizeHalfPoints),
|
|
66
|
+
properties: {
|
|
67
|
+
page: {
|
|
68
|
+
size: { width: mmToTwips(widthMm), height: mmToTwips(heightMm) },
|
|
69
|
+
margin: Object.fromEntries(
|
|
70
|
+
Object.entries(options.pagination.margins).map(([key, value]) => [
|
|
71
|
+
key,
|
|
72
|
+
mmToTwips(value)
|
|
73
|
+
])
|
|
74
|
+
),
|
|
75
|
+
...options.pagination.pageNumbers.enabled ? { pageNumbers: { start: 1 } } : {},
|
|
76
|
+
...options.typesetting.writingMode === "vertical" ? {
|
|
77
|
+
textDirection: import_docx.PageTextDirectionType.TOP_TO_BOTTOM_RIGHT_TO_LEFT
|
|
78
|
+
} : {}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
33
85
|
return import_docx.Packer.toBuffer(document);
|
|
34
86
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
87
|
+
function pageNumberSection(options, size) {
|
|
88
|
+
const page = options.pagination.pageNumbers;
|
|
89
|
+
if (!page.enabled) return {};
|
|
90
|
+
const alignment = page.position.endsWith("left") ? import_docx.AlignmentType.LEFT : page.position.endsWith("right") ? import_docx.AlignmentType.RIGHT : import_docx.AlignmentType.CENTER;
|
|
91
|
+
const current = new import_docx.TextRun({ children: [import_docx.PageNumber.CURRENT], size });
|
|
92
|
+
const runs = page.format === "dash" ? [
|
|
93
|
+
new import_docx.TextRun({ text: "\u2014 ", size }),
|
|
94
|
+
current,
|
|
95
|
+
new import_docx.TextRun({ text: " \u2014", size })
|
|
96
|
+
] : page.format === "fraction" ? [
|
|
97
|
+
current,
|
|
98
|
+
new import_docx.TextRun({ text: " / ", size }),
|
|
99
|
+
new import_docx.TextRun({ children: [import_docx.PageNumber.TOTAL_PAGES], size })
|
|
100
|
+
] : [current];
|
|
101
|
+
const paragraph2 = new import_docx.Paragraph({ alignment, children: runs });
|
|
102
|
+
return page.position.startsWith("top-") ? { headers: { default: new import_docx.Header({ children: [paragraph2] }) } } : { footers: { default: new import_docx.Footer({ children: [paragraph2] }) } };
|
|
103
|
+
}
|
|
104
|
+
function block(node, options) {
|
|
105
|
+
if (node.type === "heading")
|
|
106
|
+
return [
|
|
107
|
+
new import_docx.Paragraph({
|
|
108
|
+
heading: [
|
|
109
|
+
import_docx.HeadingLevel.HEADING_1,
|
|
110
|
+
import_docx.HeadingLevel.HEADING_2,
|
|
111
|
+
import_docx.HeadingLevel.HEADING_3,
|
|
112
|
+
import_docx.HeadingLevel.HEADING_4,
|
|
113
|
+
import_docx.HeadingLevel.HEADING_5,
|
|
114
|
+
import_docx.HeadingLevel.HEADING_6
|
|
115
|
+
][node.depth - 1],
|
|
116
|
+
children: inline(node.children)
|
|
117
|
+
})
|
|
118
|
+
];
|
|
119
|
+
if (node.type === "paragraph") return [paragraph(node.children, options)];
|
|
120
|
+
if (node.type === "list")
|
|
121
|
+
return node.children.flatMap(
|
|
122
|
+
(item) => item.children.filter((n) => n.type === "paragraph").map(
|
|
123
|
+
(n) => new import_docx.Paragraph({
|
|
124
|
+
children: inline(n.children),
|
|
125
|
+
bullet: { level: 0 }
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
);
|
|
129
|
+
if (node.type === "mdiPagebreak")
|
|
130
|
+
return [new import_docx.Paragraph({ children: [new import_docx.PageBreak()] })];
|
|
40
131
|
if (node.type === "mdiBlank") return [new import_docx.Paragraph("")];
|
|
41
132
|
return [];
|
|
42
133
|
}
|
|
134
|
+
function paragraph(nodes, options) {
|
|
135
|
+
const fontSizeMm = (() => {
|
|
136
|
+
const dimensions = import_mdi_export_profile.PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
137
|
+
const primary = options.typesetting.writingMode === "vertical" ? (options.pagination.landscape ? dimensions.width : dimensions.height) - options.pagination.margins.top - options.pagination.margins.bottom : (options.pagination.landscape ? dimensions.height : dimensions.width) - options.pagination.margins.left - options.pagination.margins.right;
|
|
138
|
+
return primary / options.pagination.charactersPerLine;
|
|
139
|
+
})();
|
|
140
|
+
const prefix = options.typesetting.fullwidthSpaceIndent ? [new import_docx.TextRun("\u3000".repeat(Math.round(options.typesetting.textIndentEm)))] : [];
|
|
141
|
+
return new import_docx.Paragraph({
|
|
142
|
+
indent: options.typesetting.fullwidthSpaceIndent ? void 0 : {
|
|
143
|
+
firstLine: Math.round(
|
|
144
|
+
options.typesetting.textIndentEm * fontSizeMm / 25.4 * 1440
|
|
145
|
+
)
|
|
146
|
+
},
|
|
147
|
+
children: [...prefix, ...inline(nodes)]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
43
150
|
function inline(nodes) {
|
|
44
151
|
return nodes.flatMap((node) => {
|
|
45
152
|
if (node.type === "text") return [new import_docx.TextRun(node.value)];
|
|
46
|
-
if (node.type === "break" || node.type === "mdiBreak")
|
|
47
|
-
|
|
48
|
-
if (node.type === "
|
|
49
|
-
|
|
153
|
+
if (node.type === "break" || node.type === "mdiBreak")
|
|
154
|
+
return [new import_docx.TextRun({ break: 1 })];
|
|
155
|
+
if (node.type === "emphasis")
|
|
156
|
+
return [new import_docx.TextRun({ italics: true, children: inline(node.children) })];
|
|
157
|
+
if (node.type === "strong")
|
|
158
|
+
return [new import_docx.TextRun({ bold: true, children: inline(node.children) })];
|
|
159
|
+
if (node.type === "delete")
|
|
160
|
+
return [new import_docx.TextRun({ strike: true, children: inline(node.children) })];
|
|
50
161
|
if (node.type === "mdiRuby") return [rawRun(rubyXml(node.base, node.ruby))];
|
|
51
|
-
if (node.type === "mdiTcy")
|
|
162
|
+
if (node.type === "mdiTcy")
|
|
163
|
+
return [
|
|
164
|
+
rawRun(
|
|
165
|
+
`<w:r><w:rPr><w:eastAsianLayout w:combine="1" w:combineBrackets="none"/></w:rPr><w:t>${xml(
|
|
166
|
+
node.value
|
|
167
|
+
)}</w:t></w:r>`
|
|
168
|
+
)
|
|
169
|
+
];
|
|
52
170
|
if ("children" in node) return inline(node.children);
|
|
53
171
|
return [];
|
|
54
172
|
});
|
|
55
173
|
}
|
|
174
|
+
function mmToTwips(mm) {
|
|
175
|
+
return Math.round(mm / 25.4 * 1440);
|
|
176
|
+
}
|
|
56
177
|
function rubyXml(base, reading) {
|
|
57
178
|
const text = Array.isArray(reading) ? reading.join(".") : reading;
|
|
58
|
-
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="center"/><w:hps w:val="12"/><w:hpsRaise w:val="18"/><w:hpsBaseText w:val="24"/></w:rubyPr><w:rt><w:r><w:t>${xml(
|
|
179
|
+
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="center"/><w:hps w:val="12"/><w:hpsRaise w:val="18"/><w:hpsBaseText w:val="24"/></w:rubyPr><w:rt><w:r><w:t>${xml(
|
|
180
|
+
text
|
|
181
|
+
)}</w:t></w:r></w:rt><w:rubyBase><w:r><w:t>${xml(
|
|
182
|
+
base
|
|
183
|
+
)}</w:t></w:r></w:rubyBase></w:ruby>`;
|
|
59
184
|
}
|
|
60
185
|
function rawRun(xmlString) {
|
|
61
186
|
return import_docx.ImportedXmlComponent.fromXmlString(xmlString);
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Root } from 'mdast';
|
|
2
|
+
import { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
2
3
|
|
|
3
4
|
declare const MDI_SPEC_VERSION = "2.0";
|
|
4
|
-
|
|
5
|
+
/** Creates a DOCX file using the same profile fields as PDF and EPUB exports. */
|
|
6
|
+
declare function mdiToDocx(tree: Root, profile?: ExportProfile): Promise<Buffer>;
|
|
5
7
|
|
|
6
8
|
export { MDI_SPEC_VERSION, mdiToDocx };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Root } from 'mdast';
|
|
2
|
+
import { ExportProfile } from '@illusions-lab/mdi-export-profile';
|
|
2
3
|
|
|
3
4
|
declare const MDI_SPEC_VERSION = "2.0";
|
|
4
|
-
|
|
5
|
+
/** Creates a DOCX file using the same profile fields as PDF and EPUB exports. */
|
|
6
|
+
declare function mdiToDocx(tree: Root, profile?: ExportProfile): Promise<Buffer>;
|
|
5
7
|
|
|
6
8
|
export { MDI_SPEC_VERSION, mdiToDocx };
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,177 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AlignmentType,
|
|
4
|
+
Document,
|
|
5
|
+
Footer,
|
|
6
|
+
HeadingLevel,
|
|
7
|
+
Header,
|
|
8
|
+
ImportedXmlComponent,
|
|
9
|
+
Packer,
|
|
10
|
+
PageBreak,
|
|
11
|
+
PageNumber,
|
|
12
|
+
PageTextDirectionType,
|
|
13
|
+
Paragraph,
|
|
14
|
+
TextRun
|
|
15
|
+
} from "docx";
|
|
16
|
+
import {
|
|
17
|
+
PAGE_DIMENSIONS,
|
|
18
|
+
resolveExportProfile
|
|
19
|
+
} from "@illusions-lab/mdi-export-profile";
|
|
3
20
|
var MDI_SPEC_VERSION = "2.0";
|
|
4
|
-
async function mdiToDocx(tree) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
21
|
+
async function mdiToDocx(tree, profile) {
|
|
22
|
+
const options = resolveExportProfile(
|
|
23
|
+
profile ?? {
|
|
24
|
+
typesetting: {
|
|
25
|
+
writingMode: tree.data?.frontmatter?.writingMode === "vertical" ? "vertical" : "horizontal"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
const children = tree.children.flatMap((node) => block(node, options));
|
|
30
|
+
const dimensions = PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
31
|
+
const widthMm = options.pagination.landscape ? dimensions.height : dimensions.width;
|
|
32
|
+
const heightMm = options.pagination.landscape ? dimensions.width : dimensions.height;
|
|
33
|
+
const primary = options.typesetting.writingMode === "vertical" ? heightMm - options.pagination.margins.top - options.pagination.margins.bottom : widthMm - options.pagination.margins.left - options.pagination.margins.right;
|
|
34
|
+
const cross = options.typesetting.writingMode === "vertical" ? widthMm - options.pagination.margins.left - options.pagination.margins.right : heightMm - options.pagination.margins.top - options.pagination.margins.bottom;
|
|
35
|
+
const fontSizeMm = primary / options.pagination.charactersPerLine;
|
|
36
|
+
const fontSizeHalfPoints = Math.round(fontSizeMm / 25.4 * 72 * 2);
|
|
37
|
+
const lineTwips = Math.round(
|
|
38
|
+
cross / options.pagination.linesPerPage / 25.4 * 1440
|
|
39
|
+
);
|
|
40
|
+
const document = new Document({
|
|
41
|
+
title: options.metadata.title ?? tree.data?.frontmatter?.title,
|
|
42
|
+
creator: options.metadata.author ?? tree.data?.frontmatter?.author,
|
|
43
|
+
styles: {
|
|
44
|
+
default: {
|
|
45
|
+
document: {
|
|
46
|
+
run: {
|
|
47
|
+
font: options.typesetting.fontFamily,
|
|
48
|
+
size: fontSizeHalfPoints
|
|
49
|
+
},
|
|
50
|
+
paragraph: { spacing: { line: lineTwips } }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
sections: [
|
|
55
|
+
{
|
|
56
|
+
...pageNumberSection(options, fontSizeHalfPoints),
|
|
57
|
+
properties: {
|
|
58
|
+
page: {
|
|
59
|
+
size: { width: mmToTwips(widthMm), height: mmToTwips(heightMm) },
|
|
60
|
+
margin: Object.fromEntries(
|
|
61
|
+
Object.entries(options.pagination.margins).map(([key, value]) => [
|
|
62
|
+
key,
|
|
63
|
+
mmToTwips(value)
|
|
64
|
+
])
|
|
65
|
+
),
|
|
66
|
+
...options.pagination.pageNumbers.enabled ? { pageNumbers: { start: 1 } } : {},
|
|
67
|
+
...options.typesetting.writingMode === "vertical" ? {
|
|
68
|
+
textDirection: PageTextDirectionType.TOP_TO_BOTTOM_RIGHT_TO_LEFT
|
|
69
|
+
} : {}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
children
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
});
|
|
8
76
|
return Packer.toBuffer(document);
|
|
9
77
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
78
|
+
function pageNumberSection(options, size) {
|
|
79
|
+
const page = options.pagination.pageNumbers;
|
|
80
|
+
if (!page.enabled) return {};
|
|
81
|
+
const alignment = page.position.endsWith("left") ? AlignmentType.LEFT : page.position.endsWith("right") ? AlignmentType.RIGHT : AlignmentType.CENTER;
|
|
82
|
+
const current = new TextRun({ children: [PageNumber.CURRENT], size });
|
|
83
|
+
const runs = page.format === "dash" ? [
|
|
84
|
+
new TextRun({ text: "\u2014 ", size }),
|
|
85
|
+
current,
|
|
86
|
+
new TextRun({ text: " \u2014", size })
|
|
87
|
+
] : page.format === "fraction" ? [
|
|
88
|
+
current,
|
|
89
|
+
new TextRun({ text: " / ", size }),
|
|
90
|
+
new TextRun({ children: [PageNumber.TOTAL_PAGES], size })
|
|
91
|
+
] : [current];
|
|
92
|
+
const paragraph2 = new Paragraph({ alignment, children: runs });
|
|
93
|
+
return page.position.startsWith("top-") ? { headers: { default: new Header({ children: [paragraph2] }) } } : { footers: { default: new Footer({ children: [paragraph2] }) } };
|
|
94
|
+
}
|
|
95
|
+
function block(node, options) {
|
|
96
|
+
if (node.type === "heading")
|
|
97
|
+
return [
|
|
98
|
+
new Paragraph({
|
|
99
|
+
heading: [
|
|
100
|
+
HeadingLevel.HEADING_1,
|
|
101
|
+
HeadingLevel.HEADING_2,
|
|
102
|
+
HeadingLevel.HEADING_3,
|
|
103
|
+
HeadingLevel.HEADING_4,
|
|
104
|
+
HeadingLevel.HEADING_5,
|
|
105
|
+
HeadingLevel.HEADING_6
|
|
106
|
+
][node.depth - 1],
|
|
107
|
+
children: inline(node.children)
|
|
108
|
+
})
|
|
109
|
+
];
|
|
110
|
+
if (node.type === "paragraph") return [paragraph(node.children, options)];
|
|
111
|
+
if (node.type === "list")
|
|
112
|
+
return node.children.flatMap(
|
|
113
|
+
(item) => item.children.filter((n) => n.type === "paragraph").map(
|
|
114
|
+
(n) => new Paragraph({
|
|
115
|
+
children: inline(n.children),
|
|
116
|
+
bullet: { level: 0 }
|
|
117
|
+
})
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
if (node.type === "mdiPagebreak")
|
|
121
|
+
return [new Paragraph({ children: [new PageBreak()] })];
|
|
15
122
|
if (node.type === "mdiBlank") return [new Paragraph("")];
|
|
16
123
|
return [];
|
|
17
124
|
}
|
|
125
|
+
function paragraph(nodes, options) {
|
|
126
|
+
const fontSizeMm = (() => {
|
|
127
|
+
const dimensions = PAGE_DIMENSIONS[options.pagination.pageSize];
|
|
128
|
+
const primary = options.typesetting.writingMode === "vertical" ? (options.pagination.landscape ? dimensions.width : dimensions.height) - options.pagination.margins.top - options.pagination.margins.bottom : (options.pagination.landscape ? dimensions.height : dimensions.width) - options.pagination.margins.left - options.pagination.margins.right;
|
|
129
|
+
return primary / options.pagination.charactersPerLine;
|
|
130
|
+
})();
|
|
131
|
+
const prefix = options.typesetting.fullwidthSpaceIndent ? [new TextRun("\u3000".repeat(Math.round(options.typesetting.textIndentEm)))] : [];
|
|
132
|
+
return new Paragraph({
|
|
133
|
+
indent: options.typesetting.fullwidthSpaceIndent ? void 0 : {
|
|
134
|
+
firstLine: Math.round(
|
|
135
|
+
options.typesetting.textIndentEm * fontSizeMm / 25.4 * 1440
|
|
136
|
+
)
|
|
137
|
+
},
|
|
138
|
+
children: [...prefix, ...inline(nodes)]
|
|
139
|
+
});
|
|
140
|
+
}
|
|
18
141
|
function inline(nodes) {
|
|
19
142
|
return nodes.flatMap((node) => {
|
|
20
143
|
if (node.type === "text") return [new TextRun(node.value)];
|
|
21
|
-
if (node.type === "break" || node.type === "mdiBreak")
|
|
22
|
-
|
|
23
|
-
if (node.type === "
|
|
24
|
-
|
|
144
|
+
if (node.type === "break" || node.type === "mdiBreak")
|
|
145
|
+
return [new TextRun({ break: 1 })];
|
|
146
|
+
if (node.type === "emphasis")
|
|
147
|
+
return [new TextRun({ italics: true, children: inline(node.children) })];
|
|
148
|
+
if (node.type === "strong")
|
|
149
|
+
return [new TextRun({ bold: true, children: inline(node.children) })];
|
|
150
|
+
if (node.type === "delete")
|
|
151
|
+
return [new TextRun({ strike: true, children: inline(node.children) })];
|
|
25
152
|
if (node.type === "mdiRuby") return [rawRun(rubyXml(node.base, node.ruby))];
|
|
26
|
-
if (node.type === "mdiTcy")
|
|
153
|
+
if (node.type === "mdiTcy")
|
|
154
|
+
return [
|
|
155
|
+
rawRun(
|
|
156
|
+
`<w:r><w:rPr><w:eastAsianLayout w:combine="1" w:combineBrackets="none"/></w:rPr><w:t>${xml(
|
|
157
|
+
node.value
|
|
158
|
+
)}</w:t></w:r>`
|
|
159
|
+
)
|
|
160
|
+
];
|
|
27
161
|
if ("children" in node) return inline(node.children);
|
|
28
162
|
return [];
|
|
29
163
|
});
|
|
30
164
|
}
|
|
165
|
+
function mmToTwips(mm) {
|
|
166
|
+
return Math.round(mm / 25.4 * 1440);
|
|
167
|
+
}
|
|
31
168
|
function rubyXml(base, reading) {
|
|
32
169
|
const text = Array.isArray(reading) ? reading.join(".") : reading;
|
|
33
|
-
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="center"/><w:hps w:val="12"/><w:hpsRaise w:val="18"/><w:hpsBaseText w:val="24"/></w:rubyPr><w:rt><w:r><w:t>${xml(
|
|
170
|
+
return `<w:ruby><w:rubyPr><w:rubyAlign w:val="center"/><w:hps w:val="12"/><w:hpsRaise w:val="18"/><w:hpsBaseText w:val="24"/></w:rubyPr><w:rt><w:r><w:t>${xml(
|
|
171
|
+
text
|
|
172
|
+
)}</w:t></w:r></w:rt><w:rubyBase><w:r><w:t>${xml(
|
|
173
|
+
base
|
|
174
|
+
)}</w:t></w:r></w:rubyBase></w:ruby>`;
|
|
34
175
|
}
|
|
35
176
|
function rawRun(xmlString) {
|
|
36
177
|
return ImportedXmlComponent.fromXmlString(xmlString);
|
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.6",
|
|
4
4
|
"description": "Render MDI (.mdi) documents to DOCX",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"docx": "^9.0.0",
|
|
27
27
|
"@types/mdast": "^4.0.0",
|
|
28
|
-
"
|
|
28
|
+
"@illusions-lab/mdi-export-profile": "2.0.1",
|
|
29
|
+
"mdast-util-mdi": "2.0.5"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"remark-parse": "^11.0.0",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"typescript": "^5.6.0",
|
|
36
37
|
"vitest": "^2.1.0",
|
|
37
38
|
"@types/node": "^20.0.0",
|
|
38
|
-
"@illusions-lab/mdi-remark": "2.0.
|
|
39
|
+
"@illusions-lab/mdi-remark": "2.0.6"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|