@unified-latex/unified-latex-util-to-string 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 +194 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11534 -0
- package/dist/index.js.map +7 -0
- package/dist/libs/compiler-string.d.ts +13 -0
- package/dist/libs/compiler-string.d.ts.map +1 -0
- package/dist/libs/to-string.d.ts +8 -0
- package/dist/libs/to-string.d.ts.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
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-util-parse
|
|
6
|
+
|
|
7
|
+
## What is this?
|
|
8
|
+
|
|
9
|
+
Functions parse strings to a `unified-latex` Abstract Syntax Tree (AST).
|
|
10
|
+
|
|
11
|
+
## When should I use this?
|
|
12
|
+
|
|
13
|
+
If you have a string that you would like to parse to a `unified-latex` `Ast.Ast`, or
|
|
14
|
+
if you are building a plugin for `unified()` that manipulates LaTeX.
|
|
15
|
+
|
|
16
|
+
# Plugins
|
|
17
|
+
|
|
18
|
+
## `unifiedLatexAstComplier`
|
|
19
|
+
|
|
20
|
+
Unified complier plugin that passes through a LaTeX AST without modification.
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
`unified().use(unifiedLatexAstComplier)`
|
|
25
|
+
|
|
26
|
+
### Type
|
|
27
|
+
|
|
28
|
+
`Plugin<void[], Ast.Root, Ast.Root>`
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
function unifiedLatexAstComplier(): void;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## `unifiedLatexFromString`
|
|
35
|
+
|
|
36
|
+
Parse a string to a LaTeX AST.
|
|
37
|
+
|
|
38
|
+
### Usage
|
|
39
|
+
|
|
40
|
+
`unified().use(unifiedLatexFromString[, options])`
|
|
41
|
+
|
|
42
|
+
#### options
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
{ mode?: "math" | "regular"; macros?: Ast.MacroInfoRecord; environments?: Ast.EnvInfoRecord; }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Type
|
|
49
|
+
|
|
50
|
+
`Plugin<{ mode?: "math" | "regular"; macros?: Ast.MacroInfoRecord; environments?: Ast.EnvInfoRecord; }[], string, Ast.Root>`
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
function unifiedLatexFromString(options: {
|
|
54
|
+
mode?: "math" | "regular";
|
|
55
|
+
macros?: Ast.MacroInfoRecord;
|
|
56
|
+
environments?: Ast.EnvInfoRecord;
|
|
57
|
+
}): void;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## `unifiedLatexFromStringMinimal`
|
|
61
|
+
|
|
62
|
+
Parse a string to a LaTeX AST with no post processing. For example,
|
|
63
|
+
no macro arguments will be attached, etc.
|
|
64
|
+
|
|
65
|
+
### Usage
|
|
66
|
+
|
|
67
|
+
`unified().use(unifiedLatexFromStringMinimal[, options])`
|
|
68
|
+
|
|
69
|
+
#### options
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
PluginOptions
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Type
|
|
76
|
+
|
|
77
|
+
`Plugin<PluginOptions[], string, Ast.Root>`
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
function unifiedLatexFromStringMinimal(options: PluginOptions): void;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## `unifiedLatexStringComplier`
|
|
84
|
+
|
|
85
|
+
Unified complier plugin that prints a LaTeX AST as a string.
|
|
86
|
+
|
|
87
|
+
### Usage
|
|
88
|
+
|
|
89
|
+
`unified().use(unifiedLatexStringComplier[, options])`
|
|
90
|
+
|
|
91
|
+
#### options
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
{ pretty?: boolean; printWidth?: number; useTabs?: boolean; }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Type
|
|
98
|
+
|
|
99
|
+
`Plugin<{ pretty?: boolean; printWidth?: number; useTabs?: boolean; }[], Ast.Root, string>`
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
function unifiedLatexStringComplier(options: {
|
|
103
|
+
pretty?: boolean;
|
|
104
|
+
printWidth?: number;
|
|
105
|
+
useTabs?: boolean;
|
|
106
|
+
}): void;
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
# Functions
|
|
110
|
+
|
|
111
|
+
## `parse(str)`
|
|
112
|
+
|
|
113
|
+
Parse the string into an AST.
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
function parse(str: String): Ast.Root;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Parameters**
|
|
120
|
+
|
|
121
|
+
| Param | Type |
|
|
122
|
+
| :---- | :------- |
|
|
123
|
+
| str | `String` |
|
|
124
|
+
|
|
125
|
+
## `parseMath(str)`
|
|
126
|
+
|
|
127
|
+
Parse `str` into an AST. Parsing starts in math mode and a list of
|
|
128
|
+
nodes is returned (instead of a "root" node).
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
function parseMath(str: string | Ast.Ast): Ast.Node[];
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Parameters**
|
|
135
|
+
|
|
136
|
+
| Param | Type |
|
|
137
|
+
| :---- | :------------------ |
|
|
138
|
+
| str | `string \| Ast.Ast` |
|
|
139
|
+
|
|
140
|
+
## `parseMathMinimal(str)`
|
|
141
|
+
|
|
142
|
+
Parse `str` to an AST with minimal processing. E.g., macro
|
|
143
|
+
arguments are not attached to macros, etc. when parsed with this
|
|
144
|
+
function.
|
|
145
|
+
|
|
146
|
+
The parsing assumes a math-mode context, so, for example, `^` and `_` are
|
|
147
|
+
parsed as macros (even though arguments are not attached to them).
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
function parseMathMinimal(str: String): Ast.Node[];
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Parameters**
|
|
154
|
+
|
|
155
|
+
| Param | Type |
|
|
156
|
+
| :---- | :------- |
|
|
157
|
+
| str | `String` |
|
|
158
|
+
|
|
159
|
+
## `parseMinimal(str)`
|
|
160
|
+
|
|
161
|
+
Parse `str` to an AST with minimal processing. E.g., macro
|
|
162
|
+
arguments are not attached to macros, etc. when parsed with this
|
|
163
|
+
function.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
function parseMinimal(str: String): Ast.Root;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Parameters**
|
|
170
|
+
|
|
171
|
+
| Param | Type |
|
|
172
|
+
| :---- | :------- |
|
|
173
|
+
| str | `String` |
|
|
174
|
+
|
|
175
|
+
# Constants
|
|
176
|
+
|
|
177
|
+
| Name | Type | Description |
|
|
178
|
+
| :---------------------------- | :------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
179
|
+
| `processLatexToAstViaUnified` | `() => Processor<Root, Root, Root, void>` | Use `unified()` to a string to an `Ast.Ast` and then return it. This function
will not print/pretty-print the `Ast.Ast` back to a string. |
|
|
180
|
+
| `processLatexViaUnified` | `() => Processor<Root, Root, Root, string>` | Use `unified()` to a string to an `Ast.Ast` and then pretty-print it. |
|
|
181
|
+
|
|
182
|
+
# Types
|
|
183
|
+
|
|
184
|
+
## `PluginOptions`
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
export type PluginOptions =
|
|
188
|
+
| {
|
|
189
|
+
mode?: "math" | "regular";
|
|
190
|
+
macros?: MacroInfoRecord;
|
|
191
|
+
environments?: EnvInfoRecord;
|
|
192
|
+
}
|
|
193
|
+
| undefined;
|
|
194
|
+
```
|