@yozora/tokenizer-definition 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
CHANGED
|
@@ -241,8 +241,8 @@ const match = function (api) {
|
|
|
241
241
|
const token = {
|
|
242
242
|
nodeType: ast.DefinitionType,
|
|
243
243
|
position: {
|
|
244
|
-
start: coreTokenizer.
|
|
245
|
-
end: coreTokenizer.
|
|
244
|
+
start: coreTokenizer.calcStartPoint(nodePoints, startIndex),
|
|
245
|
+
end: coreTokenizer.calcEndPoint(nodePoints, endIndex - 1),
|
|
246
246
|
},
|
|
247
247
|
label: labelState,
|
|
248
248
|
destination: null,
|
|
@@ -350,7 +350,7 @@ const match = function (api) {
|
|
|
350
350
|
}
|
|
351
351
|
const lastLine = token.lines[token.lines.length - 1];
|
|
352
352
|
token.title = null;
|
|
353
|
-
token.position.end = coreTokenizer.
|
|
353
|
+
token.position.end = coreTokenizer.calcEndPoint(lastLine.nodePoints, lastLine.endIndex - 1);
|
|
354
354
|
return {
|
|
355
355
|
status: 'closingAndRollback',
|
|
356
356
|
lines: token.lines.slice(token.lineNoOfTitle - 1),
|
|
@@ -376,7 +376,7 @@ const match = function (api) {
|
|
|
376
376
|
const lines = token.lines.splice(token.lineNoOfTitle - 1);
|
|
377
377
|
const lastLine = token.lines[token.lines.length - 1];
|
|
378
378
|
token.title = null;
|
|
379
|
-
token.position.end = coreTokenizer.
|
|
379
|
+
token.position.end = coreTokenizer.calcEndPoint(lastLine.nodePoints, lastLine.endIndex - 1);
|
|
380
380
|
result = { status: 'closingAndRollback', lines };
|
|
381
381
|
}
|
|
382
382
|
}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsciiCodePoint, VirtualCodePoint, isWhitespaceCharacter, isAsciiControlCharacter, calcStringFromNodePoints, calcEscapedStringFromNodePoints } from '@yozora/character';
|
|
2
|
-
import { eatOptionalWhitespaces,
|
|
2
|
+
import { eatOptionalWhitespaces, calcEndPoint, resolveLabelToIdentifier, calcStartPoint, encodeLinkDestination, BaseBlockTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
3
3
|
import { DefinitionType } from '@yozora/ast';
|
|
4
4
|
|
|
5
5
|
function eatAndCollectLinkDestination(nodePoints, startIndex, endIndex, state) {
|
|
@@ -237,8 +237,8 @@ const match = function (api) {
|
|
|
237
237
|
const token = {
|
|
238
238
|
nodeType: DefinitionType,
|
|
239
239
|
position: {
|
|
240
|
-
start:
|
|
241
|
-
end:
|
|
240
|
+
start: calcStartPoint(nodePoints, startIndex),
|
|
241
|
+
end: calcEndPoint(nodePoints, endIndex - 1),
|
|
242
242
|
},
|
|
243
243
|
label: labelState,
|
|
244
244
|
destination: null,
|
|
@@ -346,7 +346,7 @@ const match = function (api) {
|
|
|
346
346
|
}
|
|
347
347
|
const lastLine = token.lines[token.lines.length - 1];
|
|
348
348
|
token.title = null;
|
|
349
|
-
token.position.end =
|
|
349
|
+
token.position.end = calcEndPoint(lastLine.nodePoints, lastLine.endIndex - 1);
|
|
350
350
|
return {
|
|
351
351
|
status: 'closingAndRollback',
|
|
352
352
|
lines: token.lines.slice(token.lineNoOfTitle - 1),
|
|
@@ -372,7 +372,7 @@ const match = function (api) {
|
|
|
372
372
|
const lines = token.lines.splice(token.lineNoOfTitle - 1);
|
|
373
373
|
const lastLine = token.lines[token.lines.length - 1];
|
|
374
374
|
token.title = null;
|
|
375
|
-
token.position.end =
|
|
375
|
+
token.position.end = calcEndPoint(lastLine.nodePoints, lastLine.endIndex - 1);
|
|
376
376
|
result = { status: 'closingAndRollback', lines };
|
|
377
377
|
}
|
|
378
378
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Definition, DefinitionType } from '@yozora/ast';
|
|
2
2
|
import type { IBaseBlockTokenizerProps, IPartialYastBlockToken, IPhrasingContentLine, ITokenizer } from '@yozora/core-tokenizer';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { ILinkDestinationCollectingState } from './util/link-destination';
|
|
4
|
+
import type { ILinkLabelCollectingState } from './util/link-label';
|
|
5
|
+
import type { ILinkTitleCollectingState } from './util/link-title';
|
|
6
6
|
export declare type T = DefinitionType;
|
|
7
7
|
export declare type INode = Definition;
|
|
8
8
|
export declare const uniqueName = "@yozora/tokenizer-definition";
|
|
@@ -15,15 +15,15 @@ export interface IToken extends IPartialYastBlockToken<T> {
|
|
|
15
15
|
* Link label
|
|
16
16
|
* Trimmed, Case-Insensitive
|
|
17
17
|
*/
|
|
18
|
-
label:
|
|
18
|
+
label: ILinkLabelCollectingState;
|
|
19
19
|
/**
|
|
20
20
|
* Link destination
|
|
21
21
|
*/
|
|
22
|
-
destination:
|
|
22
|
+
destination: ILinkDestinationCollectingState | null;
|
|
23
23
|
/**
|
|
24
24
|
* Link title
|
|
25
25
|
*/
|
|
26
|
-
title:
|
|
26
|
+
title: ILinkTitleCollectingState | null;
|
|
27
27
|
/**
|
|
28
28
|
* The line number of the first matched character of the link label
|
|
29
29
|
*/
|
|
@@ -5,7 +5,7 @@ import type { INodePoint } from '@yozora/character';
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.github.com/gfm/#link-destination
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface ILinkDestinationCollectingState {
|
|
9
9
|
/**
|
|
10
10
|
* Whether the current token has collected a legal LinkDestination
|
|
11
11
|
*/
|
|
@@ -31,7 +31,7 @@ export interface LinkDestinationCollectingState {
|
|
|
31
31
|
* @param state
|
|
32
32
|
* @see https://github.github.com/gfm/#link-destination
|
|
33
33
|
*/
|
|
34
|
-
export declare function eatAndCollectLinkDestination(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state:
|
|
34
|
+
export declare function eatAndCollectLinkDestination(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state: ILinkDestinationCollectingState | null): {
|
|
35
35
|
nextIndex: number;
|
|
36
|
-
state:
|
|
36
|
+
state: ILinkDestinationCollectingState;
|
|
37
37
|
};
|
|
@@ -5,7 +5,7 @@ import type { INodePoint } from '@yozora/character';
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.github.com/gfm/#link-label
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface ILinkLabelCollectingState {
|
|
9
9
|
/**
|
|
10
10
|
* Whether the current token has collected a legal LinkDestination
|
|
11
11
|
*/
|
|
@@ -38,7 +38,7 @@ export interface LinkLabelCollectingState {
|
|
|
38
38
|
* @param state
|
|
39
39
|
* @see https://github.github.com/gfm/#link-label
|
|
40
40
|
*/
|
|
41
|
-
export declare function eatAndCollectLinkLabel(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state:
|
|
41
|
+
export declare function eatAndCollectLinkLabel(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state: ILinkLabelCollectingState | null): {
|
|
42
42
|
nextIndex: number;
|
|
43
|
-
state:
|
|
43
|
+
state: ILinkLabelCollectingState;
|
|
44
44
|
};
|
|
@@ -5,7 +5,7 @@ import type { INodePoint } from '@yozora/character';
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.github.com/gfm/#link-title
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface ILinkTitleCollectingState {
|
|
9
9
|
/**
|
|
10
10
|
* Whether the current token has collected a legal LinkDestination
|
|
11
11
|
*/
|
|
@@ -27,7 +27,7 @@ export interface LinkTitleCollectingState {
|
|
|
27
27
|
* @param state
|
|
28
28
|
* @see https://github.github.com/gfm/#link-title
|
|
29
29
|
*/
|
|
30
|
-
export declare function eatAndCollectLinkTitle(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state:
|
|
30
|
+
export declare function eatAndCollectLinkTitle(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number, state: ILinkTitleCollectingState | null): {
|
|
31
31
|
nextIndex: number;
|
|
32
|
-
state:
|
|
32
|
+
state: ILinkTitleCollectingState;
|
|
33
33
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-definition",
|
|
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
|
}
|