@yozora/tokenizer-autolink-extension 1.2.1 → 2.0.0-alpha.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/README.md +4 -6
- package/lib/cjs/index.js +52 -37
- package/lib/esm/index.js +50 -37
- package/lib/types/index.d.ts +4 -4
- package/lib/types/match.d.ts +6 -0
- package/lib/types/parse.d.ts +3 -0
- package/lib/types/tokenizer.d.ts +6 -21
- package/lib/types/types.d.ts +9 -8
- package/lib/types/util/email.d.ts +3 -3
- package/lib/types/util/uri.d.ts +7 -7
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -84,14 +84,14 @@ so you can use `YozoraParser` / `GfmExParser` directly.
|
|
|
84
84
|
registered in *YastParser* as a plugin-in before it can be used.
|
|
85
85
|
|
|
86
86
|
```typescript {4,9}
|
|
87
|
-
import {
|
|
87
|
+
import { DefaultParser } from '@yozora/core-parser'
|
|
88
88
|
import ParagraphTokenizer from '@yozora/tokenizer-paragraph'
|
|
89
89
|
import TextTokenizer from '@yozora/tokenizer-text'
|
|
90
90
|
import AutolinkExtensionTokenizer from '@yozora/tokenizer-autolink-extension'
|
|
91
91
|
|
|
92
|
-
const parser = new
|
|
93
|
-
.
|
|
94
|
-
.
|
|
92
|
+
const parser = new DefaultParser()
|
|
93
|
+
.useFallbackTokenizer(new ParagraphTokenizer())
|
|
94
|
+
.useFallbackTokenizer(new TextTokenizer())
|
|
95
95
|
.useTokenizer(new AutolinkExtensionTokenizer())
|
|
96
96
|
|
|
97
97
|
// parse source markdown content
|
|
@@ -243,7 +243,6 @@ Name | Type | Required | Default
|
|
|
243
243
|
[@yozora/tokenizer-link]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link#readme
|
|
244
244
|
[@yozora/tokenizer-link-reference]: https://github.com/yozorajs/yozora/tree/main/tokenizers/link-reference#readme
|
|
245
245
|
[@yozora/tokenizer-list]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list#readme
|
|
246
|
-
[@yozora/tokenizer-list-item]: https://github.com/yozorajs/yozora/tree/main/tokenizers/list-item#readme
|
|
247
246
|
[@yozora/tokenizer-math]: https://github.com/yozorajs/yozora/tree/main/tokenizers/math#readme
|
|
248
247
|
[@yozora/tokenizer-paragraph]: https://github.com/yozorajs/yozora/tree/main/tokenizers/paragraph#readme
|
|
249
248
|
[@yozora/tokenizer-setext-heading]: https://github.com/yozorajs/yozora/tree/main/tokenizers/setext-heading#readme
|
|
@@ -303,7 +302,6 @@ Name | Type | Required | Default
|
|
|
303
302
|
[doc-@yozora/tokenizer-definition]: https://yozora.guanghechen.com/docs/package/tokenizer-definition
|
|
304
303
|
[doc-@yozora/tokenizer-link-reference]: https://yozora.guanghechen.com/docs/package/tokenizer-link-reference
|
|
305
304
|
[doc-@yozora/tokenizer-list]: https://yozora.guanghechen.com/docs/package/tokenizer-list
|
|
306
|
-
[doc-@yozora/tokenizer-list-item]: https://yozora.guanghechen.com/docs/package/tokenizer-list-item
|
|
307
305
|
[doc-@yozora/tokenizer-math]: https://yozora.guanghechen.com/docs/package/tokenizer-math
|
|
308
306
|
[doc-@yozora/tokenizer-paragraph]: https://yozora.guanghechen.com/docs/package/tokenizer-paragraph
|
|
309
307
|
[doc-@yozora/tokenizer-setext-heading]: https://yozora.guanghechen.com/docs/package/tokenizer-setext-heading
|
package/lib/cjs/index.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ast = require('@yozora/ast');
|
|
6
5
|
var character = require('@yozora/character');
|
|
7
|
-
var coreTokenizer = require('@yozora/core-tokenizer');
|
|
8
6
|
var tokenizerAutolink = require('@yozora/tokenizer-autolink');
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var ast = require('@yozora/ast');
|
|
8
|
+
var coreTokenizer = require('@yozora/core-tokenizer');
|
|
11
9
|
|
|
12
10
|
function eatExtendEmailAddress(nodePoints, startIndex, endIndex) {
|
|
13
11
|
let i = startIndex;
|
|
@@ -36,15 +34,12 @@ function eatExtendEmailAddress(nodePoints, startIndex, endIndex) {
|
|
|
36
34
|
countOfPeriod += 1;
|
|
37
35
|
continue;
|
|
38
36
|
}
|
|
39
|
-
if (character.isAlphanumeric(c) ||
|
|
40
|
-
c === character.AsciiCodePoint.MINUS_SIGN ||
|
|
41
|
-
c === character.AsciiCodePoint.UNDERSCORE)
|
|
37
|
+
if (character.isAlphanumeric(c) || c === character.AsciiCodePoint.MINUS_SIGN || c === character.AsciiCodePoint.UNDERSCORE)
|
|
42
38
|
continue;
|
|
43
39
|
break;
|
|
44
40
|
}
|
|
45
41
|
const lastCharacter = nodePoints[i - 1].codePoint;
|
|
46
|
-
if (lastCharacter === character.AsciiCodePoint.MINUS_SIGN ||
|
|
47
|
-
lastCharacter === character.AsciiCodePoint.UNDERSCORE)
|
|
42
|
+
if (lastCharacter === character.AsciiCodePoint.MINUS_SIGN || lastCharacter === character.AsciiCodePoint.UNDERSCORE)
|
|
48
43
|
return { valid: false, nextIndex: i };
|
|
49
44
|
if (lastCharacter === character.AsciiCodePoint.DOT) {
|
|
50
45
|
i -= 1;
|
|
@@ -191,15 +186,13 @@ const helpers = [
|
|
|
191
186
|
{ contentType: 'uri-www', eat: eatWWWDomain },
|
|
192
187
|
{ contentType: 'email', eat: eatExtendEmailAddress },
|
|
193
188
|
];
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
_findDelimiter(startIndex, endIndex, nodePoints, api) {
|
|
189
|
+
const match = function (api) {
|
|
190
|
+
return {
|
|
191
|
+
findDelimiter: () => coreTokenizer.genFindDelimiter(_findDelimiter),
|
|
192
|
+
processSingleDelimiter,
|
|
193
|
+
};
|
|
194
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
195
|
+
const nodePoints = api.getNodePoints();
|
|
203
196
|
const blockStartIndex = api.getBlockStartIndex();
|
|
204
197
|
for (let i = startIndex; i < endIndex; ++i) {
|
|
205
198
|
{
|
|
@@ -250,38 +243,60 @@ class AutolinkExtensionTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
250
243
|
}
|
|
251
244
|
return null;
|
|
252
245
|
}
|
|
253
|
-
processSingleDelimiter(delimiter
|
|
246
|
+
function processSingleDelimiter(delimiter) {
|
|
254
247
|
const token = {
|
|
255
248
|
nodeType: ast.LinkType,
|
|
256
249
|
startIndex: delimiter.startIndex,
|
|
257
250
|
endIndex: delimiter.endIndex,
|
|
258
251
|
contentType: delimiter.contentType,
|
|
259
|
-
children: api.resolveFallbackTokens([], delimiter.startIndex, delimiter.endIndex
|
|
252
|
+
children: api.resolveFallbackTokens([], delimiter.startIndex, delimiter.endIndex),
|
|
260
253
|
};
|
|
261
254
|
return [token];
|
|
262
255
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const parse = function (api) {
|
|
259
|
+
return {
|
|
260
|
+
parse: (token, children) => {
|
|
261
|
+
const nodePoints = api.getNodePoints();
|
|
262
|
+
let url = character.calcStringFromNodePoints(nodePoints, token.startIndex, token.endIndex);
|
|
263
|
+
switch (token.contentType) {
|
|
264
|
+
case 'email':
|
|
265
|
+
url = 'mailto:' + url;
|
|
266
|
+
break;
|
|
267
|
+
case 'uri-www':
|
|
268
|
+
url = 'http://' + url;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
const result = {
|
|
272
|
+
type: ast.LinkType,
|
|
273
|
+
url,
|
|
274
|
+
children,
|
|
275
|
+
};
|
|
276
|
+
return result;
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const uniqueName = '@yozora/tokenizer-autolink-extension';
|
|
282
|
+
|
|
283
|
+
class AutolinkExtensionTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
284
|
+
constructor(props = {}) {
|
|
285
|
+
var _a, _b;
|
|
286
|
+
super({
|
|
287
|
+
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
288
|
+
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.LINKS,
|
|
289
|
+
});
|
|
290
|
+
this.match = match;
|
|
291
|
+
this.parse = parse;
|
|
279
292
|
}
|
|
280
293
|
}
|
|
281
294
|
|
|
282
295
|
exports.AutolinkExtensionTokenizer = AutolinkExtensionTokenizer;
|
|
283
296
|
exports.AutolinkExtensionTokenizerName = uniqueName;
|
|
284
|
-
exports
|
|
297
|
+
exports.autolinkExtensionMatch = match;
|
|
298
|
+
exports.autolinkExtensionParse = parse;
|
|
299
|
+
exports["default"] = AutolinkExtensionTokenizer;
|
|
285
300
|
exports.eatDomainSegment = eatDomainSegment;
|
|
286
301
|
exports.eatExtendEmailAddress = eatExtendEmailAddress;
|
|
287
302
|
exports.eatExtendedUrl = eatExtendedUrl;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { LinkType } from '@yozora/ast';
|
|
2
1
|
import { isAlphanumeric, AsciiCodePoint, isWhitespaceCharacter, isPunctuationCharacter, calcStringFromNodePoints } from '@yozora/character';
|
|
3
|
-
import { BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
4
2
|
import { eatAutolinkSchema } from '@yozora/tokenizer-autolink';
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { LinkType } from '@yozora/ast';
|
|
4
|
+
import { genFindDelimiter, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
7
5
|
|
|
8
6
|
function eatExtendEmailAddress(nodePoints, startIndex, endIndex) {
|
|
9
7
|
let i = startIndex;
|
|
@@ -32,15 +30,12 @@ function eatExtendEmailAddress(nodePoints, startIndex, endIndex) {
|
|
|
32
30
|
countOfPeriod += 1;
|
|
33
31
|
continue;
|
|
34
32
|
}
|
|
35
|
-
if (isAlphanumeric(c) ||
|
|
36
|
-
c === AsciiCodePoint.MINUS_SIGN ||
|
|
37
|
-
c === AsciiCodePoint.UNDERSCORE)
|
|
33
|
+
if (isAlphanumeric(c) || c === AsciiCodePoint.MINUS_SIGN || c === AsciiCodePoint.UNDERSCORE)
|
|
38
34
|
continue;
|
|
39
35
|
break;
|
|
40
36
|
}
|
|
41
37
|
const lastCharacter = nodePoints[i - 1].codePoint;
|
|
42
|
-
if (lastCharacter === AsciiCodePoint.MINUS_SIGN ||
|
|
43
|
-
lastCharacter === AsciiCodePoint.UNDERSCORE)
|
|
38
|
+
if (lastCharacter === AsciiCodePoint.MINUS_SIGN || lastCharacter === AsciiCodePoint.UNDERSCORE)
|
|
44
39
|
return { valid: false, nextIndex: i };
|
|
45
40
|
if (lastCharacter === AsciiCodePoint.DOT) {
|
|
46
41
|
i -= 1;
|
|
@@ -187,15 +182,13 @@ const helpers = [
|
|
|
187
182
|
{ contentType: 'uri-www', eat: eatWWWDomain },
|
|
188
183
|
{ contentType: 'email', eat: eatExtendEmailAddress },
|
|
189
184
|
];
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
_findDelimiter(startIndex, endIndex, nodePoints, api) {
|
|
185
|
+
const match = function (api) {
|
|
186
|
+
return {
|
|
187
|
+
findDelimiter: () => genFindDelimiter(_findDelimiter),
|
|
188
|
+
processSingleDelimiter,
|
|
189
|
+
};
|
|
190
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
191
|
+
const nodePoints = api.getNodePoints();
|
|
199
192
|
const blockStartIndex = api.getBlockStartIndex();
|
|
200
193
|
for (let i = startIndex; i < endIndex; ++i) {
|
|
201
194
|
{
|
|
@@ -246,33 +239,53 @@ class AutolinkExtensionTokenizer extends BaseInlineTokenizer {
|
|
|
246
239
|
}
|
|
247
240
|
return null;
|
|
248
241
|
}
|
|
249
|
-
processSingleDelimiter(delimiter
|
|
242
|
+
function processSingleDelimiter(delimiter) {
|
|
250
243
|
const token = {
|
|
251
244
|
nodeType: LinkType,
|
|
252
245
|
startIndex: delimiter.startIndex,
|
|
253
246
|
endIndex: delimiter.endIndex,
|
|
254
247
|
contentType: delimiter.contentType,
|
|
255
|
-
children: api.resolveFallbackTokens([], delimiter.startIndex, delimiter.endIndex
|
|
248
|
+
children: api.resolveFallbackTokens([], delimiter.startIndex, delimiter.endIndex),
|
|
256
249
|
};
|
|
257
250
|
return [token];
|
|
258
251
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const parse = function (api) {
|
|
255
|
+
return {
|
|
256
|
+
parse: (token, children) => {
|
|
257
|
+
const nodePoints = api.getNodePoints();
|
|
258
|
+
let url = calcStringFromNodePoints(nodePoints, token.startIndex, token.endIndex);
|
|
259
|
+
switch (token.contentType) {
|
|
260
|
+
case 'email':
|
|
261
|
+
url = 'mailto:' + url;
|
|
262
|
+
break;
|
|
263
|
+
case 'uri-www':
|
|
264
|
+
url = 'http://' + url;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
const result = {
|
|
268
|
+
type: LinkType,
|
|
269
|
+
url,
|
|
270
|
+
children,
|
|
271
|
+
};
|
|
272
|
+
return result;
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const uniqueName = '@yozora/tokenizer-autolink-extension';
|
|
278
|
+
|
|
279
|
+
class AutolinkExtensionTokenizer extends BaseInlineTokenizer {
|
|
280
|
+
constructor(props = {}) {
|
|
281
|
+
var _a, _b;
|
|
282
|
+
super({
|
|
283
|
+
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
284
|
+
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.LINKS,
|
|
285
|
+
});
|
|
286
|
+
this.match = match;
|
|
287
|
+
this.parse = parse;
|
|
275
288
|
}
|
|
276
289
|
}
|
|
277
290
|
|
|
278
|
-
export { AutolinkExtensionTokenizer, uniqueName as AutolinkExtensionTokenizerName, AutolinkExtensionTokenizer as default, eatDomainSegment, eatExtendEmailAddress, eatExtendedUrl, eatOptionalDomainFollows, eatValidDomain, eatWWWDomain };
|
|
291
|
+
export { AutolinkExtensionTokenizer, uniqueName as AutolinkExtensionTokenizerName, match as autolinkExtensionMatch, parse as autolinkExtensionParse, AutolinkExtensionTokenizer as default, eatDomainSegment, eatExtendEmailAddress, eatExtendedUrl, eatOptionalDomainFollows, eatValidDomain, eatWWWDomain };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AutolinkExtensionTokenizer } from './tokenizer';
|
|
2
1
|
export * from './util/email';
|
|
3
2
|
export * from './util/uri';
|
|
4
|
-
export {
|
|
3
|
+
export { match as autolinkExtensionMatch } from './match';
|
|
4
|
+
export { parse as autolinkExtensionParse } from './parse';
|
|
5
|
+
export { AutolinkExtensionTokenizer, AutolinkExtensionTokenizer as default } from './tokenizer';
|
|
5
6
|
export { uniqueName as AutolinkExtensionTokenizerName } from './types';
|
|
6
|
-
export type {
|
|
7
|
-
export default AutolinkExtensionTokenizer;
|
|
7
|
+
export type { IThis as IAutolinkExtensionHookContext, IToken as IAutolinkExtensionToken, ITokenizerProps as IAutolinkExtensionTokenizerProps, } from './types';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IMatchInlineHookCreator } from '@yozora/core-tokenizer';
|
|
2
|
+
import type { IDelimiter, IThis, IToken, T } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://github.github.com/gfm/#autolinks-extension-
|
|
5
|
+
*/
|
|
6
|
+
export declare const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
package/lib/types/tokenizer.d.ts
CHANGED
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NodePoint } from '@yozora/character';
|
|
3
|
-
import type { MatchInlinePhaseApi, ResultOfProcessSingleDelimiter, Tokenizer, TokenizerMatchInlineHook, TokenizerParseInlineHook } from '@yozora/core-tokenizer';
|
|
1
|
+
import type { IInlineTokenizer, IMatchInlineHookCreator, IParseInlineHookCreator } from '@yozora/core-tokenizer';
|
|
4
2
|
import { BaseInlineTokenizer } from '@yozora/core-tokenizer';
|
|
5
|
-
import type {
|
|
3
|
+
import type { IDelimiter, INode, IThis, IToken, ITokenizerProps, T } from './types';
|
|
6
4
|
/**
|
|
7
5
|
* Lexical Analyzer for Autolink (extension).
|
|
8
6
|
*
|
|
9
7
|
* @see https://github.github.com/gfm/#autolinks-extension-
|
|
10
8
|
*/
|
|
11
|
-
export declare class AutolinkExtensionTokenizer extends BaseInlineTokenizer<
|
|
12
|
-
constructor(props?:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @see BaseInlineTokenizer
|
|
16
|
-
*/
|
|
17
|
-
protected _findDelimiter(startIndex: number, endIndex: number, nodePoints: ReadonlyArray<NodePoint>, api: Readonly<MatchInlinePhaseApi>): Delimiter | null;
|
|
18
|
-
/**
|
|
19
|
-
* @override
|
|
20
|
-
* @see TokenizerMatchInlineHook
|
|
21
|
-
*/
|
|
22
|
-
processSingleDelimiter(delimiter: Delimiter, nodePoints: ReadonlyArray<NodePoint>, api: Readonly<MatchInlinePhaseApi>): ResultOfProcessSingleDelimiter<T, Token>;
|
|
23
|
-
/**
|
|
24
|
-
* @override
|
|
25
|
-
* @see TokenizerParseInlineHook
|
|
26
|
-
*/
|
|
27
|
-
processToken(token: Token, children: YastNode[] | undefined, nodePoints: ReadonlyArray<NodePoint>): Node;
|
|
9
|
+
export declare class AutolinkExtensionTokenizer extends BaseInlineTokenizer<T, IDelimiter, IToken, INode, IThis> implements IInlineTokenizer<T, IDelimiter, IToken, INode, IThis> {
|
|
10
|
+
constructor(props?: ITokenizerProps);
|
|
11
|
+
readonly match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis>;
|
|
12
|
+
readonly parse: IParseInlineHookCreator<T, IToken, INode, IThis>;
|
|
28
13
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ILink, LinkType } from '@yozora/ast';
|
|
2
|
+
import type { INodePoint } from '@yozora/character';
|
|
3
|
+
import type { IBaseInlineTokenizerProps, IPartialYastInlineToken, IResultOfRequiredEater, ITokenizer, IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
4
4
|
import type { AutolinkContentType } from '@yozora/tokenizer-autolink';
|
|
5
5
|
export declare type T = LinkType;
|
|
6
|
-
export declare type
|
|
6
|
+
export declare type INode = ILink;
|
|
7
7
|
export declare const uniqueName = "@yozora/tokenizer-autolink-extension";
|
|
8
8
|
export declare type AutolinkExtensionContentType = AutolinkContentType | 'uri-www';
|
|
9
|
-
export interface
|
|
9
|
+
export interface IToken extends IPartialYastInlineToken<T> {
|
|
10
10
|
/**
|
|
11
11
|
* Autolink content type: absolute uri or email.
|
|
12
12
|
*/
|
|
13
13
|
contentType: AutolinkExtensionContentType;
|
|
14
14
|
}
|
|
15
|
-
export interface
|
|
15
|
+
export interface IDelimiter extends IYastTokenDelimiter {
|
|
16
16
|
type: 'full';
|
|
17
17
|
/**
|
|
18
18
|
* Autolink and autolink-extension content types.
|
|
19
19
|
*/
|
|
20
20
|
contentType: AutolinkExtensionContentType;
|
|
21
21
|
}
|
|
22
|
-
export declare type
|
|
23
|
-
export declare type
|
|
22
|
+
export declare type IThis = ITokenizer;
|
|
23
|
+
export declare type ITokenizerProps = Partial<IBaseInlineTokenizerProps>;
|
|
24
|
+
export declare type ContentEater = (nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number) => IResultOfRequiredEater;
|
|
24
25
|
export interface ContentHelper {
|
|
25
26
|
contentType: AutolinkExtensionContentType;
|
|
26
27
|
eat: ContentEater;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IResultOfRequiredEater } from '@yozora/core-tokenizer';
|
|
3
3
|
/**
|
|
4
4
|
* An extended email autolink will be recognised when an email address is
|
|
5
5
|
* recognised within any text node. Email addresses are recognised according to
|
|
@@ -13,4 +13,4 @@ import type { ResultOfRequiredEater } from '@yozora/core-tokenizer';
|
|
|
13
13
|
*
|
|
14
14
|
* @see https://github.github.com/gfm/#extended-email-autolink
|
|
15
15
|
*/
|
|
16
|
-
export declare function eatExtendEmailAddress(nodePoints: ReadonlyArray<
|
|
16
|
+
export declare function eatExtendEmailAddress(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfRequiredEater;
|
package/lib/types/util/uri.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IResultOfOptionalEater, IResultOfRequiredEater } from '@yozora/core-tokenizer';
|
|
3
3
|
/**
|
|
4
4
|
* An extended url autolink will be recognised when one of the schemes 'http://',
|
|
5
5
|
* or 'https://', followed by a valid domain, then zero or more non-space non-<
|
|
@@ -7,12 +7,12 @@ import type { ResultOfOptionalEater, ResultOfRequiredEater } from '@yozora/core-
|
|
|
7
7
|
*
|
|
8
8
|
* @see https://github.github.com/gfm/#extended-url-autolink
|
|
9
9
|
*/
|
|
10
|
-
export declare function eatExtendedUrl(nodePoints: ReadonlyArray<
|
|
10
|
+
export declare function eatExtendedUrl(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfRequiredEater;
|
|
11
11
|
/**
|
|
12
12
|
* An extended www autolink will be recognised when the text 'www.' is found
|
|
13
13
|
* followed by a valid domain
|
|
14
14
|
*/
|
|
15
|
-
export declare function eatWWWDomain(nodePoints: ReadonlyArray<
|
|
15
|
+
export declare function eatWWWDomain(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfRequiredEater;
|
|
16
16
|
/**
|
|
17
17
|
* Try to eat an optional domain follows.
|
|
18
18
|
*
|
|
@@ -23,19 +23,19 @@ export declare function eatWWWDomain(nodePoints: ReadonlyArray<NodePoint>, start
|
|
|
23
23
|
* @param endIndex
|
|
24
24
|
* @see https://github.github.com/gfm/#extended-autolink-path-validation
|
|
25
25
|
*/
|
|
26
|
-
export declare function eatOptionalDomainFollows(nodePoints: ReadonlyArray<
|
|
26
|
+
export declare function eatOptionalDomainFollows(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfOptionalEater;
|
|
27
27
|
/**
|
|
28
28
|
* A valid domain consists of segments of alphanumeric characters,
|
|
29
29
|
* underscores (_) and hyphens (-) separated by periods (.).
|
|
30
30
|
*
|
|
31
31
|
* @see https://github.github.com/gfm/#valid-domain
|
|
32
32
|
*/
|
|
33
|
-
export declare function eatValidDomain(nodePoints: ReadonlyArray<
|
|
33
|
+
export declare function eatValidDomain(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfRequiredEater;
|
|
34
34
|
/**
|
|
35
35
|
* A valid domain segment consists of alphanumeric characters,
|
|
36
36
|
* underscores (_) and hyphens (-).
|
|
37
37
|
* @see https://github.github.com/gfm/#valid-domain
|
|
38
38
|
*/
|
|
39
|
-
export declare function eatDomainSegment(nodePoints: ReadonlyArray<
|
|
39
|
+
export declare function eatDomainSegment(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IResultOfRequiredEater & {
|
|
40
40
|
hasUnderscore: boolean;
|
|
41
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-autolink-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yozora/ast": "^
|
|
39
|
-
"@yozora/character": "^
|
|
40
|
-
"@yozora/core-tokenizer": "^
|
|
41
|
-
"@yozora/tokenizer-autolink": "^
|
|
38
|
+
"@yozora/ast": "^2.0.0-alpha.1",
|
|
39
|
+
"@yozora/character": "^2.0.0-alpha.1",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0-alpha.1",
|
|
41
|
+
"@yozora/tokenizer-autolink": "^2.0.0-alpha.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
|
|
44
44
|
}
|