@unified-latex/unified-latex-util-split 1.0.1 → 1.0.7
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.map → index.cjs.map} +0 -0
- package/{dist/index.d.ts → index.d.ts} +0 -0
- package/{dist/index.d.ts.map → index.d.ts.map} +0 -0
- package/{dist/index.js → index.js} +0 -0
- package/{dist/index.js.map → index.js.map} +0 -0
- package/{dist/libs → libs}/array-join.d.ts +0 -0
- package/{dist/libs → libs}/array-join.d.ts.map +0 -0
- package/{dist/libs → libs}/split-on-condition.d.ts +0 -0
- package/{dist/libs → libs}/split-on-condition.d.ts.map +0 -0
- package/{dist/libs → libs}/split-on-macro.d.ts +0 -0
- package/{dist/libs → libs}/split-on-macro.d.ts.map +0 -0
- package/{dist/libs → libs}/unsplit-on-macro.d.ts +0 -0
- package/{dist/libs → libs}/unsplit-on-macro.d.ts.map +0 -0
- package/package.json +26 -38
- package/README.md +0 -97
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unified-latex/unified-latex-util-split",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Functions for modifying a unified-latex AST",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@unified-latex/unified-latex-types": "
|
|
9
|
-
"@unified-latex/unified-latex-util-match": "
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"dist/**/*.ts",
|
|
13
|
-
"dist/**/*.js",
|
|
14
|
-
"dist/**/*.map",
|
|
15
|
-
"dist/**/*.json"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
".": {
|
|
19
|
-
"import": "./dist/index.js",
|
|
20
|
-
"require": "./dist/index.cjs"
|
|
21
|
-
},
|
|
22
|
-
"./*js": "./dist/*js",
|
|
23
|
-
"./*": {
|
|
24
|
-
"import": "./dist/*.js",
|
|
25
|
-
"require": "./dist/*.cjs"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "npm run clean && mkdirp ./dist && npm run compile",
|
|
30
|
-
"clean": "rm -rf ./dist && rm -rf tsconfig.tsbuildinfo",
|
|
31
|
-
"compile": "tsc -b tsconfig.json & node build.js",
|
|
32
|
-
"test": "jest"
|
|
8
|
+
"@unified-latex/unified-latex-types": "^1.0.7",
|
|
9
|
+
"@unified-latex/unified-latex-util-match": "^1.0.7"
|
|
33
10
|
},
|
|
34
11
|
"repository": {
|
|
35
12
|
"type": "git",
|
|
@@ -49,15 +26,26 @@
|
|
|
49
26
|
"url": "https://github.com/siefkenj/unified-latex/issues"
|
|
50
27
|
},
|
|
51
28
|
"homepage": "https://github.com/siefkenj/unified-latex#readme",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "index.js",
|
|
32
|
+
"require": "index.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./*js": "./*js",
|
|
35
|
+
"./*": {
|
|
36
|
+
"import": "./*/index.js",
|
|
37
|
+
"require": "./*/index.cjs",
|
|
38
|
+
"types": "./*/index.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./*/index": {
|
|
41
|
+
"import": "./*/index.js",
|
|
42
|
+
"require": "./*/index.cjs"
|
|
61
43
|
}
|
|
62
|
-
}
|
|
63
|
-
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"**/*.ts",
|
|
47
|
+
"**/*.js",
|
|
48
|
+
"**/*.map",
|
|
49
|
+
"**/*.json"
|
|
50
|
+
]
|
|
51
|
+
}
|
package/README.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
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-split
|
|
6
|
-
|
|
7
|
-
## What is this?
|
|
8
|
-
|
|
9
|
-
Functions to manipulate `unified-latex` Abstract Syntax Tree (AST).
|
|
10
|
-
|
|
11
|
-
## When should I use this?
|
|
12
|
-
|
|
13
|
-
If you want break apart or join an array of nodes based on a condition. For example,
|
|
14
|
-
this is used to split on `&` characters in the `align` environment.
|
|
15
|
-
|
|
16
|
-
# Functions
|
|
17
|
-
|
|
18
|
-
## `arrayJoin(array, sep)`
|
|
19
|
-
|
|
20
|
-
Joins an array of arrays with the item `sep`
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
function arrayJoin<T>(array: T[][], sep: T | T[]): T[];
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
**Parameters**
|
|
27
|
-
|
|
28
|
-
| Param | Type |
|
|
29
|
-
| :---- | :--------- |
|
|
30
|
-
| array | `T[][]` |
|
|
31
|
-
| sep | `T \| T[]` |
|
|
32
|
-
|
|
33
|
-
## `splitOnCondition(nodes, splitFunc, options)`
|
|
34
|
-
|
|
35
|
-
Split a list of nodes based on whether `splitFunc` returns `true`.
|
|
36
|
-
If `onlySplitOnFirstOccurrence` is set to true in the `options` object, then
|
|
37
|
-
there will be at most two segments returned.
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
function splitOnCondition(
|
|
41
|
-
nodes: Ast.Node[],
|
|
42
|
-
splitFunc: (node: Ast.Node) => boolean,
|
|
43
|
-
options: { onlySplitOnFirstOccurrence?: boolean }
|
|
44
|
-
): { segments: Ast.Node[][]; separators: Ast.Node[] };
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
**Parameters**
|
|
48
|
-
|
|
49
|
-
| Param | Type |
|
|
50
|
-
| :-------- | :-------------------------------- |
|
|
51
|
-
| nodes | `Ast.Node[]` |
|
|
52
|
-
| splitFunc | `(node: Ast.Node) => boolean` |
|
|
53
|
-
| options | <span color='gray'>Omitted</span> |
|
|
54
|
-
|
|
55
|
-
## `splitOnMacro(ast, macroName)`
|
|
56
|
-
|
|
57
|
-
Split an array of AST nodes based on a macro. An object `{segments: [], macros: []}`
|
|
58
|
-
is returned. The original array is reconstructed as
|
|
59
|
-
`segments[0] + macros[0] + segments[1] + ...`.
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
function splitOnMacro(
|
|
63
|
-
ast: Ast.Node[],
|
|
64
|
-
macroName: string | string[]
|
|
65
|
-
): { segments: Ast.Node[][]; macros: Ast.Macro[] };
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Parameters**
|
|
69
|
-
|
|
70
|
-
| Param | Type |
|
|
71
|
-
| :-------- | :------------------- |
|
|
72
|
-
| ast | `Ast.Node[]` |
|
|
73
|
-
| macroName | `string \| string[]` |
|
|
74
|
-
|
|
75
|
-
`unsplitOnMacro({
|
|
76
|
-
segments,
|
|
77
|
-
macros,
|
|
78
|
-
})`
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
Does the reverse of `splitOnMacro`
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
function unsplitOnMacro({
|
|
85
|
-
segments,
|
|
86
|
-
macros,
|
|
87
|
-
}: {
|
|
88
|
-
segments: Ast.Node[][];
|
|
89
|
-
macros: Ast.Node[] | Ast.Node[][];
|
|
90
|
-
}): Ast.Node[];
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
**Parameters**
|
|
94
|
-
|
|
95
|
-
| Param | Type |
|
|
96
|
-
| :---------------------------------------- | :-------------------------------- |
|
|
97
|
-
| {
 segments,
 macros,
} | <span color='gray'>Omitted</span> |
|