@unified-latex/unified-latex-types 1.0.0

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 ADDED
@@ -0,0 +1,153 @@
1
+ <!-- DO NOT MODIFY -->
2
+ <!-- This file was autogenerated by build-docs.ts -->
3
+ <!-- Edit the docstring in index.ts and regenerate -->
4
+ <!-- rather than editing this file directly. -->
5
+ # unified-latex-types
6
+
7
+ ## What is this?
8
+
9
+ Types for the `unified-latex` Abstract Syntax Tree (AST). These types extend the `unist` AST,
10
+ but instead of a `children` attribute, they have a `content` attribute.
11
+
12
+ ## When should I use this?
13
+
14
+ If you're working with `unified-latex` ASTs.
15
+
16
+ # Types
17
+
18
+ ## `Ast`
19
+
20
+ ```typescript
21
+ export type Ast = Node | Argument | Node[];
22
+ ```
23
+
24
+ ## `EnvInfo`
25
+
26
+ ```typescript
27
+ export type EnvInfo = {
28
+ renderInfo?: {
29
+ /**
30
+ * Whether the body of the environment should be treated as math mode
31
+ *
32
+ * @type {boolean}
33
+ */
34
+ inMathMode?: boolean;
35
+ /**
36
+ * Whether to align the environment contents based on `&` and `\\` delimiters
37
+ * (like a matrix or tabular environment).
38
+ *
39
+ * @type {boolean}
40
+ */
41
+ alignContent?: boolean;
42
+ /**
43
+ * Whether the arguments should be treated as pgfkeys-type arguments.
44
+ *
45
+ * @type {boolean}
46
+ */
47
+ pgfkeysArgs?: boolean;
48
+ };
49
+ /**
50
+ * Function to process the body of an environment. The return value of `processContent`
51
+ * is treated as the new body.
52
+ *
53
+ */
54
+ processContent?: (ast: Ast.Node[]) => Ast.Node[];
55
+ /**
56
+ * The environment signature as an xparse argument specification string.
57
+ *
58
+ * @type {string}
59
+ */
60
+ signature?: string;
61
+ };
62
+ ```
63
+
64
+ ## `EnvInfoRecord`
65
+
66
+ ```typescript
67
+ export type EnvInfoRecord = Record<string, EnvInfo>;
68
+ ```
69
+
70
+ ## `GenericAst`
71
+
72
+ ```typescript
73
+ export type GenericAst = GenericNode | GenericNode[];
74
+ ```
75
+
76
+ ## `MacroInfo`
77
+
78
+ ```typescript
79
+ export type MacroInfo = {
80
+ renderInfo?: {
81
+ /**
82
+ * Whether the macro's contents wraps along with the current
83
+ * paragraph or displays as it's own block.
84
+ *
85
+ * @type {boolean}
86
+ */
87
+ inParMode?: boolean;
88
+ /**
89
+ * Whether the arguments should be processed as pgfkeys-type arguments.
90
+ *
91
+ * @type {boolean}
92
+ */
93
+ pgfkeysArgs?: boolean;
94
+ /**
95
+ * Whether there should be line breaks before and after the macro
96
+ * (e.g., like the \section{...} command.)
97
+ *
98
+ * @type {boolean}
99
+ */
100
+ breakAround?: boolean;
101
+ /**
102
+ * Whether the contents of the macro should be assumed to be in math mode.
103
+ *
104
+ * @type {boolean}
105
+ */
106
+ inMathMode?: boolean;
107
+ /**
108
+ * Whether the arguments should be rendered with a hanging indent when the wrap
109
+ * (like the arguments to \item in an enumerate environment.)
110
+ *
111
+ * @type {boolean}
112
+ */
113
+ hangingIndent?: boolean;
114
+ };
115
+ /**
116
+ * The macro signature as an xparse argument specification string.
117
+ *
118
+ * @type {string}
119
+ */
120
+ signature?: string;
121
+ /**
122
+ * Some special macros like `^` and `_` don't use
123
+ * an escape token. When matching against these macros,
124
+ * care must be taken to match the macro contents and the macro's
125
+ * escape token.
126
+ */
127
+ escapeToken?: string;
128
+ };
129
+ ```
130
+
131
+ ## `MacroInfoRecord`
132
+
133
+ ```typescript
134
+ export type MacroInfoRecord = Record<string, MacroInfo>;
135
+ ```
136
+
137
+ ## `Node`
138
+
139
+ ```typescript
140
+ export type Node =
141
+ | Root
142
+ | String
143
+ | Whitespace
144
+ | Parbreak
145
+ | Comment
146
+ | Macro
147
+ | Environment
148
+ | VerbatimEnvironment
149
+ | InlineMath
150
+ | DisplayMath
151
+ | Group
152
+ | Verb;
153
+ ```
@@ -0,0 +1,14 @@
1
+ export * from "./libs/ast-types";
2
+ export * from "./libs/type-guard";
3
+ export * from "./libs/info-specs";
4
+ /**
5
+ * ## What is this?
6
+ *
7
+ * Types for the `unified-latex` Abstract Syntax Tree (AST). These types extend the `unist` AST,
8
+ * but instead of a `children` attribute, they have a `content` attribute.
9
+ *
10
+ * ## When should I use this?
11
+ *
12
+ * If you're working with `unified-latex` ASTs.
13
+ */
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAGlC;;;;;;;;;GASG"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export * from "./libs/ast-types";
2
+ export * from "./libs/type-guard";
3
+ export * from "./libs/info-specs";
4
+ // NOTE: The docstring comment must be the last item in the index.ts file!
5
+ /**
6
+ * ## What is this?
7
+ *
8
+ * Types for the `unified-latex` Abstract Syntax Tree (AST). These types extend the `unist` AST,
9
+ * but instead of a `children` attribute, they have a `content` attribute.
10
+ *
11
+ * ## When should I use this?
12
+ *
13
+ * If you're working with `unified-latex` ASTs.
14
+ */
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAElC,0EAA0E;AAC1E;;;;;;;;;GASG"}
@@ -0,0 +1,85 @@
1
+ export declare type GenericAst = GenericNode | GenericNode[];
2
+ export interface GenericNode {
3
+ [x: string]: any;
4
+ type: string;
5
+ _renderInfo?: object;
6
+ }
7
+ interface BaseNode {
8
+ type: string;
9
+ _renderInfo?: any;
10
+ position?: {
11
+ start: {
12
+ offset: number;
13
+ line: number;
14
+ column: number;
15
+ };
16
+ end: {
17
+ offset: number;
18
+ line: number;
19
+ column: number;
20
+ };
21
+ };
22
+ }
23
+ interface ContentNode extends BaseNode {
24
+ content: Node[];
25
+ }
26
+ export interface Root extends ContentNode {
27
+ type: "root";
28
+ }
29
+ export interface String extends BaseNode {
30
+ type: "string";
31
+ content: string;
32
+ }
33
+ export interface Whitespace extends BaseNode {
34
+ type: "whitespace";
35
+ }
36
+ export interface Parbreak extends BaseNode {
37
+ type: "parbreak";
38
+ }
39
+ export interface Comment extends BaseNode {
40
+ type: "comment";
41
+ content: string;
42
+ sameline?: boolean;
43
+ suffixParbreak?: boolean;
44
+ leadingWhitespace?: boolean;
45
+ }
46
+ export interface Macro extends BaseNode {
47
+ type: "macro";
48
+ content: string;
49
+ escapeToken?: string;
50
+ args?: Argument[];
51
+ }
52
+ export interface Environment extends ContentNode {
53
+ type: "environment" | "mathenv";
54
+ env: string;
55
+ args?: Argument[];
56
+ }
57
+ export interface VerbatimEnvironment extends BaseNode {
58
+ type: "verbatim";
59
+ env: string;
60
+ content: string;
61
+ }
62
+ export interface DisplayMath extends ContentNode {
63
+ type: "displaymath";
64
+ }
65
+ export interface Group extends ContentNode {
66
+ type: "group";
67
+ }
68
+ export interface InlineMath extends ContentNode {
69
+ type: "inlinemath";
70
+ }
71
+ export interface Verb extends BaseNode {
72
+ type: "verb";
73
+ env: string;
74
+ escape: string;
75
+ content: string;
76
+ }
77
+ export interface Argument extends ContentNode {
78
+ type: "argument";
79
+ openMark: string;
80
+ closeMark: string;
81
+ }
82
+ export declare type Node = Root | String | Whitespace | Parbreak | Comment | Macro | Environment | VerbatimEnvironment | InlineMath | DisplayMath | Group | Verb;
83
+ export declare type Ast = Node | Argument | Node[];
84
+ export {};
85
+ //# sourceMappingURL=ast-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-types.d.ts","sourceRoot":"","sources":["../../libs/ast-types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG,WAAW,GAAG,WAAW,EAAE,CAAC;AAErD,MAAM,WAAW,WAAW;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,GAA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C;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC5C,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,QAAQ;IACjD,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC5C,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,KAAM,SAAQ,WAAW;IACtC,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC3C,IAAI,EAAE,YAAY,CAAC;CACtB;AAED,MAAM,WAAW,IAAK,SAAQ,QAAQ;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAS,SAAQ,WAAW;IACzC,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,oBAAY,IAAI,GACV,IAAI,GACJ,MAAM,GACN,UAAU,GACV,QAAQ,GACR,OAAO,GACP,KAAK,GACL,WAAW,GACX,mBAAmB,GACnB,UAAU,GACV,WAAW,GACX,KAAK,GACL,IAAI,CAAC;AAEX,oBAAY,GAAG,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ast-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast-types.js","sourceRoot":"","sources":["../../libs/ast-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,89 @@
1
+ import * as Ast from "./ast-types";
2
+ export declare type EnvInfo = {
3
+ renderInfo?: {
4
+ /**
5
+ * Whether the body of the environment should be treated as math mode
6
+ *
7
+ * @type {boolean}
8
+ */
9
+ inMathMode?: boolean;
10
+ /**
11
+ * Whether to align the environment contents based on `&` and `\\` delimiters
12
+ * (like a matrix or tabular environment).
13
+ *
14
+ * @type {boolean}
15
+ */
16
+ alignContent?: boolean;
17
+ /**
18
+ * Whether the arguments should be treated as pgfkeys-type arguments.
19
+ *
20
+ * @type {boolean}
21
+ */
22
+ pgfkeysArgs?: boolean;
23
+ };
24
+ /**
25
+ * Function to process the body of an environment. The return value of `processContent`
26
+ * is treated as the new body.
27
+ *
28
+ */
29
+ processContent?: (ast: Ast.Node[]) => Ast.Node[];
30
+ /**
31
+ * The environment signature as an xparse argument specification string.
32
+ *
33
+ * @type {string}
34
+ */
35
+ signature?: string;
36
+ };
37
+ export declare type MacroInfo = {
38
+ renderInfo?: {
39
+ /**
40
+ * Whether the macro's contents wraps along with the current
41
+ * paragraph or displays as it's own block.
42
+ *
43
+ * @type {boolean}
44
+ */
45
+ inParMode?: boolean;
46
+ /**
47
+ * Whether the arguments should be processed as pgfkeys-type arguments.
48
+ *
49
+ * @type {boolean}
50
+ */
51
+ pgfkeysArgs?: boolean;
52
+ /**
53
+ * Whether there should be line breaks before and after the macro
54
+ * (e.g., like the \section{...} command.)
55
+ *
56
+ * @type {boolean}
57
+ */
58
+ breakAround?: boolean;
59
+ /**
60
+ * Whether the contents of the macro should be assumed to be in math mode.
61
+ *
62
+ * @type {boolean}
63
+ */
64
+ inMathMode?: boolean;
65
+ /**
66
+ * Whether the arguments should be rendered with a hanging indent when the wrap
67
+ * (like the arguments to \item in an enumerate environment.)
68
+ *
69
+ * @type {boolean}
70
+ */
71
+ hangingIndent?: boolean;
72
+ };
73
+ /**
74
+ * The macro signature as an xparse argument specification string.
75
+ *
76
+ * @type {string}
77
+ */
78
+ signature?: string;
79
+ /**
80
+ * Some special macros like `^` and `_` don't use
81
+ * an escape token. When matching against these macros,
82
+ * care must be taken to match the macro contents and the macro's
83
+ * escape token.
84
+ */
85
+ escapeToken?: string;
86
+ };
87
+ export declare type EnvInfoRecord = Record<string, EnvInfo>;
88
+ export declare type MacroInfoRecord = Record<string, MacroInfo>;
89
+ //# sourceMappingURL=info-specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info-specs.d.ts","sourceRoot":"","sources":["../../libs/info-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,oBAAY,OAAO,GAAG;IAClB,UAAU,CAAC,EAAE;QACT;;;;WAIG;QACH,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB;;;;;WAKG;QACH,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB;;;;WAIG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;IACF;;;;OAIG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;IACjD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,oBAAY,SAAS,GAAG;IACpB,UAAU,CAAC,EAAE;QACT;;;;;WAKG;QACH,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB;;;;WAIG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB;;;;;WAKG;QACH,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB;;;;WAIG;QACH,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB;;;;;WAKG;QACH,aAAa,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;IACF;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,oBAAY,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,oBAAY,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=info-specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info-specs.js","sourceRoot":"","sources":["../../libs/info-specs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generic type of a type-guard function.
3
+ */
4
+ export interface TypeGuard<T> {
5
+ (node: any): node is T;
6
+ }
7
+ //# sourceMappingURL=type-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guard.d.ts","sourceRoot":"","sources":["../../libs/type-guard.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IACxB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC;CAC1B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-guard.js","sourceRoot":"","sources":["../../libs/type-guard.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@unified-latex/unified-latex-types",
3
+ "version": "1.0.0",
4
+ "description": "type definitions for unified-latex",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "dependencies": {
8
+ "@unified-latex/unified-latex-types": "^1.0.0"
9
+ },
10
+ "files": [
11
+ "dist/**/*.ts",
12
+ "dist/**/*.js",
13
+ "dist/**/*.map",
14
+ "dist/**/*.json"
15
+ ],
16
+ "exports": {
17
+ ".": "./dist/index.js",
18
+ "./*js": "./dist/*js",
19
+ "./*": "./dist/*.js"
20
+ },
21
+ "typesVersions": {
22
+ "*": {
23
+ "*": [
24
+ "dist/*"
25
+ ]
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "npm run clean && npm run compile",
30
+ "clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo",
31
+ "compile": "tsc -b tsconfig.json"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/siefkenj/unified-latex.git"
36
+ },
37
+ "keywords": [
38
+ "pegjs",
39
+ "latex",
40
+ "parser",
41
+ "prettier",
42
+ "unified-latex",
43
+ "unified"
44
+ ],
45
+ "author": "Jason Siefken",
46
+ "license": "MIT",
47
+ "bugs": {
48
+ "url": "https://github.com/siefkenj/unified-latex/issues"
49
+ },
50
+ "homepage": "https://github.com/siefkenj/unified-latex#readme"
51
+ }