remark-docx 0.3.8 → 0.3.10
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/README.md +1 -1
- package/lib/index.cjs +106 -162
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +106 -162
- package/lib/index.js.map +1 -1
- package/lib/mdast-to-docx.d.ts +1 -1
- package/lib/plugins/code/index.cjs +33 -3
- package/lib/plugins/code/index.cjs.map +1 -1
- package/lib/plugins/code/index.js +33 -3
- package/lib/plugins/code/index.js.map +1 -1
- package/lib/plugins/html/index.cjs +2 -2
- package/lib/plugins/html/index.cjs.map +1 -1
- package/lib/plugins/html/index.js +2 -2
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/index.cjs +17 -7
- package/lib/plugins/image/index.cjs.map +1 -1
- package/lib/plugins/image/index.js +14 -4
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/math/index.cjs +4 -2
- package/lib/plugins/math/index.cjs.map +1 -1
- package/lib/plugins/math/index.js +3 -1
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/types.d.ts +42 -5
- package/package.json +1 -1
- package/lib/mdast.d.ts +0 -2
- package/lib/utils-40yKzkXT.js +0 -19
- package/lib/utils-40yKzkXT.js.map +0 -1
- package/lib/utils-EYEfXxbh.js +0 -22
- package/lib/utils-EYEfXxbh.js.map +0 -1
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Paragraph, ParagraphChild, Table, TableOfContents } from "docx";
|
|
2
|
-
import type * as mdast from "
|
|
1
|
+
import type { ILevelsOptions, Paragraph, ParagraphChild, Table, TableOfContents } from "docx";
|
|
2
|
+
import type * as mdast from "mdast";
|
|
3
3
|
import type { GetDefinition } from "mdast-util-definitions";
|
|
4
4
|
export type DocxChild = Paragraph | Table | TableOfContents;
|
|
5
5
|
export type DocxContent = DocxChild | ParagraphChild;
|
|
@@ -7,11 +7,48 @@ type KnownNodeType = mdast.RootContent["type"];
|
|
|
7
7
|
type MdastNode<T extends string> = T extends KnownNodeType ? Extract<mdast.RootContent, {
|
|
8
8
|
type: T;
|
|
9
9
|
}> : unknown;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type Decoration = Readonly<{
|
|
11
|
+
bold?: boolean;
|
|
12
|
+
italic?: boolean;
|
|
13
|
+
strike?: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
type ListInfo = Readonly<{
|
|
16
|
+
level: number;
|
|
17
|
+
ordered: boolean;
|
|
18
|
+
reference: string;
|
|
19
|
+
checked?: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export type FootnoteRegistry = {
|
|
22
|
+
ref: (id: string) => number;
|
|
23
|
+
def: (id: string, children: Paragraph[]) => void;
|
|
24
|
+
toConfig: () => {
|
|
25
|
+
[key: string]: {
|
|
26
|
+
children: Paragraph[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type NumberingRegistry = {
|
|
31
|
+
create: () => string;
|
|
32
|
+
toConfig: () => Array<{
|
|
33
|
+
reference: string;
|
|
34
|
+
levels: ILevelsOptions[];
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
export type Context = Readonly<{
|
|
38
|
+
next: (node: readonly mdast.RootContent[], ctx?: Context) => DocxContent[];
|
|
39
|
+
deco: Decoration;
|
|
40
|
+
indent: number;
|
|
41
|
+
list?: ListInfo;
|
|
42
|
+
definition: GetDefinition;
|
|
43
|
+
footnote: FootnoteRegistry;
|
|
44
|
+
numbering: NumberingRegistry;
|
|
45
|
+
}>;
|
|
46
|
+
export type NodeBuilder<T extends string> = (node: MdastNode<T>, ctx: Context) => DocxContent | DocxContent[] | null;
|
|
47
|
+
export type NodeBuilders = {
|
|
48
|
+
[K in KnownNodeType]?: NodeBuilder<K>;
|
|
12
49
|
};
|
|
13
50
|
export type RemarkDocxPlugin = (ctx: Readonly<{
|
|
14
51
|
root: mdast.Root;
|
|
15
52
|
definition: GetDefinition;
|
|
16
|
-
}>) => Promise<
|
|
53
|
+
}>) => Promise<NodeBuilders>;
|
|
17
54
|
export {};
|
package/package.json
CHANGED
package/lib/mdast.d.ts
DELETED
package/lib/utils-40yKzkXT.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*/
|
|
4
|
-
function invariant(cond, message) {
|
|
5
|
-
throw new Error(message);
|
|
6
|
-
}
|
|
7
|
-
const alreadyWarned = {};
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
function warnOnce(message, cond = false) {
|
|
12
|
-
if (!cond && !alreadyWarned[message]) {
|
|
13
|
-
alreadyWarned[message] = true;
|
|
14
|
-
console.warn(message);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { invariant as i, warnOnce as w };
|
|
19
|
-
//# sourceMappingURL=utils-40yKzkXT.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-40yKzkXT.js","sources":["../src/utils.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nconst alreadyWarned: { [message: string]: boolean } = {};\n\n/**\n * @internal\n */\nexport function warnOnce(message: string, cond: boolean = false): void {\n if (!cond && !alreadyWarned[message]) {\n alreadyWarned[message] = true;\n console.warn(message);\n }\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AACG,SAAU,SAAS,CAAC,IAAS,EAAE,OAAe,EAAA;AAClD,IAAW,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AACrC;AAEA,MAAM,aAAa,GAAmC,EAAE;AAExD;;AAEG;SACa,QAAQ,CAAC,OAAe,EAAE,OAAgB,KAAK,EAAA;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;AACpC,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI;AAC7B,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB;AACF;;;;"}
|
package/lib/utils-EYEfXxbh.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
function invariant(cond, message) {
|
|
7
|
-
throw new Error(message);
|
|
8
|
-
}
|
|
9
|
-
const alreadyWarned = {};
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
function warnOnce(message, cond = false) {
|
|
14
|
-
if (!cond && !alreadyWarned[message]) {
|
|
15
|
-
alreadyWarned[message] = true;
|
|
16
|
-
console.warn(message);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
exports.invariant = invariant;
|
|
21
|
-
exports.warnOnce = warnOnce;
|
|
22
|
-
//# sourceMappingURL=utils-EYEfXxbh.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-EYEfXxbh.js","sources":["../src/utils.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nconst alreadyWarned: { [message: string]: boolean } = {};\n\n/**\n * @internal\n */\nexport function warnOnce(message: string, cond: boolean = false): void {\n if (!cond && !alreadyWarned[message]) {\n alreadyWarned[message] = true;\n console.warn(message);\n }\n}\n"],"names":[],"mappings":";;AAAA;;AAEG;AACG,SAAU,SAAS,CAAC,IAAS,EAAE,OAAe,EAAA;AAClD,IAAW,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC;AACrC;AAEA,MAAM,aAAa,GAAmC,EAAE;AAExD;;AAEG;SACa,QAAQ,CAAC,OAAe,EAAE,OAAgB,KAAK,EAAA;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;AACpC,QAAA,aAAa,CAAC,OAAO,CAAC,GAAG,IAAI;AAC7B,QAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;IACvB;AACF;;;;;"}
|