@yozora/tokenizer-table 2.0.0-alpha.2 → 2.0.1
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/cjs/index.js +6 -12
- package/lib/esm/index.js +7 -13
- package/lib/types/types.d.ts +4 -4
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -7,7 +7,6 @@ var character = require('@yozora/character');
|
|
|
7
7
|
var coreTokenizer = require('@yozora/core-tokenizer');
|
|
8
8
|
|
|
9
9
|
const match = function (api) {
|
|
10
|
-
const { name: _tokenizer } = this;
|
|
11
10
|
return {
|
|
12
11
|
isContainingBlock: false,
|
|
13
12
|
eatOpener,
|
|
@@ -103,8 +102,8 @@ const match = function (api) {
|
|
|
103
102
|
const token = {
|
|
104
103
|
nodeType: ast.TableType,
|
|
105
104
|
position: {
|
|
106
|
-
start: coreTokenizer.
|
|
107
|
-
end: coreTokenizer.
|
|
105
|
+
start: coreTokenizer.calcStartPoint(previousLine.nodePoints, previousLine.startIndex),
|
|
106
|
+
end: coreTokenizer.calcEndPoint(nodePoints, nextIndex - 1),
|
|
108
107
|
},
|
|
109
108
|
columns,
|
|
110
109
|
rows: [row],
|
|
@@ -138,9 +137,7 @@ const match = function (api) {
|
|
|
138
137
|
if (!character.isWhitespaceCharacter(p.codePoint))
|
|
139
138
|
break;
|
|
140
139
|
}
|
|
141
|
-
const startPoint = i < endIndex
|
|
142
|
-
? coreTokenizer.calcStartYastNodePoint(nodePoints, i)
|
|
143
|
-
: coreTokenizer.calcEndYastNodePoint(nodePoints, endIndex - 1);
|
|
140
|
+
const startPoint = i < endIndex ? coreTokenizer.calcStartPoint(nodePoints, i) : coreTokenizer.calcEndPoint(nodePoints, endIndex - 1);
|
|
144
141
|
const cellStartIndex = i, cellFirstNonWhitespaceIndex = i;
|
|
145
142
|
for (; i < endIndex; ++i) {
|
|
146
143
|
p = nodePoints[i];
|
|
@@ -157,7 +154,7 @@ const match = function (api) {
|
|
|
157
154
|
if (!character.isWhitespaceCharacter(p.codePoint))
|
|
158
155
|
break;
|
|
159
156
|
}
|
|
160
|
-
const endPoint = coreTokenizer.
|
|
157
|
+
const endPoint = coreTokenizer.calcEndPoint(nodePoints, i - 1);
|
|
161
158
|
const lines = cellFirstNonWhitespaceIndex >= cellEndIndex
|
|
162
159
|
? []
|
|
163
160
|
: [
|
|
@@ -170,7 +167,6 @@ const match = function (api) {
|
|
|
170
167
|
},
|
|
171
168
|
];
|
|
172
169
|
const cell = {
|
|
173
|
-
_tokenizer,
|
|
174
170
|
nodeType: ast.TableCellType,
|
|
175
171
|
position: { start: startPoint, end: endPoint },
|
|
176
172
|
lines: lines,
|
|
@@ -179,11 +175,10 @@ const match = function (api) {
|
|
|
179
175
|
if (cells.length >= columns.length)
|
|
180
176
|
break;
|
|
181
177
|
}
|
|
182
|
-
const startPoint = coreTokenizer.
|
|
183
|
-
const endPoint = coreTokenizer.
|
|
178
|
+
const startPoint = coreTokenizer.calcStartPoint(nodePoints, startIndex);
|
|
179
|
+
const endPoint = coreTokenizer.calcEndPoint(nodePoints, endIndex - 1);
|
|
184
180
|
for (let c = cells.length; c < columns.length; ++c) {
|
|
185
181
|
const cell = {
|
|
186
|
-
_tokenizer,
|
|
187
182
|
nodeType: ast.TableCellType,
|
|
188
183
|
position: { start: Object.assign({}, endPoint), end: Object.assign({}, endPoint) },
|
|
189
184
|
lines: [],
|
|
@@ -191,7 +186,6 @@ const match = function (api) {
|
|
|
191
186
|
cells.push(cell);
|
|
192
187
|
}
|
|
193
188
|
const row = {
|
|
194
|
-
_tokenizer,
|
|
195
189
|
nodeType: ast.TableRowType,
|
|
196
190
|
position: { start: startPoint, end: endPoint },
|
|
197
191
|
cells,
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TableType, TableCellType, TableRowType } from '@yozora/ast';
|
|
2
2
|
import { AsciiCodePoint, isWhitespaceCharacter } from '@yozora/character';
|
|
3
|
-
import {
|
|
3
|
+
import { calcStartPoint, calcEndPoint, mergeAndStripContentLines, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
4
4
|
|
|
5
5
|
const match = function (api) {
|
|
6
|
-
const { name: _tokenizer } = this;
|
|
7
6
|
return {
|
|
8
7
|
isContainingBlock: false,
|
|
9
8
|
eatOpener,
|
|
@@ -99,8 +98,8 @@ const match = function (api) {
|
|
|
99
98
|
const token = {
|
|
100
99
|
nodeType: TableType,
|
|
101
100
|
position: {
|
|
102
|
-
start:
|
|
103
|
-
end:
|
|
101
|
+
start: calcStartPoint(previousLine.nodePoints, previousLine.startIndex),
|
|
102
|
+
end: calcEndPoint(nodePoints, nextIndex - 1),
|
|
104
103
|
},
|
|
105
104
|
columns,
|
|
106
105
|
rows: [row],
|
|
@@ -134,9 +133,7 @@ const match = function (api) {
|
|
|
134
133
|
if (!isWhitespaceCharacter(p.codePoint))
|
|
135
134
|
break;
|
|
136
135
|
}
|
|
137
|
-
const startPoint = i < endIndex
|
|
138
|
-
? calcStartYastNodePoint(nodePoints, i)
|
|
139
|
-
: calcEndYastNodePoint(nodePoints, endIndex - 1);
|
|
136
|
+
const startPoint = i < endIndex ? calcStartPoint(nodePoints, i) : calcEndPoint(nodePoints, endIndex - 1);
|
|
140
137
|
const cellStartIndex = i, cellFirstNonWhitespaceIndex = i;
|
|
141
138
|
for (; i < endIndex; ++i) {
|
|
142
139
|
p = nodePoints[i];
|
|
@@ -153,7 +150,7 @@ const match = function (api) {
|
|
|
153
150
|
if (!isWhitespaceCharacter(p.codePoint))
|
|
154
151
|
break;
|
|
155
152
|
}
|
|
156
|
-
const endPoint =
|
|
153
|
+
const endPoint = calcEndPoint(nodePoints, i - 1);
|
|
157
154
|
const lines = cellFirstNonWhitespaceIndex >= cellEndIndex
|
|
158
155
|
? []
|
|
159
156
|
: [
|
|
@@ -166,7 +163,6 @@ const match = function (api) {
|
|
|
166
163
|
},
|
|
167
164
|
];
|
|
168
165
|
const cell = {
|
|
169
|
-
_tokenizer,
|
|
170
166
|
nodeType: TableCellType,
|
|
171
167
|
position: { start: startPoint, end: endPoint },
|
|
172
168
|
lines: lines,
|
|
@@ -175,11 +171,10 @@ const match = function (api) {
|
|
|
175
171
|
if (cells.length >= columns.length)
|
|
176
172
|
break;
|
|
177
173
|
}
|
|
178
|
-
const startPoint =
|
|
179
|
-
const endPoint =
|
|
174
|
+
const startPoint = calcStartPoint(nodePoints, startIndex);
|
|
175
|
+
const endPoint = calcEndPoint(nodePoints, endIndex - 1);
|
|
180
176
|
for (let c = cells.length; c < columns.length; ++c) {
|
|
181
177
|
const cell = {
|
|
182
|
-
_tokenizer,
|
|
183
178
|
nodeType: TableCellType,
|
|
184
179
|
position: { start: Object.assign({}, endPoint), end: Object.assign({}, endPoint) },
|
|
185
180
|
lines: [],
|
|
@@ -187,7 +182,6 @@ const match = function (api) {
|
|
|
187
182
|
cells.push(cell);
|
|
188
183
|
}
|
|
189
184
|
const row = {
|
|
190
|
-
_tokenizer,
|
|
191
185
|
nodeType: TableRowType,
|
|
192
186
|
position: { start: startPoint, end: endPoint },
|
|
193
187
|
cells,
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Position, Table, TableCellType, TableColumn, TableRowType, TableType } from '@yozora/ast';
|
|
2
2
|
import type { IBaseBlockTokenizerProps, IPartialYastBlockToken, IPhrasingContentLine, ITokenizer } from '@yozora/core-tokenizer';
|
|
3
3
|
export declare type T = TableType;
|
|
4
|
-
export declare type INode =
|
|
4
|
+
export declare type INode = Table;
|
|
5
5
|
export declare const uniqueName = "@yozora/tokenizer-table";
|
|
6
6
|
export interface IToken extends IPartialYastBlockToken<TableType> {
|
|
7
7
|
/**
|
|
8
8
|
* Table column configuration items
|
|
9
9
|
*/
|
|
10
|
-
columns:
|
|
10
|
+
columns: TableColumn[];
|
|
11
11
|
/**
|
|
12
12
|
* Table rows
|
|
13
13
|
*/
|
|
@@ -19,6 +19,6 @@ export interface ITableRowToken extends IPartialYastBlockToken<TableRowType> {
|
|
|
19
19
|
cells: ITableCellToken[];
|
|
20
20
|
}
|
|
21
21
|
export interface ITableCellToken extends IPartialYastBlockToken<TableCellType> {
|
|
22
|
-
position:
|
|
22
|
+
position: Position;
|
|
23
23
|
lines: IPhrasingContentLine[];
|
|
24
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-table",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yozora/ast": "^2.0.
|
|
39
|
-
"@yozora/character": "^2.0.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.
|
|
38
|
+
"@yozora/ast": "^2.0.1",
|
|
39
|
+
"@yozora/character": "^2.0.1",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.1"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3aea33091e402bd6c7754d91d549e8d648475073"
|
|
43
43
|
}
|