@yozora/tokenizer-list 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +1 -1
- package/lib/cjs/index.js +31 -20
- package/lib/esm/index.js +32 -21
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -218,7 +218,7 @@ Name | Type | Required | Default
|
|
|
218
218
|
`name` | `string` | `false` | `"@yozora/tokenizer-list"`
|
|
219
219
|
`priority` | `number` | `false` | `TokenizerPriority.CONTAINING_BLOCK`
|
|
220
220
|
`enableTaskListItem` | `boolean` | `false` | `false`
|
|
221
|
-
`emptyItemCouldNotInterruptedTypes` | `YastNodeType[]` | `false` | `[
|
|
221
|
+
`emptyItemCouldNotInterruptedTypes` | `YastNodeType[]` | `false` | `[ParagraphType]`
|
|
222
222
|
|
|
223
223
|
* `name`: The unique name of the tokenizer, used to bind the token it generates,
|
|
224
224
|
to determine the tokenizer that should be called in each life cycle of the
|
package/lib/cjs/index.js
CHANGED
|
@@ -241,27 +241,39 @@ const resolveList = (tokens, api) => {
|
|
|
241
241
|
: nodes
|
|
242
242
|
.map(node => (node.type === ast.ParagraphType ? node.children : node))
|
|
243
243
|
.flat();
|
|
244
|
-
const listItem =
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
244
|
+
const listItem = api.shouldReservePosition
|
|
245
|
+
? {
|
|
246
|
+
type: ast.ListItemType,
|
|
247
|
+
position: listItemToken.position,
|
|
248
|
+
status: listItemToken.status,
|
|
249
|
+
children,
|
|
250
|
+
}
|
|
251
|
+
: { type: ast.ListItemType, status: listItemToken.status, children };
|
|
250
252
|
return listItem;
|
|
251
253
|
});
|
|
252
|
-
const node =
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
254
|
+
const node = api.shouldReservePosition
|
|
255
|
+
? {
|
|
256
|
+
type: ast.ListType,
|
|
257
|
+
position: {
|
|
258
|
+
start: Object.assign({}, tokens[0].position.start),
|
|
259
|
+
end: Object.assign({}, tokens[tokens.length - 1].position.end),
|
|
260
|
+
},
|
|
261
|
+
ordered: tokens[0].ordered,
|
|
262
|
+
orderType: tokens[0].orderType,
|
|
263
|
+
start: tokens[0].order,
|
|
264
|
+
marker: tokens[0].marker,
|
|
265
|
+
spread,
|
|
266
|
+
children,
|
|
267
|
+
}
|
|
268
|
+
: {
|
|
269
|
+
type: ast.ListType,
|
|
270
|
+
ordered: tokens[0].ordered,
|
|
271
|
+
orderType: tokens[0].orderType,
|
|
272
|
+
start: tokens[0].order,
|
|
273
|
+
marker: tokens[0].marker,
|
|
274
|
+
spread,
|
|
275
|
+
children,
|
|
276
|
+
};
|
|
265
277
|
return node;
|
|
266
278
|
};
|
|
267
279
|
|
|
@@ -278,7 +290,6 @@ class ListTokenizer extends coreTokenizer.BaseBlockTokenizer {
|
|
|
278
290
|
this.parse = parse;
|
|
279
291
|
this.enableTaskListItem = (_c = props.enableTaskListItem) !== null && _c !== void 0 ? _c : false;
|
|
280
292
|
this.emptyItemCouldNotInterruptedTypes = (_d = props.emptyItemCouldNotInterruptedTypes) !== null && _d !== void 0 ? _d : [
|
|
281
|
-
coreTokenizer.PhrasingContentType,
|
|
282
293
|
ast.ParagraphType,
|
|
283
294
|
];
|
|
284
295
|
}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ListType, TaskStatus, ParagraphType, ListItemType } from '@yozora/ast';
|
|
2
|
-
import { calcStartYastNodePoint, calcEndYastNodePoint, BaseBlockTokenizer, TokenizerPriority
|
|
2
|
+
import { calcStartYastNodePoint, calcEndYastNodePoint, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
3
3
|
import { isAsciiDigitCharacter, AsciiCodePoint, isAsciiLowerLetter, isAsciiUpperLetter, VirtualCodePoint, isSpaceCharacter, isWhitespaceCharacter } from '@yozora/character';
|
|
4
4
|
|
|
5
5
|
const match = function () {
|
|
@@ -237,27 +237,39 @@ const resolveList = (tokens, api) => {
|
|
|
237
237
|
: nodes
|
|
238
238
|
.map(node => (node.type === ParagraphType ? node.children : node))
|
|
239
239
|
.flat();
|
|
240
|
-
const listItem =
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
240
|
+
const listItem = api.shouldReservePosition
|
|
241
|
+
? {
|
|
242
|
+
type: ListItemType,
|
|
243
|
+
position: listItemToken.position,
|
|
244
|
+
status: listItemToken.status,
|
|
245
|
+
children,
|
|
246
|
+
}
|
|
247
|
+
: { type: ListItemType, status: listItemToken.status, children };
|
|
246
248
|
return listItem;
|
|
247
249
|
});
|
|
248
|
-
const node =
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
250
|
+
const node = api.shouldReservePosition
|
|
251
|
+
? {
|
|
252
|
+
type: ListType,
|
|
253
|
+
position: {
|
|
254
|
+
start: Object.assign({}, tokens[0].position.start),
|
|
255
|
+
end: Object.assign({}, tokens[tokens.length - 1].position.end),
|
|
256
|
+
},
|
|
257
|
+
ordered: tokens[0].ordered,
|
|
258
|
+
orderType: tokens[0].orderType,
|
|
259
|
+
start: tokens[0].order,
|
|
260
|
+
marker: tokens[0].marker,
|
|
261
|
+
spread,
|
|
262
|
+
children,
|
|
263
|
+
}
|
|
264
|
+
: {
|
|
265
|
+
type: ListType,
|
|
266
|
+
ordered: tokens[0].ordered,
|
|
267
|
+
orderType: tokens[0].orderType,
|
|
268
|
+
start: tokens[0].order,
|
|
269
|
+
marker: tokens[0].marker,
|
|
270
|
+
spread,
|
|
271
|
+
children,
|
|
272
|
+
};
|
|
261
273
|
return node;
|
|
262
274
|
};
|
|
263
275
|
|
|
@@ -274,7 +286,6 @@ class ListTokenizer extends BaseBlockTokenizer {
|
|
|
274
286
|
this.parse = parse;
|
|
275
287
|
this.enableTaskListItem = (_c = props.enableTaskListItem) !== null && _c !== void 0 ? _c : false;
|
|
276
288
|
this.emptyItemCouldNotInterruptedTypes = (_d = props.emptyItemCouldNotInterruptedTypes) !== null && _d !== void 0 ? _d : [
|
|
277
|
-
PhrasingContentType,
|
|
278
289
|
ParagraphType,
|
|
279
290
|
];
|
|
280
291
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-list",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
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-alpha.
|
|
39
|
-
"@yozora/character": "^2.0.0-alpha.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.0-alpha.
|
|
38
|
+
"@yozora/ast": "^2.0.0-alpha.2",
|
|
39
|
+
"@yozora/character": "^2.0.0-alpha.2",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0-alpha.2"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "da59d85520455c59a117a35032ef1a035c10ea21"
|
|
43
43
|
}
|