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/lib/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Paragraph, ParagraphChild, Table, TableOfContents } from "docx";
2
- import type * as mdast from "./mdast";
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
- export type NodeOverrides = {
11
- [K in KnownNodeType]?: (node: MdastNode<K>, next: (node: mdast.RootContent[]) => DocxContent[]) => DocxContent | DocxContent[] | null;
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<NodeOverrides>;
53
+ }>) => Promise<NodeBuilders>;
17
54
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remark-docx",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "description": "remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",
package/lib/mdast.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export type * from "mdast";
2
- export type * from "mdast-util-math";
@@ -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;;;;"}
@@ -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;;;;;"}