docx 9.8.0 → 9.8.1
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 +108 -57
- package/dist/index.d.cts +83 -16
- package/dist/index.d.ts +83 -16
- package/dist/index.iife.js +108 -57
- package/dist/index.mjs +109 -55
- package/dist/index.umd.cjs +108 -57
- package/dist/math.cjs +2235 -5
- package/dist/math.d.cts +316 -0
- package/dist/math.d.ts +316 -0
- package/dist/math.iife.js +2235 -5
- package/dist/math.mjs +2230 -7
- package/dist/math.umd.cjs +2235 -5
- package/package.json +3 -3
package/dist/math.d.cts
CHANGED
|
@@ -28,12 +28,14 @@ import { MathCurlyBrackets } from 'docx';
|
|
|
28
28
|
import { MathDegree } from 'docx';
|
|
29
29
|
import { MathDenominator } from 'docx';
|
|
30
30
|
import { MathFraction } from 'docx';
|
|
31
|
+
import { MathFractionType } from 'docx';
|
|
31
32
|
import { MathFunction } from 'docx';
|
|
32
33
|
import { MathFunctionName } from 'docx';
|
|
33
34
|
import { MathFunctionProperties } from 'docx';
|
|
34
35
|
import { MathIntegral } from 'docx';
|
|
35
36
|
import { MathLimit } from 'docx';
|
|
36
37
|
import { MathLimitLower } from 'docx';
|
|
38
|
+
import { MathLimitsPosition } from 'docx';
|
|
37
39
|
import { MathLimitUpper } from 'docx';
|
|
38
40
|
import { MathNumerator } from 'docx';
|
|
39
41
|
import { MathPreSubSuperScript } from 'docx';
|
|
@@ -42,6 +44,8 @@ import { MathRadicalProperties } from 'docx';
|
|
|
42
44
|
import { MathRoundBrackets } from 'docx';
|
|
43
45
|
import { MathRun } from 'docx';
|
|
44
46
|
import { MathRunOptions } from 'docx';
|
|
47
|
+
import { MathRunScript } from 'docx';
|
|
48
|
+
import { MathRunStyle } from 'docx';
|
|
45
49
|
import { MathSquareBrackets } from 'docx';
|
|
46
50
|
import { MathSubScript } from 'docx';
|
|
47
51
|
import { MathSubSuperScript } from 'docx';
|
|
@@ -92,10 +96,202 @@ export { IMathSumOptions }
|
|
|
92
96
|
|
|
93
97
|
export { IMathSuperScriptOptions }
|
|
94
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Turns LaTeX math into docx's math, to go in a `Math`, as Word's own equations, which it shows and edits as it does
|
|
101
|
+
* those typed into it.
|
|
102
|
+
*
|
|
103
|
+
* It reads the math that LaTeX, MathJax and KaTeX write: fractions, scripts, roots, sums, integrals and other large
|
|
104
|
+
* operators, functions such as sin and lim, brackets that grow with `\left` and `\right`, accents, braces, boxes,
|
|
105
|
+
* fonts such as `\mathbb` and `\mathrm`, `\text`, Greek letters and symbols, and the environments for matrices,
|
|
106
|
+
* cases and aligned equations, with `\tag` for their numbers. The math can be given in `$…$`, `$$…$$`, `\(…\)` or
|
|
107
|
+
* `\[…\]`, which are left out.
|
|
108
|
+
*
|
|
109
|
+
* Colours, sizes and spacing that Word works out for itself are left out.
|
|
110
|
+
*
|
|
111
|
+
* @param latex - The LaTeX, such as `"\\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}"`
|
|
112
|
+
* @returns The math, to be the children of a `Math`, or to go among other math components
|
|
113
|
+
* @throws If the LaTeX has a command or an environment it doesn't know, or isn't well formed, such as a `{` with no
|
|
114
|
+
* `}`. The error says where
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* new Math({ children: latexToMath("x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}") });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare const latexToMath: (latex: string) => readonly MathComponent[];
|
|
122
|
+
|
|
95
123
|
export { Math_2 as Math }
|
|
96
124
|
|
|
125
|
+
/**
|
|
126
|
+
* An accent over math (`m:acc`), such as a hat, a tilde, dots or a vector's arrow, as LaTeX's `\hat`, `\tilde`,
|
|
127
|
+
* `\dot` and `\vec`. Word stretches the accent over what it goes over.
|
|
128
|
+
*
|
|
129
|
+
* For a line over or under math, as LaTeX's `\overline` and `\underline`, use a `MathBar`.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* new MathAccent({ accent: "rightArrow", children: [new MathRun("v")] });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare class MathAccent extends BuilderElement {
|
|
137
|
+
constructor({ accent, children }: MathAccentOptions);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* An accent over math, as LaTeX writes it:
|
|
142
|
+
*
|
|
143
|
+
* - `"hat"`: x̂, `\hat` and `\widehat`;
|
|
144
|
+
* - `"check"`: x̌, `\check`;
|
|
145
|
+
* - `"tilde"`: x̃, `\tilde` and `\widetilde`;
|
|
146
|
+
* - `"acute"`: x́, `\acute`;
|
|
147
|
+
* - `"grave"`: x̀, `\grave`;
|
|
148
|
+
* - `"dot"`: ẋ, `\dot`;
|
|
149
|
+
* - `"doubleDot"`: ẍ, `\ddot`;
|
|
150
|
+
* - `"tripleDot"`: x⃛, `\dddot`;
|
|
151
|
+
* - `"breve"`: x̆, `\breve`;
|
|
152
|
+
* - `"bar"`: x̅, `\bar`;
|
|
153
|
+
* - `"ring"`: x̊, `\mathring`;
|
|
154
|
+
* - `"rightArrow"`: x⃗, `\vec` and `\overrightarrow`;
|
|
155
|
+
* - `"leftArrow"`: x⃖, `\overleftarrow`;
|
|
156
|
+
* - `"leftRightArrow"`: x⃡, `\overleftrightarrow`;
|
|
157
|
+
* - `"rightHarpoon"`: x⃑, `\overrightharpoon`;
|
|
158
|
+
* - `"leftHarpoon"`: x⃐, `\overleftharpoon`.
|
|
159
|
+
*/
|
|
160
|
+
export declare type MathAccentName = "hat" | "check" | "tilde" | "acute" | "grave" | "dot" | "doubleDot" | "tripleDot" | "breve" | "bar" | "ring" | "rightArrow" | "leftArrow" | "leftRightArrow" | "rightHarpoon" | "leftHarpoon";
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Options for {@link MathAccent}.
|
|
164
|
+
*/
|
|
165
|
+
export declare type MathAccentOptions = {
|
|
166
|
+
/**
|
|
167
|
+
* The accent.
|
|
168
|
+
* @default "hat"
|
|
169
|
+
*/
|
|
170
|
+
readonly accent?: MathAccentName;
|
|
171
|
+
/** What the accent goes over */
|
|
172
|
+
readonly children: readonly MathComponent[];
|
|
173
|
+
};
|
|
174
|
+
|
|
97
175
|
export { MathAngledBrackets }
|
|
98
176
|
|
|
177
|
+
/**
|
|
178
|
+
* A line over or under math (`m:bar`), as LaTeX's `\overline` and `\underline`, as long as what it goes over.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* new MathBar({ children: [new MathRun("AB")] });
|
|
183
|
+
* new MathBar({ position: "below", children: [new MathRun("x")] });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare class MathBar extends BuilderElement {
|
|
187
|
+
constructor({ position, children }: MathBarOptions);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Options for {@link MathBar}.
|
|
192
|
+
*/
|
|
193
|
+
export declare type MathBarOptions = {
|
|
194
|
+
/**
|
|
195
|
+
* Whether the line goes above or below.
|
|
196
|
+
* @default "above"
|
|
197
|
+
*/
|
|
198
|
+
readonly position?: MathPosition;
|
|
199
|
+
/** What the line goes over or under */
|
|
200
|
+
readonly children: readonly MathComponent[];
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A box around math (`m:borderBox`), as LaTeX's `\boxed`, with lines struck through it, as `\cancel`, `\bcancel` and
|
|
205
|
+
* `\xcancel`. Any of its sides can be left out.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* new MathBox({ children: [new MathRun("E=mc²")] });
|
|
210
|
+
* new MathBox({ borders: [], strikes: ["diagonalUp"], children: [new MathRun("x")] });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export declare class MathBox extends BuilderElement {
|
|
214
|
+
constructor({ children, borders, strikes }: MathBoxOptions);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Options for {@link MathBox}.
|
|
219
|
+
*/
|
|
220
|
+
export declare type MathBoxOptions = {
|
|
221
|
+
/** What goes in the box */
|
|
222
|
+
readonly children: readonly MathComponent[];
|
|
223
|
+
/**
|
|
224
|
+
* The sides of the box that are drawn. `[]` draws none, for lines struck through math with no box.
|
|
225
|
+
* @default ["top", "bottom", "left", "right"]
|
|
226
|
+
*/
|
|
227
|
+
readonly borders?: readonly MathBoxSide[];
|
|
228
|
+
/**
|
|
229
|
+
* Lines struck through the box, such as `["diagonalUp"]` to cancel a term.
|
|
230
|
+
* @default []
|
|
231
|
+
*/
|
|
232
|
+
readonly strikes?: readonly MathBoxStrike[];
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/** A side of a box */
|
|
236
|
+
export declare type MathBoxSide = "top" | "bottom" | "left" | "right";
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* A line struck through a box:
|
|
240
|
+
*
|
|
241
|
+
* - `"horizontal"`: across its middle;
|
|
242
|
+
* - `"vertical"`: down its middle;
|
|
243
|
+
* - `"diagonalUp"`: from its bottom left corner to its top right, as LaTeX's `\cancel`;
|
|
244
|
+
* - `"diagonalDown"`: from its top left corner to its bottom right, as `\bcancel`.
|
|
245
|
+
*/
|
|
246
|
+
export declare type MathBoxStrike = "horizontal" | "vertical" | "diagonalUp" | "diagonalDown";
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* A brace over or under math (`m:groupChr`), as long as what it goes over, as LaTeX's `\overbrace` and
|
|
250
|
+
* `\underbrace`. A label goes on the brace's other side, as Word writes it: in a limit above (`m:limUpp`) or below
|
|
251
|
+
* (`m:limLow`).
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* new MathBrace({
|
|
256
|
+
* position: "below",
|
|
257
|
+
* children: [new MathRun("1+2+⋯+n")],
|
|
258
|
+
* label: [new MathRun("n terms")],
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
export declare class MathBrace extends BuilderElement {
|
|
263
|
+
constructor({ position, brace, children, label }: MathBraceOptions);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Options for {@link MathBrace}.
|
|
268
|
+
*/
|
|
269
|
+
export declare type MathBraceOptions = {
|
|
270
|
+
/**
|
|
271
|
+
* Whether the brace goes above or below.
|
|
272
|
+
* @default "above"
|
|
273
|
+
*/
|
|
274
|
+
readonly position?: MathPosition;
|
|
275
|
+
/**
|
|
276
|
+
* The shape of the brace.
|
|
277
|
+
* @default "curly"
|
|
278
|
+
*/
|
|
279
|
+
readonly brace?: MathBraceShape;
|
|
280
|
+
/** What the brace goes over or under */
|
|
281
|
+
readonly children: readonly MathComponent[];
|
|
282
|
+
/** A label on the brace's other side, such as `n times` */
|
|
283
|
+
readonly label?: readonly MathComponent[];
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The shape of a brace:
|
|
288
|
+
*
|
|
289
|
+
* - `"curly"`: ⏞ and ⏟, as LaTeX's `\overbrace` and `\underbrace`;
|
|
290
|
+
* - `"square"`: ⎴ and ⎵, as `\overbracket` and `\underbracket`;
|
|
291
|
+
* - `"round"`: ⏜ and ⏝, as `\overparen` and `\underparen`.
|
|
292
|
+
*/
|
|
293
|
+
export declare type MathBraceShape = "curly" | "square" | "round";
|
|
294
|
+
|
|
99
295
|
/**
|
|
100
296
|
* Brackets of any characters around math (`m:d`), such as |x|, ‖v‖, ⟨a|b⟩ or a brace on one side only. They grow
|
|
101
297
|
* with what they hold.
|
|
@@ -255,6 +451,8 @@ export declare type MathEquationArrayRow = {
|
|
|
255
451
|
|
|
256
452
|
export { MathFraction }
|
|
257
453
|
|
|
454
|
+
export { MathFractionType }
|
|
455
|
+
|
|
258
456
|
export { MathFunction }
|
|
259
457
|
|
|
260
458
|
export { MathFunctionName }
|
|
@@ -263,10 +461,74 @@ export { MathFunctionProperties }
|
|
|
263
461
|
|
|
264
462
|
export { MathIntegral }
|
|
265
463
|
|
|
464
|
+
/**
|
|
465
|
+
* A large operator with limits (`m:nary`), such as ∏, ⋃ or ∮, as LaTeX's `\prod`, `\bigcup` and `\oint`, over what
|
|
466
|
+
* it applies to. `MathSum` and `MathIntegral` are two of these.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* new MathLargeOperator({
|
|
471
|
+
* operator: "product",
|
|
472
|
+
* subScript: [new MathRun("i=1")],
|
|
473
|
+
* superScript: [new MathRun("n")],
|
|
474
|
+
* children: [new MathRun("i")],
|
|
475
|
+
* });
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
export declare class MathLargeOperator extends BuilderElement {
|
|
479
|
+
constructor({ operator, children, subScript, superScript, limits }: MathLargeOperatorOptions);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* A large operator, as LaTeX writes it:
|
|
484
|
+
*
|
|
485
|
+
* - `"sum"`: ∑, `\sum`;
|
|
486
|
+
* - `"product"`: ∏, `\prod`;
|
|
487
|
+
* - `"coproduct"`: ∐, `\coprod`;
|
|
488
|
+
* - `"union"`: ⋃, `\bigcup`;
|
|
489
|
+
* - `"intersection"`: ⋂, `\bigcap`;
|
|
490
|
+
* - `"squareUnion"`: ⨆, `\bigsqcup`;
|
|
491
|
+
* - `"multisetUnion"`: ⨄, `\biguplus`;
|
|
492
|
+
* - `"logicalOr"`: ⋁, `\bigvee`;
|
|
493
|
+
* - `"logicalAnd"`: ⋀, `\bigwedge`;
|
|
494
|
+
* - `"directSum"`: ⨁, `\bigoplus`;
|
|
495
|
+
* - `"tensorProduct"`: ⨂, `\bigotimes`;
|
|
496
|
+
* - `"circledDot"`: ⨀, `\bigodot`;
|
|
497
|
+
* - `"integral"`: ∫, `\int`;
|
|
498
|
+
* - `"doubleIntegral"`: ∬, `\iint`;
|
|
499
|
+
* - `"tripleIntegral"`: ∭, `\iiint`;
|
|
500
|
+
* - `"quadrupleIntegral"`: ⨌, `\iiiint`;
|
|
501
|
+
* - `"contourIntegral"`: ∮, `\oint`;
|
|
502
|
+
* - `"surfaceIntegral"`: ∯, `\oiint`;
|
|
503
|
+
* - `"volumeIntegral"`: ∰, `\oiiint`.
|
|
504
|
+
*/
|
|
505
|
+
export declare type MathLargeOperatorName = "sum" | "product" | "coproduct" | "union" | "intersection" | "squareUnion" | "multisetUnion" | "logicalOr" | "logicalAnd" | "directSum" | "tensorProduct" | "circledDot" | "integral" | "doubleIntegral" | "tripleIntegral" | "quadrupleIntegral" | "contourIntegral" | "surfaceIntegral" | "volumeIntegral";
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Options for {@link MathLargeOperator}.
|
|
509
|
+
*/
|
|
510
|
+
export declare type MathLargeOperatorOptions = {
|
|
511
|
+
/** The operator */
|
|
512
|
+
readonly operator: MathLargeOperatorName;
|
|
513
|
+
/** What the operator applies to, such as the terms of a sum */
|
|
514
|
+
readonly children: readonly MathComponent[];
|
|
515
|
+
/** The lower limit, such as `i=1` */
|
|
516
|
+
readonly subScript?: readonly MathComponent[];
|
|
517
|
+
/** The upper limit, such as `n` */
|
|
518
|
+
readonly superScript?: readonly MathComponent[];
|
|
519
|
+
/**
|
|
520
|
+
* Where the limits go: above and below the operator, or to its right.
|
|
521
|
+
* @default "side" for integrals, and "aboveBelow" for the others, as Word puts them
|
|
522
|
+
*/
|
|
523
|
+
readonly limits?: MathLimitsPosition;
|
|
524
|
+
};
|
|
525
|
+
|
|
266
526
|
export { MathLimit }
|
|
267
527
|
|
|
268
528
|
export { MathLimitLower }
|
|
269
529
|
|
|
530
|
+
export { MathLimitsPosition }
|
|
531
|
+
|
|
270
532
|
export { MathLimitUpper }
|
|
271
533
|
|
|
272
534
|
/**
|
|
@@ -332,6 +594,56 @@ export declare type MathMatrixOptions = {
|
|
|
332
594
|
|
|
333
595
|
export { MathNumerator }
|
|
334
596
|
|
|
597
|
+
/**
|
|
598
|
+
* A phantom (`m:phant`): math that takes up room without being seen, as LaTeX's `\phantom`, to leave space for it or
|
|
599
|
+
* line things up with it. Or math that is seen but takes up no room, or less, as `\smash`.
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```typescript
|
|
603
|
+
* // As much space as "x+y" takes up
|
|
604
|
+
* new MathPhantom({ children: [new MathRun("x+y")] });
|
|
605
|
+
*
|
|
606
|
+
* // A tall fraction that doesn't push its line apart
|
|
607
|
+
* new MathPhantom({ visible: true, height: false, depth: false, children: [fraction] });
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
export declare class MathPhantom extends BuilderElement {
|
|
611
|
+
constructor({ children, visible, width, height, depth }: MathPhantomOptions);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Options for {@link MathPhantom}.
|
|
616
|
+
*/
|
|
617
|
+
export declare type MathPhantomOptions = {
|
|
618
|
+
/** The math */
|
|
619
|
+
readonly children: readonly MathComponent[];
|
|
620
|
+
/**
|
|
621
|
+
* Whether the math is seen (`m:show`).
|
|
622
|
+
* @default false
|
|
623
|
+
*/
|
|
624
|
+
readonly visible?: boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Whether it takes up its width. False gives it none (`m:zeroWid`), as LaTeX's `\vphantom`.
|
|
627
|
+
* @default true
|
|
628
|
+
*/
|
|
629
|
+
readonly width?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Whether it takes up its height above the line. False gives it none (`m:zeroAsc`), as LaTeX's `\hphantom` and
|
|
632
|
+
* `\smash`.
|
|
633
|
+
* @default true
|
|
634
|
+
*/
|
|
635
|
+
readonly height?: boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Whether it takes up its depth below the line. False gives it none (`m:zeroDesc`), as LaTeX's `\hphantom` and
|
|
638
|
+
* `\smash`.
|
|
639
|
+
* @default true
|
|
640
|
+
*/
|
|
641
|
+
readonly depth?: boolean;
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
/** Whether something goes above or below the math it is on */
|
|
645
|
+
export declare type MathPosition = "above" | "below";
|
|
646
|
+
|
|
335
647
|
export { MathPreSubSuperScript }
|
|
336
648
|
|
|
337
649
|
export { MathRadical }
|
|
@@ -344,6 +656,10 @@ export { MathRun }
|
|
|
344
656
|
|
|
345
657
|
export { MathRunOptions }
|
|
346
658
|
|
|
659
|
+
export { MathRunScript }
|
|
660
|
+
|
|
661
|
+
export { MathRunStyle }
|
|
662
|
+
|
|
347
663
|
export { MathSquareBrackets }
|
|
348
664
|
|
|
349
665
|
export { MathSubScript }
|