@yozora/tokenizer-link 2.0.5 → 2.1.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/types/index.d.ts +4 -4
- package/package.json +5 -5
- package/src/match.ts +4 -4
- package/src/types.ts +4 -4
- package/src/util/check-brackets.ts +2 -2
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { INodePoint, INodeInterval } from '@yozora/character';
|
|
2
|
-
import {
|
|
2
|
+
import { IInlineToken, IPartialInlineToken, ITokenizer, IBaseInlineTokenizerProps, ITokenDelimiter, BaseInlineTokenizer, IInlineTokenizer, IMatchInlineHookCreator, IParseInlineHookCreator } from '@yozora/core-tokenizer';
|
|
3
3
|
import { LinkType, Link } from '@yozora/ast';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ import { LinkType, Link } from '@yozora/ast';
|
|
|
11
11
|
* @see https://github.github.com/gfm/#example-522
|
|
12
12
|
* @see https://github.github.com/gfm/#example-523
|
|
13
13
|
*/
|
|
14
|
-
declare const checkBalancedBracketsStatus: (startIndex: number, endIndex: number, internalTokens: ReadonlyArray<
|
|
14
|
+
declare const checkBalancedBracketsStatus: (startIndex: number, endIndex: number, internalTokens: ReadonlyArray<IInlineToken>, nodePoints: ReadonlyArray<INodePoint>) => -1 | 0 | 1;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* A link destination consists of either
|
|
@@ -45,7 +45,7 @@ declare function eatLinkTitle(nodePoints: ReadonlyArray<INodePoint>, startIndex:
|
|
|
45
45
|
type T = LinkType;
|
|
46
46
|
type INode = Link;
|
|
47
47
|
declare const uniqueName = "@yozora/tokenizer-link";
|
|
48
|
-
interface IToken extends
|
|
48
|
+
interface IToken extends IPartialInlineToken<T> {
|
|
49
49
|
/**
|
|
50
50
|
* Link destination interval.
|
|
51
51
|
*/
|
|
@@ -55,7 +55,7 @@ interface IToken extends IPartialYastInlineToken<T> {
|
|
|
55
55
|
*/
|
|
56
56
|
titleContent?: INodeInterval;
|
|
57
57
|
}
|
|
58
|
-
interface IDelimiter extends
|
|
58
|
+
interface IDelimiter extends ITokenDelimiter {
|
|
59
59
|
/**
|
|
60
60
|
* IDelimiter type.
|
|
61
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-link",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"test": "cross-env TS_NODE_FILES=true NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.config.mjs --rootDir ."
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@yozora/ast": "^2.0
|
|
43
|
-
"@yozora/character": "^2.0
|
|
44
|
-
"@yozora/core-tokenizer": "^2.0
|
|
42
|
+
"@yozora/ast": "^2.1.0",
|
|
43
|
+
"@yozora/character": "^2.1.0",
|
|
44
|
+
"@yozora/core-tokenizer": "^2.1.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "387a68e8f9154944e2a6a7009a808d076d0659c6"
|
|
47
47
|
}
|
package/src/match.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { LinkType } from '@yozora/ast'
|
|
|
2
2
|
import type { INodePoint } from '@yozora/character'
|
|
3
3
|
import { AsciiCodePoint } from '@yozora/character'
|
|
4
4
|
import type {
|
|
5
|
+
IInlineToken,
|
|
5
6
|
IMatchInlineHookCreator,
|
|
6
7
|
IResultOfIsDelimiterPair,
|
|
7
8
|
IResultOfProcessDelimiterPair,
|
|
8
|
-
IYastInlineToken,
|
|
9
9
|
} from '@yozora/core-tokenizer'
|
|
10
10
|
import { eatOptionalWhitespaces, genFindDelimiter, isLinkToken } from '@yozora/core-tokenizer'
|
|
11
11
|
import type { IDelimiter, IThis, IToken, T } from './types'
|
|
@@ -154,7 +154,7 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
154
154
|
function isDelimiterPair(
|
|
155
155
|
openerDelimiter: IDelimiter,
|
|
156
156
|
closerDelimiter: IDelimiter,
|
|
157
|
-
internalTokens: ReadonlyArray<
|
|
157
|
+
internalTokens: ReadonlyArray<IInlineToken>,
|
|
158
158
|
): IResultOfIsDelimiterPair {
|
|
159
159
|
const nodePoints: ReadonlyArray<INodePoint> = api.getNodePoints()
|
|
160
160
|
|
|
@@ -187,9 +187,9 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
187
187
|
function processDelimiterPair(
|
|
188
188
|
openerDelimiter: IDelimiter,
|
|
189
189
|
closerDelimiter: IDelimiter,
|
|
190
|
-
internalTokens: ReadonlyArray<
|
|
190
|
+
internalTokens: ReadonlyArray<IInlineToken>,
|
|
191
191
|
): IResultOfProcessDelimiterPair<T, IToken, IDelimiter> {
|
|
192
|
-
const children: ReadonlyArray<
|
|
192
|
+
const children: ReadonlyArray<IInlineToken> = api.resolveInternalTokens(
|
|
193
193
|
internalTokens,
|
|
194
194
|
openerDelimiter.endIndex,
|
|
195
195
|
closerDelimiter.startIndex,
|
package/src/types.ts
CHANGED
|
@@ -2,16 +2,16 @@ import type { Link, LinkType } from '@yozora/ast'
|
|
|
2
2
|
import type { INodeInterval } from '@yozora/character'
|
|
3
3
|
import type {
|
|
4
4
|
IBaseInlineTokenizerProps,
|
|
5
|
-
|
|
5
|
+
IPartialInlineToken,
|
|
6
|
+
ITokenDelimiter,
|
|
6
7
|
ITokenizer,
|
|
7
|
-
IYastTokenDelimiter,
|
|
8
8
|
} from '@yozora/core-tokenizer'
|
|
9
9
|
|
|
10
10
|
export type T = LinkType
|
|
11
11
|
export type INode = Link
|
|
12
12
|
export const uniqueName = '@yozora/tokenizer-link'
|
|
13
13
|
|
|
14
|
-
export interface IToken extends
|
|
14
|
+
export interface IToken extends IPartialInlineToken<T> {
|
|
15
15
|
/**
|
|
16
16
|
* Link destination interval.
|
|
17
17
|
*/
|
|
@@ -22,7 +22,7 @@ export interface IToken extends IPartialYastInlineToken<T> {
|
|
|
22
22
|
titleContent?: INodeInterval
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export interface IDelimiter extends
|
|
25
|
+
export interface IDelimiter extends ITokenDelimiter {
|
|
26
26
|
/**
|
|
27
27
|
* IDelimiter type.
|
|
28
28
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { INodePoint } from '@yozora/character'
|
|
2
2
|
import { AsciiCodePoint } from '@yozora/character'
|
|
3
|
-
import type {
|
|
3
|
+
import type { IInlineToken } from '@yozora/core-tokenizer'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The link text may contain balanced brackets, but not unbalanced ones,
|
|
@@ -14,7 +14,7 @@ import type { IYastInlineToken } from '@yozora/core-tokenizer'
|
|
|
14
14
|
export const checkBalancedBracketsStatus = (
|
|
15
15
|
startIndex: number,
|
|
16
16
|
endIndex: number,
|
|
17
|
-
internalTokens: ReadonlyArray<
|
|
17
|
+
internalTokens: ReadonlyArray<IInlineToken>,
|
|
18
18
|
nodePoints: ReadonlyArray<INodePoint>,
|
|
19
19
|
): -1 | 0 | 1 => {
|
|
20
20
|
let i = startIndex
|