@yozora/tokenizer-table 2.0.0-alpha.3 → 2.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/lib/cjs/index.js +6 -8
- package/lib/esm/index.js +7 -9
- package/lib/types/types.d.ts +2 -2
- package/package.json +5 -5
package/lib/cjs/index.js
CHANGED
|
@@ -102,8 +102,8 @@ const match = function (api) {
|
|
|
102
102
|
const token = {
|
|
103
103
|
nodeType: ast.TableType,
|
|
104
104
|
position: {
|
|
105
|
-
start: coreTokenizer.
|
|
106
|
-
end: coreTokenizer.
|
|
105
|
+
start: coreTokenizer.calcStartPoint(previousLine.nodePoints, previousLine.startIndex),
|
|
106
|
+
end: coreTokenizer.calcEndPoint(nodePoints, nextIndex - 1),
|
|
107
107
|
},
|
|
108
108
|
columns,
|
|
109
109
|
rows: [row],
|
|
@@ -137,9 +137,7 @@ const match = function (api) {
|
|
|
137
137
|
if (!character.isWhitespaceCharacter(p.codePoint))
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
-
const startPoint = i < endIndex
|
|
141
|
-
? coreTokenizer.calcStartYastNodePoint(nodePoints, i)
|
|
142
|
-
: coreTokenizer.calcEndYastNodePoint(nodePoints, endIndex - 1);
|
|
140
|
+
const startPoint = i < endIndex ? coreTokenizer.calcStartPoint(nodePoints, i) : coreTokenizer.calcEndPoint(nodePoints, endIndex - 1);
|
|
143
141
|
const cellStartIndex = i, cellFirstNonWhitespaceIndex = i;
|
|
144
142
|
for (; i < endIndex; ++i) {
|
|
145
143
|
p = nodePoints[i];
|
|
@@ -156,7 +154,7 @@ const match = function (api) {
|
|
|
156
154
|
if (!character.isWhitespaceCharacter(p.codePoint))
|
|
157
155
|
break;
|
|
158
156
|
}
|
|
159
|
-
const endPoint = coreTokenizer.
|
|
157
|
+
const endPoint = coreTokenizer.calcEndPoint(nodePoints, i - 1);
|
|
160
158
|
const lines = cellFirstNonWhitespaceIndex >= cellEndIndex
|
|
161
159
|
? []
|
|
162
160
|
: [
|
|
@@ -177,8 +175,8 @@ const match = function (api) {
|
|
|
177
175
|
if (cells.length >= columns.length)
|
|
178
176
|
break;
|
|
179
177
|
}
|
|
180
|
-
const startPoint = coreTokenizer.
|
|
181
|
-
const endPoint = coreTokenizer.
|
|
178
|
+
const startPoint = coreTokenizer.calcStartPoint(nodePoints, startIndex);
|
|
179
|
+
const endPoint = coreTokenizer.calcEndPoint(nodePoints, endIndex - 1);
|
|
182
180
|
for (let c = cells.length; c < columns.length; ++c) {
|
|
183
181
|
const cell = {
|
|
184
182
|
nodeType: ast.TableCellType,
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
6
|
return {
|
|
@@ -98,8 +98,8 @@ const match = function (api) {
|
|
|
98
98
|
const token = {
|
|
99
99
|
nodeType: TableType,
|
|
100
100
|
position: {
|
|
101
|
-
start:
|
|
102
|
-
end:
|
|
101
|
+
start: calcStartPoint(previousLine.nodePoints, previousLine.startIndex),
|
|
102
|
+
end: calcEndPoint(nodePoints, nextIndex - 1),
|
|
103
103
|
},
|
|
104
104
|
columns,
|
|
105
105
|
rows: [row],
|
|
@@ -133,9 +133,7 @@ const match = function (api) {
|
|
|
133
133
|
if (!isWhitespaceCharacter(p.codePoint))
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
|
-
const startPoint = i < endIndex
|
|
137
|
-
? calcStartYastNodePoint(nodePoints, i)
|
|
138
|
-
: calcEndYastNodePoint(nodePoints, endIndex - 1);
|
|
136
|
+
const startPoint = i < endIndex ? calcStartPoint(nodePoints, i) : calcEndPoint(nodePoints, endIndex - 1);
|
|
139
137
|
const cellStartIndex = i, cellFirstNonWhitespaceIndex = i;
|
|
140
138
|
for (; i < endIndex; ++i) {
|
|
141
139
|
p = nodePoints[i];
|
|
@@ -152,7 +150,7 @@ const match = function (api) {
|
|
|
152
150
|
if (!isWhitespaceCharacter(p.codePoint))
|
|
153
151
|
break;
|
|
154
152
|
}
|
|
155
|
-
const endPoint =
|
|
153
|
+
const endPoint = calcEndPoint(nodePoints, i - 1);
|
|
156
154
|
const lines = cellFirstNonWhitespaceIndex >= cellEndIndex
|
|
157
155
|
? []
|
|
158
156
|
: [
|
|
@@ -173,8 +171,8 @@ const match = function (api) {
|
|
|
173
171
|
if (cells.length >= columns.length)
|
|
174
172
|
break;
|
|
175
173
|
}
|
|
176
|
-
const startPoint =
|
|
177
|
-
const endPoint =
|
|
174
|
+
const startPoint = calcStartPoint(nodePoints, startIndex);
|
|
175
|
+
const endPoint = calcEndPoint(nodePoints, endIndex - 1);
|
|
178
176
|
for (let c = cells.length; c < columns.length; ++c) {
|
|
179
177
|
const cell = {
|
|
180
178
|
nodeType: TableCellType,
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
4
|
export declare type INode = Table;
|
|
@@ -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.0
|
|
3
|
+
"version": "2.0.0",
|
|
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.0
|
|
39
|
-
"@yozora/character": "^2.0.0
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.0
|
|
38
|
+
"@yozora/ast": "^2.0.0",
|
|
39
|
+
"@yozora/character": "^2.0.0",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "65e99d1709fdd1c918465dce6b1e91de96bdab5e"
|
|
43
43
|
}
|